Index: AUTHORS
===================================================================
--- AUTHORS	(revision b21cb9dbead4d40950777be4260bea1a6560f9b6)
+++ AUTHORS	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -1,3 +1,1 @@
-Jan Hamaekers (hamaekers@ins.uni-bonn.de)
-Frederik Heber (heber@ins.uni-bonn.de)
-Ralf Wildenhuis (wildenhuis@ins.uni-bonn.de)
+Frederik Heber	(heber@ins.uni-bonn.de)
Index: COPYING
===================================================================
--- COPYING	(revision b21cb9dbead4d40950777be4260bea1a6560f9b6)
+++ COPYING	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -1,2 +1,23 @@
+<<<<<<< HEAD
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  You can apply it to
+=======
 		    GNU GENERAL PUBLIC LICENSE
 		       Version 2, June 1991
@@ -17,4 +38,5 @@
 using it.  (Some other Free Software Foundation software is covered by
 the GNU Library General Public License instead.)  You can apply it to
+>>>>>>> FETCH_HEAD
 your programs, too.
 
@@ -22,4 +44,605 @@
 price.  Our General Public Licenses are designed to make sure that you
 have the freedom to distribute copies of free software (and charge for
+<<<<<<< HEAD
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  You must make sure that they, too, receive
+or can get the source code.  And you must show them these terms so they
+know their rights.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
+
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
+
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
+
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
+
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
+
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
+
+  If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Use with the GNU Affero General Public License.
+
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+  Each version is given a distinguishing version number.  If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+  If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
+
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. Limitation of Liability.
+
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+  17. Interpretation of Sections 15 and 16.
+
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+=======
 this service if you wish), that you receive source code or can get it
 if you want it, that you can change the software or use pieces of it
@@ -286,4 +909,5 @@
 
 	    How to Apply These Terms to Your New Programs
+>>>>>>> FETCH_HEAD
 
   If you develop a new program, and you want it to be of the greatest
@@ -293,5 +917,9 @@
   To do so, attach the following notices to the program.  It is safest
 to attach them to the start of each source file to most effectively
+<<<<<<< HEAD
+state the exclusion of warranty; and each file should have at least
+=======
 convey the exclusion of warranty; and each file should have at least
+>>>>>>> FETCH_HEAD
 the "copyright" line and a pointer to where the full notice is found.
 
@@ -299,7 +927,13 @@
     Copyright (C) <year>  <name of author>
 
+<<<<<<< HEAD
+    This program 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 3 of the License, or
+=======
     This program 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
+>>>>>>> FETCH_HEAD
     (at your option) any later version.
 
@@ -310,4 +944,15 @@
 
     You should have received a copy of the GNU General Public License
+<<<<<<< HEAD
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+  If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+    <program>  Copyright (C) <year>  <name of author>
+    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+=======
     along with this program; if not, write to the Free Software
     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
@@ -321,8 +966,25 @@
     Gnomovision version 69, Copyright (C) year  name of author
     Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+>>>>>>> FETCH_HEAD
     This is free software, and you are welcome to redistribute it
     under certain conditions; type `show c' for details.
 
 The hypothetical commands `show w' and `show c' should show the appropriate
+<<<<<<< HEAD
+parts of the General Public License.  Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+  The GNU General Public License does not permit incorporating your program
+into proprietary programs.  If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.  But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
+=======
 parts of the General Public License.  Of course, the commands you use may
 be called something other than `show w' and `show c'; they could even be
@@ -344,2 +1006,3 @@
 library.  If this is what you want to do, use the GNU Library General
 Public License instead of this License.
+>>>>>>> FETCH_HEAD
Index: INSTALL
===================================================================
--- INSTALL	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ INSTALL	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,365 @@
+Installation Instructions
+*************************
+
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
+2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+
+   Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved.  This file is offered as-is,
+without warranty of any kind.
+
+Basic Installation
+==================
+
+   Briefly, the shell commands `./configure; make; make install' should
+configure, build, and install this package.  The following
+more-detailed instructions are generic; see the `README' file for
+instructions specific to this package.  Some packages provide this
+`INSTALL' file but do not implement all of the features documented
+below.  The lack of an optional feature in a given package is not
+necessarily a bug.  More recommendations for GNU packages can be found
+in *note Makefile Conventions: (standards)Makefile Conventions.
+
+   The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation.  It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions.  Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+   It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring.  Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.
+
+   If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release.  If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+   The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'.  You need `configure.ac' if
+you want to change it or regenerate `configure' using a newer version
+of `autoconf'.
+
+   The simplest way to compile this package is:
+
+  1. `cd' to the directory containing the package's source code and type
+     `./configure' to configure the package for your system.
+
+     Running `configure' might take a while.  While running, it prints
+     some messages telling which features it is checking for.
+
+  2. Type `make' to compile the package.
+
+  3. Optionally, type `make check' to run any self-tests that come with
+     the package, generally using the just-built uninstalled binaries.
+
+  4. Type `make install' to install the programs and any data files and
+     documentation.  When installing into a prefix owned by root, it is
+     recommended that the package be configured and built as a regular
+     user, and only the `make install' phase executed with root
+     privileges.
+
+  5. Optionally, type `make installcheck' to repeat any self-tests, but
+     this time using the binaries in their final installed location.
+     This target does not install anything.  Running this target as a
+     regular user, particularly if the prior `make install' required
+     root privileges, verifies that the installation completed
+     correctly.
+
+  6. You can remove the program binaries and object files from the
+     source code directory by typing `make clean'.  To also remove the
+     files that `configure' created (so you can compile the package for
+     a different kind of computer), type `make distclean'.  There is
+     also a `make maintainer-clean' target, but that is intended mainly
+     for the package's developers.  If you use it, you may have to get
+     all sorts of other programs in order to regenerate files that came
+     with the distribution.
+
+  7. Often, you can also type `make uninstall' to remove the installed
+     files again.  In practice, not all packages have tested that
+     uninstallation works correctly, even though it is required by the
+     GNU Coding Standards.
+
+  8. Some packages, particularly those that use Automake, provide `make
+     distcheck', which can by used by developers to test that all other
+     targets like `make install' and `make uninstall' work correctly.
+     This target is generally not run by end users.
+
+Compilers and Options
+=====================
+
+   Some systems require unusual options for compilation or linking that
+the `configure' script does not know about.  Run `./configure --help'
+for details on some of the pertinent environment variables.
+
+   You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment.  Here
+is an example:
+
+     ./configure CC=c99 CFLAGS=-g LIBS=-lposix
+
+   *Note Defining Variables::, for more details.
+
+Compiling For Multiple Architectures
+====================================
+
+   You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory.  To do this, you can use GNU `make'.  `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script.  `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.  This
+is known as a "VPATH" build.
+
+   With a non-GNU `make', it is safer to compile the package for one
+architecture at a time in the source code directory.  After you have
+installed the package for one architecture, use `make distclean' before
+reconfiguring for another architecture.
+
+   On MacOS X 10.5 and later systems, you can create libraries and
+executables that work on multiple system types--known as "fat" or
+"universal" binaries--by specifying multiple `-arch' options to the
+compiler but only a single `-arch' option to the preprocessor.  Like
+this:
+
+     ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+                 CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+                 CPP="gcc -E" CXXCPP="g++ -E"
+
+   This is not guaranteed to produce working output in all cases, you
+may have to build one architecture at a time and combine the results
+using the `lipo' tool if you have problems.
+
+Installation Names
+==================
+
+   By default, `make install' installs the package's commands under
+`/usr/local/bin', include files under `/usr/local/include', etc.  You
+can specify an installation prefix other than `/usr/local' by giving
+`configure' the option `--prefix=PREFIX', where PREFIX must be an
+absolute file name.
+
+   You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files.  If you
+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files still use the regular prefix.
+
+   In addition, if you use an unusual directory layout you can give
+options like `--bindir=DIR' to specify different values for particular
+kinds of files.  Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.  In general, the
+default for these options is expressed in terms of `${prefix}', so that
+specifying just `--prefix' will affect all of the other directory
+specifications that were not explicitly provided.
+
+   The most portable way to affect installation locations is to pass the
+correct locations to `configure'; however, many packages provide one or
+both of the following shortcuts of passing variable assignments to the
+`make install' command line to change installation locations without
+having to reconfigure or recompile.
+
+   The first method involves providing an override variable for each
+affected directory.  For example, `make install
+prefix=/alternate/directory' will choose an alternate location for all
+directory configuration variables that were expressed in terms of
+`${prefix}'.  Any directories that were specified during `configure',
+but not in terms of `${prefix}', must each be overridden at install
+time for the entire installation to be relocated.  The approach of
+makefile variable overrides for each directory variable is required by
+the GNU Coding Standards, and ideally causes no recompilation.
+However, some platforms have known limitations with the semantics of
+shared libraries that end up requiring recompilation when using this
+method, particularly noticeable in packages that use GNU Libtool.
+
+   The second method involves providing the `DESTDIR' variable.  For
+example, `make install DESTDIR=/alternate/directory' will prepend
+`/alternate/directory' before all installation names.  The approach of
+`DESTDIR' overrides is not required by the GNU Coding Standards, and
+does not work on platforms that have drive letters.  On the other hand,
+it does better at avoiding recompilation issues, and works well even
+when some directory options were not specified in terms of `${prefix}'
+at `configure' time.
+
+Optional Features
+=================
+
+   If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+   Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System).  The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+   For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+   Some packages offer the ability to configure how verbose the
+execution of `make' will be.  For these packages, running `./configure
+--enable-silent-rules' sets the default to minimal output, which can be
+overridden with `make V=1'; while running `./configure
+--disable-silent-rules' sets the default to verbose, which can be
+overridden with `make V=0'.
+
+Particular systems
+==================
+
+   On HP-UX, the default C compiler is not ANSI C compatible.  If GNU
+CC is not installed, it is recommended to use the following options in
+order to use an ANSI C compiler:
+
+     ./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
+
+and if that doesn't work, install pre-built binaries of GCC for HP-UX.
+
+   On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
+parse its `<wchar.h>' header file.  The option `-nodtk' can be used as
+a workaround.  If GNU CC is not installed, it is therefore recommended
+to try
+
+     ./configure CC="cc"
+
+and if that doesn't work, try
+
+     ./configure CC="cc -nodtk"
+
+   On Solaris, don't put `/usr/ucb' early in your `PATH'.  This
+directory contains several dysfunctional programs; working variants of
+these programs are available in `/usr/bin'.  So, if you need `/usr/ucb'
+in your `PATH', put it _after_ `/usr/bin'.
+
+   On Haiku, software installed for all users goes in `/boot/common',
+not `/usr/local'.  It is recommended to use the following options:
+
+     ./configure --prefix=/boot/common
+
+Specifying the System Type
+==========================
+
+   There may be some features `configure' cannot figure out
+automatically, but needs to determine by the type of machine the package
+will run on.  Usually, assuming the package is built to be run on the
+_same_ architectures, `configure' can figure that out, but if it prints
+a message saying it cannot guess the machine type, give it the
+`--build=TYPE' option.  TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+     CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+     OS
+     KERNEL-OS
+
+   See the file `config.sub' for the possible values of each field.  If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the machine type.
+
+   If you are _building_ compiler tools for cross-compiling, you should
+use the option `--target=TYPE' to select the type of system they will
+produce code for.
+
+   If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
+
+Sharing Defaults
+================
+
+   If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists.  Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Defining Variables
+==================
+
+   Variables not defined in a site shell script can be set in the
+environment passed to `configure'.  However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost.  In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'.  For example:
+
+     ./configure CC=/usr/local2/bin/gcc
+
+causes the specified `gcc' to be used as the C compiler (unless it is
+overridden in the site shell script).
+
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
+an Autoconf bug.  Until the bug is fixed you can use this workaround:
+
+     CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
+`configure' Invocation
+======================
+
+   `configure' recognizes the following options to control how it
+operates.
+
+`--help'
+`-h'
+     Print a summary of all of the options to `configure', and exit.
+
+`--help=short'
+`--help=recursive'
+     Print a summary of the options unique to this package's
+     `configure', and exit.  The `short' variant lists options used
+     only in the top level, while the `recursive' variant lists options
+     also present in any nested packages.
+
+`--version'
+`-V'
+     Print the version of Autoconf used to generate the `configure'
+     script, and exit.
+
+`--cache-file=FILE'
+     Enable the cache: use and save the results of the tests in FILE,
+     traditionally `config.cache'.  FILE defaults to `/dev/null' to
+     disable caching.
+
+`--config-cache'
+`-C'
+     Alias for `--cache-file=config.cache'.
+
+`--quiet'
+`--silent'
+`-q'
+     Do not print messages saying which checks are being made.  To
+     suppress all normal output, redirect it to `/dev/null' (any error
+     messages will still be shown).
+
+`--srcdir=DIR'
+     Look for the package's source code in directory DIR.  Usually
+     `configure' can determine that directory automatically.
+
+`--prefix=DIR'
+     Use DIR as the installation prefix.  *note Installation Names::
+     for more details, including other options available for fine-tuning
+     the installation locations.
+
+`--no-create'
+`-n'
+     Run the configure checks, but stop before creating any output
+     files.
+
+`configure' also accepts some other, not widely useful, options.  Run
+`configure --help' for more details.
+
Index: Makefile.am
===================================================================
--- Makefile.am	(revision b21cb9dbead4d40950777be4260bea1a6560f9b6)
+++ Makefile.am	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -1,18 +1,8 @@
-#ACLOCAL_AMFLAGS = -I m4
-SUBDIRS = pcp util molecuilder
-#<F2>util/molecuilder
-DIST_SUBDIRS = ${SUBDIRS} 
-#defaults/pseudopot
+ACLOCAL_AMFLAGS = -I m4
+SUBDIRS = src src/unittests doc tests 
 
-#include aminclude.am
+EXTRA_DIST = autogen.sh
 
-pcpdir = ${bindir}
-
-EXTRA_DIST = util/suffix autogen.sh configs.tar.gz pseudopots.tar.gz util/visual.cfg util/visual.net
-
-configs.tar.gz:
-	$(TAR) -zcvf $(srcdir)/configs.tar.gz `find  $(srcdir) -name 'main_pcp_linux'`
-
-
-pseudopots.tar.gz:
-	$(TAR) -zcvf $(srcdir)/pseudopots.tar.gz `find  $(srcdir) -name 'pseudo.??'`
+.PHONY: doc
+doc:
+	cd doc && make doxygen-docs
Index: README
===================================================================
--- README	(revision b21cb9dbead4d40950777be4260bea1a6560f9b6)
+++ README	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -1,2 +1,11 @@
+<<<<<<< HEAD
+# Project: Molecuilder
+#
+# heber@ins.uni-bonn.de
+
+	Molecuilder
+
+... is a tool that started as a mean to edit pcp configuration files (adding/remvoing groups of atoms, measuring bond lengths and so forth) and has grown into the many-body fragmentation test base of a new method coined BOSSANOVA (Bond Order diSSection in an ANOVA (ANalysis Of VAriance) -like fashion). It spills out configuration files for each fragment and includes joining and analyzing programs, to put together the partial energies and forces of each fragment to the total energy and forces. It allows for a complete Born-Oppenheimer molecular dynamics run.
+=======
 # Project: ParallelCarParrinello
 # Jan Hamaekers
@@ -18,8 +27,15 @@
 
 
+>>>>>>> FETCH_HEAD
 
 INSTALLATION NOTES
 ==================
 
+<<<<<<< HEAD
+The following packages are needed
+* GCC or alike
+* GSL (GNU Scientific Library, available at http://www.gnu.org/software/gsl)
+* Boost 1.4 or newer
+=======
 In general gcc or alike is needed to compile the sources, for more specific demands see the README files in the sub directory of each package part.
 
@@ -27,2 +43,3 @@
 =====
 [1] http://www.ins.uni-bonn.de/
+>>>>>>> FETCH_HEAD
Index: config/config.guess
===================================================================
--- config/config.guess	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ config/config.guess	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,1533 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+#   Free Software Foundation, Inc.
+
+timestamp='2009-06-10'
+
+# This file 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.
+#
+# This program 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 this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Originally written by Per Bothner <per@bothner.com>.
+# Please send patches to <config-patches@gnu.org>.  Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub.  If it succeeds, it prints the system name on stdout, and
+# exits with 0.  Otherwise, it exits with 1.
+#
+# The plan is that this can be called by configure scripts if you
+# don't specify an explicit build system type.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+2002, 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."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit ;;
+    --version | -v )
+       echo "$version" ; exit ;;
+    --help | --h* | -h )
+       echo "$usage"; exit ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )	# Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help" >&2
+       exit 1 ;;
+    * )
+       break ;;
+  esac
+done
+
+if test $# != 0; then
+  echo "$me: too many arguments$help" >&2
+  exit 1
+fi
+
+trap 'exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
+
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+# Portable tmp directory creation inspired by the Autoconf team.
+
+set_cc_for_build='
+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+: ${TMPDIR=/tmp} ;
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+dummy=$tmp/dummy ;
+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,)    echo "int x;" > $dummy.c ;
+	for c in cc gcc c89 c99 ; do
+	  if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+	     CC_FOR_BUILD="$c"; break ;
+	  fi ;
+	done ;
+	if test x"$CC_FOR_BUILD" = x ; then
+	  CC_FOR_BUILD=no_compiler_found ;
+	fi
+	;;
+ ,,*)   CC_FOR_BUILD=$CC ;;
+ ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
+esac ; set_cc_for_build= ;'
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 1994-08-24)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+	PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+    *:NetBSD:*:*)
+	# NetBSD (nbsd) targets should (where applicable) match one or
+	# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
+	# switched to ELF, *-*-netbsd* would select the old
+	# object file format.  This provides both forward
+	# compatibility and a consistent mechanism for selecting the
+	# object file format.
+	#
+	# Note: NetBSD doesn't particularly care about the vendor
+	# portion of the name.  We always set it to "unknown".
+	sysctl="sysctl -n hw.machine_arch"
+	UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+	    /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+	case "${UNAME_MACHINE_ARCH}" in
+	    armeb) machine=armeb-unknown ;;
+	    arm*) machine=arm-unknown ;;
+	    sh3el) machine=shl-unknown ;;
+	    sh3eb) machine=sh-unknown ;;
+	    sh5el) machine=sh5le-unknown ;;
+	    *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+	esac
+	# The Operating System including object format, if it has switched
+	# to ELF recently, or will in the future.
+	case "${UNAME_MACHINE_ARCH}" in
+	    arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+		eval $set_cc_for_build
+		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+			| grep -q __ELF__
+		then
+		    # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+		    # Return netbsd for either.  FIX?
+		    os=netbsd
+		else
+		    os=netbsdelf
+		fi
+		;;
+	    *)
+	        os=netbsd
+		;;
+	esac
+	# The OS release
+	# Debian GNU/NetBSD machines have a different userland, and
+	# thus, need a distinct triplet. However, they do not need
+	# kernel version information, so it can be replaced with a
+	# suitable tag, in the style of linux-gnu.
+	case "${UNAME_VERSION}" in
+	    Debian*)
+		release='-gnu'
+		;;
+	    *)
+		release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+		;;
+	esac
+	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+	# contains redundant information, the shorter form:
+	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+	echo "${machine}-${os}${release}"
+	exit ;;
+    *:OpenBSD:*:*)
+	UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
+	echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
+	exit ;;
+    *:ekkoBSD:*:*)
+	echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+	exit ;;
+    *:SolidBSD:*:*)
+	echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
+	exit ;;
+    macppc:MirBSD:*:*)
+	echo powerpc-unknown-mirbsd${UNAME_RELEASE}
+	exit ;;
+    *:MirBSD:*:*)
+	echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+	exit ;;
+    alpha:OSF1:*:*)
+	case $UNAME_RELEASE in
+	*4.0)
+		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+		;;
+	*5.*)
+	        UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+		;;
+	esac
+	# According to Compaq, /usr/sbin/psrinfo has been available on
+	# OSF/1 and Tru64 systems produced since 1995.  I hope that
+	# covers most systems running today.  This code pipes the CPU
+	# types through head -n 1, so we only detect the type of CPU 0.
+	ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
+	case "$ALPHA_CPU_TYPE" in
+	    "EV4 (21064)")
+		UNAME_MACHINE="alpha" ;;
+	    "EV4.5 (21064)")
+		UNAME_MACHINE="alpha" ;;
+	    "LCA4 (21066/21068)")
+		UNAME_MACHINE="alpha" ;;
+	    "EV5 (21164)")
+		UNAME_MACHINE="alphaev5" ;;
+	    "EV5.6 (21164A)")
+		UNAME_MACHINE="alphaev56" ;;
+	    "EV5.6 (21164PC)")
+		UNAME_MACHINE="alphapca56" ;;
+	    "EV5.7 (21164PC)")
+		UNAME_MACHINE="alphapca57" ;;
+	    "EV6 (21264)")
+		UNAME_MACHINE="alphaev6" ;;
+	    "EV6.7 (21264A)")
+		UNAME_MACHINE="alphaev67" ;;
+	    "EV6.8CB (21264C)")
+		UNAME_MACHINE="alphaev68" ;;
+	    "EV6.8AL (21264B)")
+		UNAME_MACHINE="alphaev68" ;;
+	    "EV6.8CX (21264D)")
+		UNAME_MACHINE="alphaev68" ;;
+	    "EV6.9A (21264/EV69A)")
+		UNAME_MACHINE="alphaev69" ;;
+	    "EV7 (21364)")
+		UNAME_MACHINE="alphaev7" ;;
+	    "EV7.9 (21364A)")
+		UNAME_MACHINE="alphaev79" ;;
+	esac
+	# A Pn.n version is a patched version.
+	# A Vn.n version is a released version.
+	# A Tn.n version is a released field test version.
+	# A Xn.n version is an unreleased experimental baselevel.
+	# 1.2 uses "1.2" for uname -r.
+	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+	exit ;;
+    Alpha\ *:Windows_NT*:*)
+	# How do we know it's Interix rather than the generic POSIX subsystem?
+	# Should we change UNAME_MACHINE based on the output of uname instead
+	# of the specific Alpha model?
+	echo alpha-pc-interix
+	exit ;;
+    21064:Windows_NT:50:3)
+	echo alpha-dec-winnt3.5
+	exit ;;
+    Amiga*:UNIX_System_V:4.0:*)
+	echo m68k-unknown-sysv4
+	exit ;;
+    *:[Aa]miga[Oo][Ss]:*:*)
+	echo ${UNAME_MACHINE}-unknown-amigaos
+	exit ;;
+    *:[Mm]orph[Oo][Ss]:*:*)
+	echo ${UNAME_MACHINE}-unknown-morphos
+	exit ;;
+    *:OS/390:*:*)
+	echo i370-ibm-openedition
+	exit ;;
+    *:z/VM:*:*)
+	echo s390-ibm-zvmoe
+	exit ;;
+    *:OS400:*:*)
+        echo powerpc-ibm-os400
+	exit ;;
+    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+	echo arm-acorn-riscix${UNAME_RELEASE}
+	exit ;;
+    arm:riscos:*:*|arm:RISCOS:*:*)
+	echo arm-unknown-riscos
+	exit ;;
+    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+	echo hppa1.1-hitachi-hiuxmpp
+	exit ;;
+    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+	# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+	if test "`(/bin/universe) 2>/dev/null`" = att ; then
+		echo pyramid-pyramid-sysv3
+	else
+		echo pyramid-pyramid-bsd
+	fi
+	exit ;;
+    NILE*:*:*:dcosx)
+	echo pyramid-pyramid-svr4
+	exit ;;
+    DRS?6000:unix:4.0:6*)
+	echo sparc-icl-nx6
+	exit ;;
+    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
+	case `/usr/bin/uname -p` in
+	    sparc) echo sparc-icl-nx7; exit ;;
+	esac ;;
+    s390x:SunOS:*:*)
+	echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit ;;
+    sun4H:SunOS:5.*:*)
+	echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit ;;
+    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+	echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit ;;
+    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
+	eval $set_cc_for_build
+	SUN_ARCH="i386"
+	# If there is a compiler, see if it is configured for 64-bit objects.
+	# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
+	# This test works for both compilers.
+	if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+	    if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
+		(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+		grep IS_64BIT_ARCH >/dev/null
+	    then
+		SUN_ARCH="x86_64"
+	    fi
+	fi
+	echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit ;;
+    sun4*:SunOS:6*:*)
+	# According to config.sub, this is the proper way to canonicalize
+	# SunOS6.  Hard to guess exactly what SunOS6 will be like, but
+	# it's likely to be more like Solaris than SunOS4.
+	echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit ;;
+    sun4*:SunOS:*:*)
+	case "`/usr/bin/arch -k`" in
+	    Series*|S4*)
+		UNAME_RELEASE=`uname -v`
+		;;
+	esac
+	# Japanese Language versions have a version number like `4.1.3-JL'.
+	echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+	exit ;;
+    sun3*:SunOS:*:*)
+	echo m68k-sun-sunos${UNAME_RELEASE}
+	exit ;;
+    sun*:*:4.2BSD:*)
+	UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+	test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+	case "`/bin/arch`" in
+	    sun3)
+		echo m68k-sun-sunos${UNAME_RELEASE}
+		;;
+	    sun4)
+		echo sparc-sun-sunos${UNAME_RELEASE}
+		;;
+	esac
+	exit ;;
+    aushp:SunOS:*:*)
+	echo sparc-auspex-sunos${UNAME_RELEASE}
+	exit ;;
+    # The situation for MiNT is a little confusing.  The machine name
+    # can be virtually everything (everything which is not
+    # "atarist" or "atariste" at least should have a processor
+    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
+    # to the lowercase version "mint" (or "freemint").  Finally
+    # the system name "TOS" denotes a system which is actually not
+    # MiNT.  But MiNT is downward compatible to TOS, so this should
+    # be no problem.
+    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+	exit ;;
+    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+	echo m68k-atari-mint${UNAME_RELEASE}
+        exit ;;
+    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+	exit ;;
+    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+        echo m68k-milan-mint${UNAME_RELEASE}
+        exit ;;
+    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+        echo m68k-hades-mint${UNAME_RELEASE}
+        exit ;;
+    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+        echo m68k-unknown-mint${UNAME_RELEASE}
+        exit ;;
+    m68k:machten:*:*)
+	echo m68k-apple-machten${UNAME_RELEASE}
+	exit ;;
+    powerpc:machten:*:*)
+	echo powerpc-apple-machten${UNAME_RELEASE}
+	exit ;;
+    RISC*:Mach:*:*)
+	echo mips-dec-mach_bsd4.3
+	exit ;;
+    RISC*:ULTRIX:*:*)
+	echo mips-dec-ultrix${UNAME_RELEASE}
+	exit ;;
+    VAX*:ULTRIX*:*:*)
+	echo vax-dec-ultrix${UNAME_RELEASE}
+	exit ;;
+    2020:CLIX:*:* | 2430:CLIX:*:*)
+	echo clipper-intergraph-clix${UNAME_RELEASE}
+	exit ;;
+    mips:*:*:UMIPS | mips:*:*:RISCos)
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
+	int main (int argc, char *argv[]) {
+#else
+	int main (argc, argv) int argc; char *argv[]; {
+#endif
+	#if defined (host_mips) && defined (MIPSEB)
+	#if defined (SYSTYPE_SYSV)
+	  printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+	#endif
+	#if defined (SYSTYPE_SVR4)
+	  printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+	#endif
+	#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+	  printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+	#endif
+	#endif
+	  exit (-1);
+	}
+EOF
+	$CC_FOR_BUILD -o $dummy $dummy.c &&
+	  dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+	  SYSTEM_NAME=`$dummy $dummyarg` &&
+	    { echo "$SYSTEM_NAME"; exit; }
+	echo mips-mips-riscos${UNAME_RELEASE}
+	exit ;;
+    Motorola:PowerMAX_OS:*:*)
+	echo powerpc-motorola-powermax
+	exit ;;
+    Motorola:*:4.3:PL8-*)
+	echo powerpc-harris-powermax
+	exit ;;
+    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+	echo powerpc-harris-powermax
+	exit ;;
+    Night_Hawk:Power_UNIX:*:*)
+	echo powerpc-harris-powerunix
+	exit ;;
+    m88k:CX/UX:7*:*)
+	echo m88k-harris-cxux7
+	exit ;;
+    m88k:*:4*:R4*)
+	echo m88k-motorola-sysv4
+	exit ;;
+    m88k:*:3*:R3*)
+	echo m88k-motorola-sysv3
+	exit ;;
+    AViiON:dgux:*:*)
+        # DG/UX returns AViiON for all architectures
+        UNAME_PROCESSOR=`/usr/bin/uname -p`
+	if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+	then
+	    if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+	       [ ${TARGET_BINARY_INTERFACE}x = x ]
+	    then
+		echo m88k-dg-dgux${UNAME_RELEASE}
+	    else
+		echo m88k-dg-dguxbcs${UNAME_RELEASE}
+	    fi
+	else
+	    echo i586-dg-dgux${UNAME_RELEASE}
+	fi
+ 	exit ;;
+    M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
+	echo m88k-dolphin-sysv3
+	exit ;;
+    M88*:*:R3*:*)
+	# Delta 88k system running SVR3
+	echo m88k-motorola-sysv3
+	exit ;;
+    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+	echo m88k-tektronix-sysv3
+	exit ;;
+    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+	echo m68k-tektronix-bsd
+	exit ;;
+    *:IRIX*:*:*)
+	echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+	exit ;;
+    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+	echo romp-ibm-aix     # uname -m gives an 8 hex-code CPU id
+	exit ;;               # Note that: echo "'`uname -s`'" gives 'AIX '
+    i*86:AIX:*:*)
+	echo i386-ibm-aix
+	exit ;;
+    ia64:AIX:*:*)
+	if [ -x /usr/bin/oslevel ] ; then
+		IBM_REV=`/usr/bin/oslevel`
+	else
+		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+	fi
+	echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+	exit ;;
+    *:AIX:2:3)
+	if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+		eval $set_cc_for_build
+		sed 's/^		//' << EOF >$dummy.c
+		#include <sys/systemcfg.h>
+
+		main()
+			{
+			if (!__power_pc())
+				exit(1);
+			puts("powerpc-ibm-aix3.2.5");
+			exit(0);
+			}
+EOF
+		if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
+		then
+			echo "$SYSTEM_NAME"
+		else
+			echo rs6000-ibm-aix3.2.5
+		fi
+	elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+		echo rs6000-ibm-aix3.2.4
+	else
+		echo rs6000-ibm-aix3.2
+	fi
+	exit ;;
+    *:AIX:*:[456])
+	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
+	if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+		IBM_ARCH=rs6000
+	else
+		IBM_ARCH=powerpc
+	fi
+	if [ -x /usr/bin/oslevel ] ; then
+		IBM_REV=`/usr/bin/oslevel`
+	else
+		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+	fi
+	echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+	exit ;;
+    *:AIX:*:*)
+	echo rs6000-ibm-aix
+	exit ;;
+    ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+	echo romp-ibm-bsd4.4
+	exit ;;
+    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
+	echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
+	exit ;;                             # report: romp-ibm BSD 4.3
+    *:BOSX:*:*)
+	echo rs6000-bull-bosx
+	exit ;;
+    DPX/2?00:B.O.S.:*:*)
+	echo m68k-bull-sysv3
+	exit ;;
+    9000/[34]??:4.3bsd:1.*:*)
+	echo m68k-hp-bsd
+	exit ;;
+    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+	echo m68k-hp-bsd4.4
+	exit ;;
+    9000/[34678]??:HP-UX:*:*)
+	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+	case "${UNAME_MACHINE}" in
+	    9000/31? )            HP_ARCH=m68000 ;;
+	    9000/[34]?? )         HP_ARCH=m68k ;;
+	    9000/[678][0-9][0-9])
+		if [ -x /usr/bin/getconf ]; then
+		    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+                    case "${sc_cpu_version}" in
+                      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+                      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+                      532)                      # CPU_PA_RISC2_0
+                        case "${sc_kernel_bits}" in
+                          32) HP_ARCH="hppa2.0n" ;;
+                          64) HP_ARCH="hppa2.0w" ;;
+			  '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
+                        esac ;;
+                    esac
+		fi
+		if [ "${HP_ARCH}" = "" ]; then
+		    eval $set_cc_for_build
+		    sed 's/^              //' << EOF >$dummy.c
+
+              #define _HPUX_SOURCE
+              #include <stdlib.h>
+              #include <unistd.h>
+
+              int main ()
+              {
+              #if defined(_SC_KERNEL_BITS)
+                  long bits = sysconf(_SC_KERNEL_BITS);
+              #endif
+                  long cpu  = sysconf (_SC_CPU_VERSION);
+
+                  switch (cpu)
+              	{
+              	case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+              	case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+              	case CPU_PA_RISC2_0:
+              #if defined(_SC_KERNEL_BITS)
+              	    switch (bits)
+              		{
+              		case 64: puts ("hppa2.0w"); break;
+              		case 32: puts ("hppa2.0n"); break;
+              		default: puts ("hppa2.0"); break;
+              		} break;
+              #else  /* !defined(_SC_KERNEL_BITS) */
+              	    puts ("hppa2.0"); break;
+              #endif
+              	default: puts ("hppa1.0"); break;
+              	}
+                  exit (0);
+              }
+EOF
+		    (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+		    test -z "$HP_ARCH" && HP_ARCH=hppa
+		fi ;;
+	esac
+	if [ ${HP_ARCH} = "hppa2.0w" ]
+	then
+	    eval $set_cc_for_build
+
+	    # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
+	    # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
+	    # generating 64-bit code.  GNU and HP use different nomenclature:
+	    #
+	    # $ CC_FOR_BUILD=cc ./config.guess
+	    # => hppa2.0w-hp-hpux11.23
+	    # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
+	    # => hppa64-hp-hpux11.23
+
+	    if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
+		grep -q __LP64__
+	    then
+		HP_ARCH="hppa2.0w"
+	    else
+		HP_ARCH="hppa64"
+	    fi
+	fi
+	echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+	exit ;;
+    ia64:HP-UX:*:*)
+	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+	echo ia64-hp-hpux${HPUX_REV}
+	exit ;;
+    3050*:HI-UX:*:*)
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+	#include <unistd.h>
+	int
+	main ()
+	{
+	  long cpu = sysconf (_SC_CPU_VERSION);
+	  /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+	     true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
+	     results, however.  */
+	  if (CPU_IS_PA_RISC (cpu))
+	    {
+	      switch (cpu)
+		{
+		  case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+		  case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+		  case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+		  default: puts ("hppa-hitachi-hiuxwe2"); break;
+		}
+	    }
+	  else if (CPU_IS_HP_MC68K (cpu))
+	    puts ("m68k-hitachi-hiuxwe2");
+	  else puts ("unknown-hitachi-hiuxwe2");
+	  exit (0);
+	}
+EOF
+	$CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
+		{ echo "$SYSTEM_NAME"; exit; }
+	echo unknown-hitachi-hiuxwe2
+	exit ;;
+    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+	echo hppa1.1-hp-bsd
+	exit ;;
+    9000/8??:4.3bsd:*:*)
+	echo hppa1.0-hp-bsd
+	exit ;;
+    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+	echo hppa1.0-hp-mpeix
+	exit ;;
+    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+	echo hppa1.1-hp-osf
+	exit ;;
+    hp8??:OSF1:*:*)
+	echo hppa1.0-hp-osf
+	exit ;;
+    i*86:OSF1:*:*)
+	if [ -x /usr/sbin/sysversion ] ; then
+	    echo ${UNAME_MACHINE}-unknown-osf1mk
+	else
+	    echo ${UNAME_MACHINE}-unknown-osf1
+	fi
+	exit ;;
+    parisc*:Lites*:*:*)
+	echo hppa1.1-hp-lites
+	exit ;;
+    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+	echo c1-convex-bsd
+        exit ;;
+    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+	if getsysinfo -f scalar_acc
+	then echo c32-convex-bsd
+	else echo c2-convex-bsd
+	fi
+        exit ;;
+    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+	echo c34-convex-bsd
+        exit ;;
+    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+	echo c38-convex-bsd
+        exit ;;
+    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+	echo c4-convex-bsd
+        exit ;;
+    CRAY*Y-MP:*:*:*)
+	echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit ;;
+    CRAY*[A-Z]90:*:*:*)
+	echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+	| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+	      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+	      -e 's/\.[^.]*$/.X/'
+	exit ;;
+    CRAY*TS:*:*:*)
+	echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit ;;
+    CRAY*T3E:*:*:*)
+	echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit ;;
+    CRAY*SV1:*:*:*)
+	echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit ;;
+    *:UNICOS/mp:*:*)
+	echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit ;;
+    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+	FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+        exit ;;
+    5000:UNIX_System_V:4.*:*)
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+        echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+	exit ;;
+    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+	echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+	exit ;;
+    sparc*:BSD/OS:*:*)
+	echo sparc-unknown-bsdi${UNAME_RELEASE}
+	exit ;;
+    *:BSD/OS:*:*)
+	echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+	exit ;;
+    *:FreeBSD:*:*)
+	case ${UNAME_MACHINE} in
+	    pc98)
+		echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+	    amd64)
+		echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+	    *)
+		echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+	esac
+	exit ;;
+    i*:CYGWIN*:*)
+	echo ${UNAME_MACHINE}-pc-cygwin
+	exit ;;
+    *:MINGW*:*)
+	echo ${UNAME_MACHINE}-pc-mingw32
+	exit ;;
+    i*:windows32*:*)
+    	# uname -m includes "-pc" on this system.
+    	echo ${UNAME_MACHINE}-mingw32
+	exit ;;
+    i*:PW*:*)
+	echo ${UNAME_MACHINE}-pc-pw32
+	exit ;;
+    *:Interix*:[3456]*)
+    	case ${UNAME_MACHINE} in
+	    x86)
+		echo i586-pc-interix${UNAME_RELEASE}
+		exit ;;
+	    EM64T | authenticamd | genuineintel)
+		echo x86_64-unknown-interix${UNAME_RELEASE}
+		exit ;;
+	    IA64)
+		echo ia64-unknown-interix${UNAME_RELEASE}
+		exit ;;
+	esac ;;
+    [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+	echo i${UNAME_MACHINE}-pc-mks
+	exit ;;
+    8664:Windows_NT:*)
+	echo x86_64-pc-mks
+	exit ;;
+    i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+	# How do we know it's Interix rather than the generic POSIX subsystem?
+	# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+	# UNAME_MACHINE based on the output of uname instead of i386?
+	echo i586-pc-interix
+	exit ;;
+    i*:UWIN*:*)
+	echo ${UNAME_MACHINE}-pc-uwin
+	exit ;;
+    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
+	echo x86_64-unknown-cygwin
+	exit ;;
+    p*:CYGWIN*:*)
+	echo powerpcle-unknown-cygwin
+	exit ;;
+    prep*:SunOS:5.*:*)
+	echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit ;;
+    *:GNU:*:*)
+	# the GNU system
+	echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+	exit ;;
+    *:GNU/*:*:*)
+	# other systems with GNU libc and userland
+	echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+	exit ;;
+    i*86:Minix:*:*)
+	echo ${UNAME_MACHINE}-pc-minix
+	exit ;;
+    arm*:Linux:*:*)
+	eval $set_cc_for_build
+	if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
+	    | grep -q __ARM_EABI__
+	then
+	    echo ${UNAME_MACHINE}-unknown-linux-gnu
+	else
+	    echo ${UNAME_MACHINE}-unknown-linux-gnueabi
+	fi
+	exit ;;
+    avr32*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    cris:Linux:*:*)
+	echo cris-axis-linux-gnu
+	exit ;;
+    crisv32:Linux:*:*)
+	echo crisv32-axis-linux-gnu
+	exit ;;
+    frv:Linux:*:*)
+    	echo frv-unknown-linux-gnu
+	exit ;;
+    ia64:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    m32r*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    m68*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    mips:Linux:*:* | mips64:Linux:*:*)
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+	#undef CPU
+	#undef ${UNAME_MACHINE}
+	#undef ${UNAME_MACHINE}el
+	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+	CPU=${UNAME_MACHINE}el
+	#else
+	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+	CPU=${UNAME_MACHINE}
+	#else
+	CPU=
+	#endif
+	#endif
+EOF
+	eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+	    /^CPU/{
+		s: ::g
+		p
+	    }'`"
+	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+	;;
+    or32:Linux:*:*)
+	echo or32-unknown-linux-gnu
+	exit ;;
+    ppc:Linux:*:*)
+	echo powerpc-unknown-linux-gnu
+	exit ;;
+    ppc64:Linux:*:*)
+	echo powerpc64-unknown-linux-gnu
+	exit ;;
+    alpha:Linux:*:*)
+	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+	  EV5)   UNAME_MACHINE=alphaev5 ;;
+	  EV56)  UNAME_MACHINE=alphaev56 ;;
+	  PCA56) UNAME_MACHINE=alphapca56 ;;
+	  PCA57) UNAME_MACHINE=alphapca56 ;;
+	  EV6)   UNAME_MACHINE=alphaev6 ;;
+	  EV67)  UNAME_MACHINE=alphaev67 ;;
+	  EV68*) UNAME_MACHINE=alphaev68 ;;
+        esac
+	objdump --private-headers /bin/sh | grep -q ld.so.1
+	if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+	echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+	exit ;;
+    padre:Linux:*:*)
+	echo sparc-unknown-linux-gnu
+	exit ;;
+    parisc:Linux:*:* | hppa:Linux:*:*)
+	# Look for CPU level
+	case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+	  PA7*) echo hppa1.1-unknown-linux-gnu ;;
+	  PA8*) echo hppa2.0-unknown-linux-gnu ;;
+	  *)    echo hppa-unknown-linux-gnu ;;
+	esac
+	exit ;;
+    parisc64:Linux:*:* | hppa64:Linux:*:*)
+	echo hppa64-unknown-linux-gnu
+	exit ;;
+    s390:Linux:*:* | s390x:Linux:*:*)
+	echo ${UNAME_MACHINE}-ibm-linux
+	exit ;;
+    sh64*:Linux:*:*)
+    	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    sh*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    sparc:Linux:*:* | sparc64:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    vax:Linux:*:*)
+	echo ${UNAME_MACHINE}-dec-linux-gnu
+	exit ;;
+    x86_64:Linux:*:*)
+	echo x86_64-unknown-linux-gnu
+	exit ;;
+    xtensa*:Linux:*:*)
+    	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    i*86:Linux:*:*)
+	# The BFD linker knows what the default object file format is, so
+	# first see if it will tell us. cd to the root directory to prevent
+	# problems with other programs or directories called `ld' in the path.
+	# Set LC_ALL=C to ensure ld outputs messages in English.
+	ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
+			 | sed -ne '/supported targets:/!d
+				    s/[ 	][ 	]*/ /g
+				    s/.*supported targets: *//
+				    s/ .*//
+				    p'`
+        case "$ld_supported_targets" in
+	  elf32-i386)
+		TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
+		;;
+	esac
+	# Determine whether the default compiler is a.out or elf
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+	#include <features.h>
+	#ifdef __ELF__
+	# ifdef __GLIBC__
+	#  if __GLIBC__ >= 2
+	LIBC=gnu
+	#  else
+	LIBC=gnulibc1
+	#  endif
+	# else
+	LIBC=gnulibc1
+	# endif
+	#else
+	#if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
+	LIBC=gnu
+	#else
+	LIBC=gnuaout
+	#endif
+	#endif
+	#ifdef __dietlibc__
+	LIBC=dietlibc
+	#endif
+EOF
+	eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+	    /^LIBC/{
+		s: ::g
+		p
+	    }'`"
+	test x"${LIBC}" != x && {
+		echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
+		exit
+	}
+	test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
+	;;
+    i*86:DYNIX/ptx:4*:*)
+	# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+	# earlier versions are messed up and put the nodename in both
+	# sysname and nodename.
+	echo i386-sequent-sysv4
+	exit ;;
+    i*86:UNIX_SV:4.2MP:2.*)
+        # Unixware is an offshoot of SVR4, but it has its own version
+        # number series starting with 2...
+        # I am not positive that other SVR4 systems won't match this,
+	# I just have to hope.  -- rms.
+        # Use sysv4.2uw... so that sysv4* matches it.
+	echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+	exit ;;
+    i*86:OS/2:*:*)
+	# If we were able to find `uname', then EMX Unix compatibility
+	# is probably installed.
+	echo ${UNAME_MACHINE}-pc-os2-emx
+	exit ;;
+    i*86:XTS-300:*:STOP)
+	echo ${UNAME_MACHINE}-unknown-stop
+	exit ;;
+    i*86:atheos:*:*)
+	echo ${UNAME_MACHINE}-unknown-atheos
+	exit ;;
+    i*86:syllable:*:*)
+	echo ${UNAME_MACHINE}-pc-syllable
+	exit ;;
+    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
+	echo i386-unknown-lynxos${UNAME_RELEASE}
+	exit ;;
+    i*86:*DOS:*:*)
+	echo ${UNAME_MACHINE}-pc-msdosdjgpp
+	exit ;;
+    i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+	UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+		echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+	else
+		echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+	fi
+	exit ;;
+    i*86:*:5:[678]*)
+    	# UnixWare 7.x, OpenUNIX and OpenServer 6.
+	case `/bin/uname -X | grep "^Machine"` in
+	    *486*)	     UNAME_MACHINE=i486 ;;
+	    *Pentium)	     UNAME_MACHINE=i586 ;;
+	    *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+	esac
+	echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+	exit ;;
+    i*86:*:3.2:*)
+	if test -f /usr/options/cb.name; then
+		UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+		echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+	elif /bin/uname -X 2>/dev/null >/dev/null ; then
+		UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
+		(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+		(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
+			&& UNAME_MACHINE=i586
+		(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
+			&& UNAME_MACHINE=i686
+		(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
+			&& UNAME_MACHINE=i686
+		echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+	else
+		echo ${UNAME_MACHINE}-pc-sysv32
+	fi
+	exit ;;
+    pc:*:*:*)
+	# Left here for compatibility:
+        # uname -m prints for DJGPP always 'pc', but it prints nothing about
+        # the processor, so we play safe by assuming i586.
+	# Note: whatever this is, it MUST be the same as what config.sub
+	# prints for the "djgpp" host, or else GDB configury will decide that
+	# this is a cross-build.
+	echo i586-pc-msdosdjgpp
+        exit ;;
+    Intel:Mach:3*:*)
+	echo i386-pc-mach3
+	exit ;;
+    paragon:*:*:*)
+	echo i860-intel-osf1
+	exit ;;
+    i860:*:4.*:*) # i860-SVR4
+	if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+	  echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+	else # Add other i860-SVR4 vendors below as they are discovered.
+	  echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
+	fi
+	exit ;;
+    mini*:CTIX:SYS*5:*)
+	# "miniframe"
+	echo m68010-convergent-sysv
+	exit ;;
+    mc68k:UNIX:SYSTEM5:3.51m)
+	echo m68k-convergent-sysv
+	exit ;;
+    M680?0:D-NIX:5.3:*)
+	echo m68k-diab-dnix
+	exit ;;
+    M68*:*:R3V[5678]*:*)
+	test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
+    3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
+	OS_REL=''
+	test -r /etc/.relid \
+	&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+	  && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+	  && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+          && { echo i486-ncr-sysv4; exit; } ;;
+    NCR*:*:4.2:* | MPRAS*:*:4.2:*)
+	OS_REL='.3'
+	test -r /etc/.relid \
+	    && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+	    && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+	    && { echo i586-ncr-sysv4.3${OS_REL}; exit; }
+	/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
+	    && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+	echo m68k-unknown-lynxos${UNAME_RELEASE}
+	exit ;;
+    mc68030:UNIX_System_V:4.*:*)
+	echo m68k-atari-sysv4
+	exit ;;
+    TSUNAMI:LynxOS:2.*:*)
+	echo sparc-unknown-lynxos${UNAME_RELEASE}
+	exit ;;
+    rs6000:LynxOS:2.*:*)
+	echo rs6000-unknown-lynxos${UNAME_RELEASE}
+	exit ;;
+    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
+	echo powerpc-unknown-lynxos${UNAME_RELEASE}
+	exit ;;
+    SM[BE]S:UNIX_SV:*:*)
+	echo mips-dde-sysv${UNAME_RELEASE}
+	exit ;;
+    RM*:ReliantUNIX-*:*:*)
+	echo mips-sni-sysv4
+	exit ;;
+    RM*:SINIX-*:*:*)
+	echo mips-sni-sysv4
+	exit ;;
+    *:SINIX-*:*:*)
+	if uname -p 2>/dev/null >/dev/null ; then
+		UNAME_MACHINE=`(uname -p) 2>/dev/null`
+		echo ${UNAME_MACHINE}-sni-sysv4
+	else
+		echo ns32k-sni-sysv
+	fi
+	exit ;;
+    PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+                      # says <Richard.M.Bartel@ccMail.Census.GOV>
+        echo i586-unisys-sysv4
+        exit ;;
+    *:UNIX_System_V:4*:FTX*)
+	# From Gerald Hewes <hewes@openmarket.com>.
+	# How about differentiating between stratus architectures? -djm
+	echo hppa1.1-stratus-sysv4
+	exit ;;
+    *:*:*:FTX*)
+	# From seanf@swdc.stratus.com.
+	echo i860-stratus-sysv4
+	exit ;;
+    i*86:VOS:*:*)
+	# From Paul.Green@stratus.com.
+	echo ${UNAME_MACHINE}-stratus-vos
+	exit ;;
+    *:VOS:*:*)
+	# From Paul.Green@stratus.com.
+	echo hppa1.1-stratus-vos
+	exit ;;
+    mc68*:A/UX:*:*)
+	echo m68k-apple-aux${UNAME_RELEASE}
+	exit ;;
+    news*:NEWS-OS:6*:*)
+	echo mips-sony-newsos6
+	exit ;;
+    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+	if [ -d /usr/nec ]; then
+	        echo mips-nec-sysv${UNAME_RELEASE}
+	else
+	        echo mips-unknown-sysv${UNAME_RELEASE}
+	fi
+        exit ;;
+    BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.
+	echo powerpc-be-beos
+	exit ;;
+    BeMac:BeOS:*:*)	# BeOS running on Mac or Mac clone, PPC only.
+	echo powerpc-apple-beos
+	exit ;;
+    BePC:BeOS:*:*)	# BeOS running on Intel PC compatible.
+	echo i586-pc-beos
+	exit ;;
+    BePC:Haiku:*:*)	# Haiku running on Intel PC compatible.
+	echo i586-pc-haiku
+	exit ;;
+    SX-4:SUPER-UX:*:*)
+	echo sx4-nec-superux${UNAME_RELEASE}
+	exit ;;
+    SX-5:SUPER-UX:*:*)
+	echo sx5-nec-superux${UNAME_RELEASE}
+	exit ;;
+    SX-6:SUPER-UX:*:*)
+	echo sx6-nec-superux${UNAME_RELEASE}
+	exit ;;
+    SX-7:SUPER-UX:*:*)
+	echo sx7-nec-superux${UNAME_RELEASE}
+	exit ;;
+    SX-8:SUPER-UX:*:*)
+	echo sx8-nec-superux${UNAME_RELEASE}
+	exit ;;
+    SX-8R:SUPER-UX:*:*)
+	echo sx8r-nec-superux${UNAME_RELEASE}
+	exit ;;
+    Power*:Rhapsody:*:*)
+	echo powerpc-apple-rhapsody${UNAME_RELEASE}
+	exit ;;
+    *:Rhapsody:*:*)
+	echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+	exit ;;
+    *:Darwin:*:*)
+	UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
+	case $UNAME_PROCESSOR in
+	    unknown) UNAME_PROCESSOR=powerpc ;;
+	esac
+	echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+	exit ;;
+    *:procnto*:*:* | *:QNX:[0123456789]*:*)
+	UNAME_PROCESSOR=`uname -p`
+	if test "$UNAME_PROCESSOR" = "x86"; then
+		UNAME_PROCESSOR=i386
+		UNAME_MACHINE=pc
+	fi
+	echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+	exit ;;
+    *:QNX:*:4*)
+	echo i386-pc-qnx
+	exit ;;
+    NSE-?:NONSTOP_KERNEL:*:*)
+	echo nse-tandem-nsk${UNAME_RELEASE}
+	exit ;;
+    NSR-?:NONSTOP_KERNEL:*:*)
+	echo nsr-tandem-nsk${UNAME_RELEASE}
+	exit ;;
+    *:NonStop-UX:*:*)
+	echo mips-compaq-nonstopux
+	exit ;;
+    BS2000:POSIX*:*:*)
+	echo bs2000-siemens-sysv
+	exit ;;
+    DS/*:UNIX_System_V:*:*)
+	echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+	exit ;;
+    *:Plan9:*:*)
+	# "uname -m" is not consistent, so use $cputype instead. 386
+	# is converted to i386 for consistency with other x86
+	# operating systems.
+	if test "$cputype" = "386"; then
+	    UNAME_MACHINE=i386
+	else
+	    UNAME_MACHINE="$cputype"
+	fi
+	echo ${UNAME_MACHINE}-unknown-plan9
+	exit ;;
+    *:TOPS-10:*:*)
+	echo pdp10-unknown-tops10
+	exit ;;
+    *:TENEX:*:*)
+	echo pdp10-unknown-tenex
+	exit ;;
+    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+	echo pdp10-dec-tops20
+	exit ;;
+    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+	echo pdp10-xkl-tops20
+	exit ;;
+    *:TOPS-20:*:*)
+	echo pdp10-unknown-tops20
+	exit ;;
+    *:ITS:*:*)
+	echo pdp10-unknown-its
+	exit ;;
+    SEI:*:*:SEIUX)
+        echo mips-sei-seiux${UNAME_RELEASE}
+	exit ;;
+    *:DragonFly:*:*)
+	echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+	exit ;;
+    *:*VMS:*:*)
+    	UNAME_MACHINE=`(uname -p) 2>/dev/null`
+	case "${UNAME_MACHINE}" in
+	    A*) echo alpha-dec-vms ; exit ;;
+	    I*) echo ia64-dec-vms ; exit ;;
+	    V*) echo vax-dec-vms ; exit ;;
+	esac ;;
+    *:XENIX:*:SysV)
+	echo i386-pc-xenix
+	exit ;;
+    i*86:skyos:*:*)
+	echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
+	exit ;;
+    i*86:rdos:*:*)
+	echo ${UNAME_MACHINE}-pc-rdos
+	exit ;;
+    i*86:AROS:*:*)
+	echo ${UNAME_MACHINE}-pc-aros
+	exit ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+eval $set_cc_for_build
+cat >$dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
+     I don't know....  */
+  printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+  printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+          "4"
+#else
+	  ""
+#endif
+         ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+  printf ("arm-acorn-riscix\n"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+  printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+  int version;
+  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+  if (version < 4)
+    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+  else
+    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+  exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+  printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+  printf ("ns32k-encore-mach\n"); exit (0);
+#else
+  printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+  printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+  printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+  printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+    struct utsname un;
+
+    uname(&un);
+
+    if (strncmp(un.version, "V2", 2) == 0) {
+	printf ("i386-sequent-ptx2\n"); exit (0);
+    }
+    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+	printf ("i386-sequent-ptx1\n"); exit (0);
+    }
+    printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+# if !defined (ultrix)
+#  include <sys/param.h>
+#  if defined (BSD)
+#   if BSD == 43
+      printf ("vax-dec-bsd4.3\n"); exit (0);
+#   else
+#    if BSD == 199006
+      printf ("vax-dec-bsd4.3reno\n"); exit (0);
+#    else
+      printf ("vax-dec-bsd\n"); exit (0);
+#    endif
+#   endif
+#  else
+    printf ("vax-dec-bsd\n"); exit (0);
+#  endif
+# else
+    printf ("vax-dec-ultrix\n"); exit (0);
+# endif
+#endif
+
+#if defined (alliant) && defined (i860)
+  printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+  exit (1);
+}
+EOF
+
+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
+	{ echo "$SYSTEM_NAME"; exit; }
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+    case `getsysinfo -f cpu_type` in
+    c1*)
+	echo c1-convex-bsd
+	exit ;;
+    c2*)
+	if getsysinfo -f scalar_acc
+	then echo c32-convex-bsd
+	else echo c2-convex-bsd
+	fi
+	exit ;;
+    c34*)
+	echo c34-convex-bsd
+	exit ;;
+    c38*)
+	echo c38-convex-bsd
+	exit ;;
+    c4*)
+	echo c4-convex-bsd
+	exit ;;
+    esac
+fi
+
+cat >&2 <<EOF
+$0: unable to guess system type
+
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
+
+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+and
+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches@gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo               = `(hostinfo) 2>/dev/null`
+/bin/universe          = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch              = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM  = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
Index: config/config.sub
===================================================================
--- config/config.sub	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ config/config.sub	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,1693 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+#   Free Software Foundation, Inc.
+
+timestamp='2009-06-11'
+
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine.  It does not imply ALL GNU software can.
+#
+# This file 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.
+#
+# This program 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 this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Please send patches to <config-patches@gnu.org>.  Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support.  The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+       $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+2002, 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."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit ;;
+    --version | -v )
+       echo "$version" ; exit ;;
+    --help | --h* | -h )
+       echo "$usage"; exit ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )	# Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help"
+       exit 1 ;;
+
+    *local*)
+       # First pass through any local machine types.
+       echo $1
+       exit ;;
+
+    * )
+       break ;;
+  esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+    exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+    exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+  nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
+  uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
+  kopensolaris*-gnu* | \
+  storm-chaos* | os2-emx* | rtmk-nova*)
+    os=-$maybe_os
+    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+    ;;
+  *)
+    basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+    if [ $basic_machine != $1 ]
+    then os=`echo $1 | sed 's/.*-/-/'`
+    else os=; fi
+    ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work.  We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+	-sun*os*)
+		# Prevent following clause from handling this invalid input.
+		;;
+	-dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+	-att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+	-unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+	-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+	-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+	-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+	-apple | -axis | -knuth | -cray)
+		os=
+		basic_machine=$1
+		;;
+        -bluegene*)
+	        os=-cnk
+		;;
+	-sim | -cisco | -oki | -wec | -winbond)
+		os=
+		basic_machine=$1
+		;;
+	-scout)
+		;;
+	-wrs)
+		os=-vxworks
+		basic_machine=$1
+		;;
+	-chorusos*)
+		os=-chorusos
+		basic_machine=$1
+		;;
+ 	-chorusrdb)
+ 		os=-chorusrdb
+		basic_machine=$1
+ 		;;
+	-hiux*)
+		os=-hiuxwe2
+		;;
+	-sco6)
+		os=-sco5v6
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco5)
+		os=-sco3.2v5
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco4)
+		os=-sco3.2v4
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco3.2.[4-9]*)
+		os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco3.2v[4-9]*)
+		# Don't forget version if it is 3.2v4 or newer.
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco5v6*)
+		# Don't forget version if it is 3.2v4 or newer.
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco*)
+		os=-sco3.2v2
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-udk*)
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-isc)
+		os=-isc2.2
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-clix*)
+		basic_machine=clipper-intergraph
+		;;
+	-isc*)
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-lynx*)
+		os=-lynxos
+		;;
+	-ptx*)
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+		;;
+	-windowsnt*)
+		os=`echo $os | sed -e 's/windowsnt/winnt/'`
+		;;
+	-psos*)
+		os=-psos
+		;;
+	-mint | -mint[0-9]*)
+		basic_machine=m68k-atari
+		os=-mint
+		;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+	# Recognize the basic CPU types without company name.
+	# Some are omitted here because they have special meanings below.
+	1750a | 580 \
+	| a29k \
+	| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+	| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+	| am33_2.0 \
+	| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
+	| bfin \
+	| c4x | clipper \
+	| d10v | d30v | dlx | dsp16xx \
+	| fido | fr30 | frv \
+	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+	| i370 | i860 | i960 | ia64 \
+	| ip2k | iq2000 \
+	| lm32 \
+	| m32c | m32r | m32rle | m68000 | m68k | m88k \
+	| maxq | mb | microblaze | mcore | mep | metag \
+	| mips | mipsbe | mipseb | mipsel | mipsle \
+	| mips16 \
+	| mips64 | mips64el \
+	| mips64octeon | mips64octeonel \
+	| mips64orion | mips64orionel \
+	| mips64r5900 | mips64r5900el \
+	| mips64vr | mips64vrel \
+	| mips64vr4100 | mips64vr4100el \
+	| mips64vr4300 | mips64vr4300el \
+	| mips64vr5000 | mips64vr5000el \
+	| mips64vr5900 | mips64vr5900el \
+	| mipsisa32 | mipsisa32el \
+	| mipsisa32r2 | mipsisa32r2el \
+	| mipsisa64 | mipsisa64el \
+	| mipsisa64r2 | mipsisa64r2el \
+	| mipsisa64sb1 | mipsisa64sb1el \
+	| mipsisa64sr71k | mipsisa64sr71kel \
+	| mipstx39 | mipstx39el \
+	| mn10200 | mn10300 \
+	| moxie \
+	| mt \
+	| msp430 \
+	| nios | nios2 \
+	| ns16k | ns32k \
+	| or32 \
+	| pdp10 | pdp11 | pj | pjl \
+	| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+	| pyramid \
+	| score \
+	| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+	| sh64 | sh64le \
+	| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
+	| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
+	| spu | strongarm \
+	| tahoe | thumb | tic4x | tic80 | tron \
+	| v850 | v850e \
+	| we32k \
+	| x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
+	| z8k | z80)
+		basic_machine=$basic_machine-unknown
+		;;
+	m6811 | m68hc11 | m6812 | m68hc12)
+		# Motorola 68HC11/12.
+		basic_machine=$basic_machine-unknown
+		os=-none
+		;;
+	m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+		;;
+	ms1)
+		basic_machine=mt-unknown
+		;;
+
+	# We use `pc' rather than `unknown'
+	# because (1) that's what they normally are, and
+	# (2) the word "unknown" tends to confuse beginning users.
+	i*86 | x86_64)
+	  basic_machine=$basic_machine-pc
+	  ;;
+	# Object if more than one company name word.
+	*-*-*)
+		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+		exit 1
+		;;
+	# Recognize the basic CPU types with company name.
+	580-* \
+	| a29k-* \
+	| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+	| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+	| arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
+	| avr-* | avr32-* \
+	| bfin-* | bs2000-* \
+	| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+	| clipper-* | craynv-* | cydra-* \
+	| d10v-* | d30v-* | dlx-* \
+	| elxsi-* \
+	| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
+	| h8300-* | h8500-* \
+	| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+	| i*86-* | i860-* | i960-* | ia64-* \
+	| ip2k-* | iq2000-* \
+	| lm32-* \
+	| m32c-* | m32r-* | m32rle-* \
+	| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+	| m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
+	| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+	| mips16-* \
+	| mips64-* | mips64el-* \
+	| mips64octeon-* | mips64octeonel-* \
+	| mips64orion-* | mips64orionel-* \
+	| mips64r5900-* | mips64r5900el-* \
+	| mips64vr-* | mips64vrel-* \
+	| mips64vr4100-* | mips64vr4100el-* \
+	| mips64vr4300-* | mips64vr4300el-* \
+	| mips64vr5000-* | mips64vr5000el-* \
+	| mips64vr5900-* | mips64vr5900el-* \
+	| mipsisa32-* | mipsisa32el-* \
+	| mipsisa32r2-* | mipsisa32r2el-* \
+	| mipsisa64-* | mipsisa64el-* \
+	| mipsisa64r2-* | mipsisa64r2el-* \
+	| mipsisa64sb1-* | mipsisa64sb1el-* \
+	| mipsisa64sr71k-* | mipsisa64sr71kel-* \
+	| mipstx39-* | mipstx39el-* \
+	| mmix-* \
+	| mt-* \
+	| msp430-* \
+	| nios-* | nios2-* \
+	| none-* | np1-* | ns16k-* | ns32k-* \
+	| orion-* \
+	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+	| pyramid-* \
+	| romp-* | rs6000-* \
+	| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
+	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+	| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
+	| sparclite-* \
+	| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
+	| tahoe-* | thumb-* \
+	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \
+	| tron-* \
+	| v850-* | v850e-* | vax-* \
+	| we32k-* \
+	| x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
+	| xstormy16-* | xtensa*-* \
+	| ymp-* \
+	| z8k-* | z80-*)
+		;;
+	# Recognize the basic CPU types without company name, with glob match.
+	xtensa*)
+		basic_machine=$basic_machine-unknown
+		;;
+	# Recognize the various machine names and aliases which stand
+	# for a CPU type and a company and sometimes even an OS.
+	386bsd)
+		basic_machine=i386-unknown
+		os=-bsd
+		;;
+	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+		basic_machine=m68000-att
+		;;
+	3b*)
+		basic_machine=we32k-att
+		;;
+	a29khif)
+		basic_machine=a29k-amd
+		os=-udi
+		;;
+    	abacus)
+		basic_machine=abacus-unknown
+		;;
+	adobe68k)
+		basic_machine=m68010-adobe
+		os=-scout
+		;;
+	alliant | fx80)
+		basic_machine=fx80-alliant
+		;;
+	altos | altos3068)
+		basic_machine=m68k-altos
+		;;
+	am29k)
+		basic_machine=a29k-none
+		os=-bsd
+		;;
+	amd64)
+		basic_machine=x86_64-pc
+		;;
+	amd64-*)
+		basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	amdahl)
+		basic_machine=580-amdahl
+		os=-sysv
+		;;
+	amiga | amiga-*)
+		basic_machine=m68k-unknown
+		;;
+	amigaos | amigados)
+		basic_machine=m68k-unknown
+		os=-amigaos
+		;;
+	amigaunix | amix)
+		basic_machine=m68k-unknown
+		os=-sysv4
+		;;
+	apollo68)
+		basic_machine=m68k-apollo
+		os=-sysv
+		;;
+	apollo68bsd)
+		basic_machine=m68k-apollo
+		os=-bsd
+		;;
+	aros)
+		basic_machine=i386-pc
+		os=-aros
+		;;
+	aux)
+		basic_machine=m68k-apple
+		os=-aux
+		;;
+	balance)
+		basic_machine=ns32k-sequent
+		os=-dynix
+		;;
+	blackfin)
+		basic_machine=bfin-unknown
+		os=-linux
+		;;
+	blackfin-*)
+		basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
+		os=-linux
+		;;
+	bluegene*)
+		basic_machine=powerpc-ibm
+		os=-cnk
+		;;
+	c90)
+		basic_machine=c90-cray
+		os=-unicos
+		;;
+        cegcc)
+		basic_machine=arm-unknown
+		os=-cegcc
+		;;
+	convex-c1)
+		basic_machine=c1-convex
+		os=-bsd
+		;;
+	convex-c2)
+		basic_machine=c2-convex
+		os=-bsd
+		;;
+	convex-c32)
+		basic_machine=c32-convex
+		os=-bsd
+		;;
+	convex-c34)
+		basic_machine=c34-convex
+		os=-bsd
+		;;
+	convex-c38)
+		basic_machine=c38-convex
+		os=-bsd
+		;;
+	cray | j90)
+		basic_machine=j90-cray
+		os=-unicos
+		;;
+	craynv)
+		basic_machine=craynv-cray
+		os=-unicosmp
+		;;
+	cr16)
+		basic_machine=cr16-unknown
+		os=-elf
+		;;
+	crds | unos)
+		basic_machine=m68k-crds
+		;;
+	crisv32 | crisv32-* | etraxfs*)
+		basic_machine=crisv32-axis
+		;;
+	cris | cris-* | etrax*)
+		basic_machine=cris-axis
+		;;
+	crx)
+		basic_machine=crx-unknown
+		os=-elf
+		;;
+	da30 | da30-*)
+		basic_machine=m68k-da30
+		;;
+	decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+		basic_machine=mips-dec
+		;;
+	decsystem10* | dec10*)
+		basic_machine=pdp10-dec
+		os=-tops10
+		;;
+	decsystem20* | dec20*)
+		basic_machine=pdp10-dec
+		os=-tops20
+		;;
+	delta | 3300 | motorola-3300 | motorola-delta \
+	      | 3300-motorola | delta-motorola)
+		basic_machine=m68k-motorola
+		;;
+	delta88)
+		basic_machine=m88k-motorola
+		os=-sysv3
+		;;
+	dicos)
+		basic_machine=i686-pc
+		os=-dicos
+		;;
+	djgpp)
+		basic_machine=i586-pc
+		os=-msdosdjgpp
+		;;
+	dpx20 | dpx20-*)
+		basic_machine=rs6000-bull
+		os=-bosx
+		;;
+	dpx2* | dpx2*-bull)
+		basic_machine=m68k-bull
+		os=-sysv3
+		;;
+	ebmon29k)
+		basic_machine=a29k-amd
+		os=-ebmon
+		;;
+	elxsi)
+		basic_machine=elxsi-elxsi
+		os=-bsd
+		;;
+	encore | umax | mmax)
+		basic_machine=ns32k-encore
+		;;
+	es1800 | OSE68k | ose68k | ose | OSE)
+		basic_machine=m68k-ericsson
+		os=-ose
+		;;
+	fx2800)
+		basic_machine=i860-alliant
+		;;
+	genix)
+		basic_machine=ns32k-ns
+		;;
+	gmicro)
+		basic_machine=tron-gmicro
+		os=-sysv
+		;;
+	go32)
+		basic_machine=i386-pc
+		os=-go32
+		;;
+	h3050r* | hiux*)
+		basic_machine=hppa1.1-hitachi
+		os=-hiuxwe2
+		;;
+	h8300hms)
+		basic_machine=h8300-hitachi
+		os=-hms
+		;;
+	h8300xray)
+		basic_machine=h8300-hitachi
+		os=-xray
+		;;
+	h8500hms)
+		basic_machine=h8500-hitachi
+		os=-hms
+		;;
+	harris)
+		basic_machine=m88k-harris
+		os=-sysv3
+		;;
+	hp300-*)
+		basic_machine=m68k-hp
+		;;
+	hp300bsd)
+		basic_machine=m68k-hp
+		os=-bsd
+		;;
+	hp300hpux)
+		basic_machine=m68k-hp
+		os=-hpux
+		;;
+	hp3k9[0-9][0-9] | hp9[0-9][0-9])
+		basic_machine=hppa1.0-hp
+		;;
+	hp9k2[0-9][0-9] | hp9k31[0-9])
+		basic_machine=m68000-hp
+		;;
+	hp9k3[2-9][0-9])
+		basic_machine=m68k-hp
+		;;
+	hp9k6[0-9][0-9] | hp6[0-9][0-9])
+		basic_machine=hppa1.0-hp
+		;;
+	hp9k7[0-79][0-9] | hp7[0-79][0-9])
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k78[0-9] | hp78[0-9])
+		# FIXME: really hppa2.0-hp
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+		# FIXME: really hppa2.0-hp
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k8[0-9][13679] | hp8[0-9][13679])
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k8[0-9][0-9] | hp8[0-9][0-9])
+		basic_machine=hppa1.0-hp
+		;;
+	hppa-next)
+		os=-nextstep3
+		;;
+	hppaosf)
+		basic_machine=hppa1.1-hp
+		os=-osf
+		;;
+	hppro)
+		basic_machine=hppa1.1-hp
+		os=-proelf
+		;;
+	i370-ibm* | ibm*)
+		basic_machine=i370-ibm
+		;;
+# I'm not sure what "Sysv32" means.  Should this be sysv3.2?
+	i*86v32)
+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		os=-sysv32
+		;;
+	i*86v4*)
+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		os=-sysv4
+		;;
+	i*86v)
+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		os=-sysv
+		;;
+	i*86sol2)
+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		os=-solaris2
+		;;
+	i386mach)
+		basic_machine=i386-mach
+		os=-mach
+		;;
+	i386-vsta | vsta)
+		basic_machine=i386-unknown
+		os=-vsta
+		;;
+	iris | iris4d)
+		basic_machine=mips-sgi
+		case $os in
+		    -irix*)
+			;;
+		    *)
+			os=-irix4
+			;;
+		esac
+		;;
+	isi68 | isi)
+		basic_machine=m68k-isi
+		os=-sysv
+		;;
+	m68knommu)
+		basic_machine=m68k-unknown
+		os=-linux
+		;;
+	m68knommu-*)
+		basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
+		os=-linux
+		;;
+	m88k-omron*)
+		basic_machine=m88k-omron
+		;;
+	magnum | m3230)
+		basic_machine=mips-mips
+		os=-sysv
+		;;
+	merlin)
+		basic_machine=ns32k-utek
+		os=-sysv
+		;;
+	mingw32)
+		basic_machine=i386-pc
+		os=-mingw32
+		;;
+	mingw32ce)
+		basic_machine=arm-unknown
+		os=-mingw32ce
+		;;
+	miniframe)
+		basic_machine=m68000-convergent
+		;;
+	*mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+		basic_machine=m68k-atari
+		os=-mint
+		;;
+	mips3*-*)
+		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+		;;
+	mips3*)
+		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+		;;
+	monitor)
+		basic_machine=m68k-rom68k
+		os=-coff
+		;;
+	morphos)
+		basic_machine=powerpc-unknown
+		os=-morphos
+		;;
+	msdos)
+		basic_machine=i386-pc
+		os=-msdos
+		;;
+	ms1-*)
+		basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
+		;;
+	mvs)
+		basic_machine=i370-ibm
+		os=-mvs
+		;;
+	ncr3000)
+		basic_machine=i486-ncr
+		os=-sysv4
+		;;
+	netbsd386)
+		basic_machine=i386-unknown
+		os=-netbsd
+		;;
+	netwinder)
+		basic_machine=armv4l-rebel
+		os=-linux
+		;;
+	news | news700 | news800 | news900)
+		basic_machine=m68k-sony
+		os=-newsos
+		;;
+	news1000)
+		basic_machine=m68030-sony
+		os=-newsos
+		;;
+	news-3600 | risc-news)
+		basic_machine=mips-sony
+		os=-newsos
+		;;
+	necv70)
+		basic_machine=v70-nec
+		os=-sysv
+		;;
+	next | m*-next )
+		basic_machine=m68k-next
+		case $os in
+		    -nextstep* )
+			;;
+		    -ns2*)
+		      os=-nextstep2
+			;;
+		    *)
+		      os=-nextstep3
+			;;
+		esac
+		;;
+	nh3000)
+		basic_machine=m68k-harris
+		os=-cxux
+		;;
+	nh[45]000)
+		basic_machine=m88k-harris
+		os=-cxux
+		;;
+	nindy960)
+		basic_machine=i960-intel
+		os=-nindy
+		;;
+	mon960)
+		basic_machine=i960-intel
+		os=-mon960
+		;;
+	nonstopux)
+		basic_machine=mips-compaq
+		os=-nonstopux
+		;;
+	np1)
+		basic_machine=np1-gould
+		;;
+	nsr-tandem)
+		basic_machine=nsr-tandem
+		;;
+	op50n-* | op60c-*)
+		basic_machine=hppa1.1-oki
+		os=-proelf
+		;;
+	openrisc | openrisc-*)
+		basic_machine=or32-unknown
+		;;
+	os400)
+		basic_machine=powerpc-ibm
+		os=-os400
+		;;
+	OSE68000 | ose68000)
+		basic_machine=m68000-ericsson
+		os=-ose
+		;;
+	os68k)
+		basic_machine=m68k-none
+		os=-os68k
+		;;
+	pa-hitachi)
+		basic_machine=hppa1.1-hitachi
+		os=-hiuxwe2
+		;;
+	paragon)
+		basic_machine=i860-intel
+		os=-osf
+		;;
+	parisc)
+		basic_machine=hppa-unknown
+		os=-linux
+		;;
+	parisc-*)
+		basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
+		os=-linux
+		;;
+	pbd)
+		basic_machine=sparc-tti
+		;;
+	pbb)
+		basic_machine=m68k-tti
+		;;
+	pc532 | pc532-*)
+		basic_machine=ns32k-pc532
+		;;
+	pc98)
+		basic_machine=i386-pc
+		;;
+	pc98-*)
+		basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pentium | p5 | k5 | k6 | nexgen | viac3)
+		basic_machine=i586-pc
+		;;
+	pentiumpro | p6 | 6x86 | athlon | athlon_*)
+		basic_machine=i686-pc
+		;;
+	pentiumii | pentium2 | pentiumiii | pentium3)
+		basic_machine=i686-pc
+		;;
+	pentium4)
+		basic_machine=i786-pc
+		;;
+	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+		basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pentiumpro-* | p6-* | 6x86-* | athlon-*)
+		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
+		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pentium4-*)
+		basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pn)
+		basic_machine=pn-gould
+		;;
+	power)	basic_machine=power-ibm
+		;;
+	ppc)	basic_machine=powerpc-unknown
+		;;
+	ppc-*)	basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	ppcle | powerpclittle | ppc-le | powerpc-little)
+		basic_machine=powerpcle-unknown
+		;;
+	ppcle-* | powerpclittle-*)
+		basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	ppc64)	basic_machine=powerpc64-unknown
+		;;
+	ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+		basic_machine=powerpc64le-unknown
+		;;
+	ppc64le-* | powerpc64little-*)
+		basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	ps2)
+		basic_machine=i386-ibm
+		;;
+	pw32)
+		basic_machine=i586-unknown
+		os=-pw32
+		;;
+	rdos)
+		basic_machine=i386-pc
+		os=-rdos
+		;;
+	rom68k)
+		basic_machine=m68k-rom68k
+		os=-coff
+		;;
+	rm[46]00)
+		basic_machine=mips-siemens
+		;;
+	rtpc | rtpc-*)
+		basic_machine=romp-ibm
+		;;
+	s390 | s390-*)
+		basic_machine=s390-ibm
+		;;
+	s390x | s390x-*)
+		basic_machine=s390x-ibm
+		;;
+	sa29200)
+		basic_machine=a29k-amd
+		os=-udi
+		;;
+	sb1)
+		basic_machine=mipsisa64sb1-unknown
+		;;
+	sb1el)
+		basic_machine=mipsisa64sb1el-unknown
+		;;
+	sde)
+		basic_machine=mipsisa32-sde
+		os=-elf
+		;;
+	sei)
+		basic_machine=mips-sei
+		os=-seiux
+		;;
+	sequent)
+		basic_machine=i386-sequent
+		;;
+	sh)
+		basic_machine=sh-hitachi
+		os=-hms
+		;;
+	sh5el)
+		basic_machine=sh5le-unknown
+		;;
+	sh64)
+		basic_machine=sh64-unknown
+		;;
+	sparclite-wrs | simso-wrs)
+		basic_machine=sparclite-wrs
+		os=-vxworks
+		;;
+	sps7)
+		basic_machine=m68k-bull
+		os=-sysv2
+		;;
+	spur)
+		basic_machine=spur-unknown
+		;;
+	st2000)
+		basic_machine=m68k-tandem
+		;;
+	stratus)
+		basic_machine=i860-stratus
+		os=-sysv4
+		;;
+	sun2)
+		basic_machine=m68000-sun
+		;;
+	sun2os3)
+		basic_machine=m68000-sun
+		os=-sunos3
+		;;
+	sun2os4)
+		basic_machine=m68000-sun
+		os=-sunos4
+		;;
+	sun3os3)
+		basic_machine=m68k-sun
+		os=-sunos3
+		;;
+	sun3os4)
+		basic_machine=m68k-sun
+		os=-sunos4
+		;;
+	sun4os3)
+		basic_machine=sparc-sun
+		os=-sunos3
+		;;
+	sun4os4)
+		basic_machine=sparc-sun
+		os=-sunos4
+		;;
+	sun4sol2)
+		basic_machine=sparc-sun
+		os=-solaris2
+		;;
+	sun3 | sun3-*)
+		basic_machine=m68k-sun
+		;;
+	sun4)
+		basic_machine=sparc-sun
+		;;
+	sun386 | sun386i | roadrunner)
+		basic_machine=i386-sun
+		;;
+	sv1)
+		basic_machine=sv1-cray
+		os=-unicos
+		;;
+	symmetry)
+		basic_machine=i386-sequent
+		os=-dynix
+		;;
+	t3e)
+		basic_machine=alphaev5-cray
+		os=-unicos
+		;;
+	t90)
+		basic_machine=t90-cray
+		os=-unicos
+		;;
+	tic54x | c54x*)
+		basic_machine=tic54x-unknown
+		os=-coff
+		;;
+	tic55x | c55x*)
+		basic_machine=tic55x-unknown
+		os=-coff
+		;;
+	tic6x | c6x*)
+		basic_machine=tic6x-unknown
+		os=-coff
+		;;
+	tile*)
+		basic_machine=tile-unknown
+		os=-linux-gnu
+		;;
+	tx39)
+		basic_machine=mipstx39-unknown
+		;;
+	tx39el)
+		basic_machine=mipstx39el-unknown
+		;;
+	toad1)
+		basic_machine=pdp10-xkl
+		os=-tops20
+		;;
+	tower | tower-32)
+		basic_machine=m68k-ncr
+		;;
+	tpf)
+		basic_machine=s390x-ibm
+		os=-tpf
+		;;
+	udi29k)
+		basic_machine=a29k-amd
+		os=-udi
+		;;
+	ultra3)
+		basic_machine=a29k-nyu
+		os=-sym1
+		;;
+	v810 | necv810)
+		basic_machine=v810-nec
+		os=-none
+		;;
+	vaxv)
+		basic_machine=vax-dec
+		os=-sysv
+		;;
+	vms)
+		basic_machine=vax-dec
+		os=-vms
+		;;
+	vpp*|vx|vx-*)
+		basic_machine=f301-fujitsu
+		;;
+	vxworks960)
+		basic_machine=i960-wrs
+		os=-vxworks
+		;;
+	vxworks68)
+		basic_machine=m68k-wrs
+		os=-vxworks
+		;;
+	vxworks29k)
+		basic_machine=a29k-wrs
+		os=-vxworks
+		;;
+	w65*)
+		basic_machine=w65-wdc
+		os=-none
+		;;
+	w89k-*)
+		basic_machine=hppa1.1-winbond
+		os=-proelf
+		;;
+	xbox)
+		basic_machine=i686-pc
+		os=-mingw32
+		;;
+	xps | xps100)
+		basic_machine=xps100-honeywell
+		;;
+	ymp)
+		basic_machine=ymp-cray
+		os=-unicos
+		;;
+	z8k-*-coff)
+		basic_machine=z8k-unknown
+		os=-sim
+		;;
+	z80-*-coff)
+		basic_machine=z80-unknown
+		os=-sim
+		;;
+	none)
+		basic_machine=none-none
+		os=-none
+		;;
+
+# Here we handle the default manufacturer of certain CPU types.  It is in
+# some cases the only manufacturer, in others, it is the most popular.
+	w89k)
+		basic_machine=hppa1.1-winbond
+		;;
+	op50n)
+		basic_machine=hppa1.1-oki
+		;;
+	op60c)
+		basic_machine=hppa1.1-oki
+		;;
+	romp)
+		basic_machine=romp-ibm
+		;;
+	mmix)
+		basic_machine=mmix-knuth
+		;;
+	rs6000)
+		basic_machine=rs6000-ibm
+		;;
+	vax)
+		basic_machine=vax-dec
+		;;
+	pdp10)
+		# there are many clones, so DEC is not a safe bet
+		basic_machine=pdp10-unknown
+		;;
+	pdp11)
+		basic_machine=pdp11-dec
+		;;
+	we32k)
+		basic_machine=we32k-att
+		;;
+	sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
+		basic_machine=sh-unknown
+		;;
+	sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
+		basic_machine=sparc-sun
+		;;
+	cydra)
+		basic_machine=cydra-cydrome
+		;;
+	orion)
+		basic_machine=orion-highlevel
+		;;
+	orion105)
+		basic_machine=clipper-highlevel
+		;;
+	mac | mpw | mac-mpw)
+		basic_machine=m68k-apple
+		;;
+	pmac | pmac-mpw)
+		basic_machine=powerpc-apple
+		;;
+	*-unknown)
+		# Make sure to match an already-canonicalized machine name.
+		;;
+	*)
+		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+		exit 1
+		;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+	*-digital*)
+		basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+		;;
+	*-commodore*)
+		basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+		;;
+	*)
+		;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+        # First match some system type aliases
+        # that might get confused with valid system types.
+	# -solaris* is a basic system type, with this one exception.
+	-solaris1 | -solaris1.*)
+		os=`echo $os | sed -e 's|solaris1|sunos4|'`
+		;;
+	-solaris)
+		os=-solaris2
+		;;
+	-svr4*)
+		os=-sysv4
+		;;
+	-unixware*)
+		os=-sysv4.2uw
+		;;
+	-gnu/linux*)
+		os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+		;;
+	# First accept the basic system types.
+	# The portable systems comes first.
+	# Each alternative MUST END IN A *, to match a version number.
+	# -sysv* is not here because it comes later, after sysvr4.
+	-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+	      | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
+	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+	      | -kopensolaris* \
+	      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+	      | -aos* | -aros* \
+	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+	      | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
+	      | -openbsd* | -solidbsd* \
+	      | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
+	      | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+	      | -chorusos* | -chorusrdb* | -cegcc* \
+	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+	      | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
+	      | -uxpv* | -beos* | -mpeix* | -udk* \
+	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+	      | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+	      | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+	      | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+	      | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
+	      | -skyos* | -haiku* | -rdos* | -toppers* | -drops*)
+	# Remember, each alternative MUST END IN *, to match a version number.
+		;;
+	-qnx*)
+		case $basic_machine in
+		    x86-* | i*86-*)
+			;;
+		    *)
+			os=-nto$os
+			;;
+		esac
+		;;
+	-nto-qnx*)
+		;;
+	-nto*)
+		os=`echo $os | sed -e 's|nto|nto-qnx|'`
+		;;
+	-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+	      | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
+	      | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+		;;
+	-mac*)
+		os=`echo $os | sed -e 's|mac|macos|'`
+		;;
+	-linux-dietlibc)
+		os=-linux-dietlibc
+		;;
+	-linux*)
+		os=`echo $os | sed -e 's|linux|linux-gnu|'`
+		;;
+	-sunos5*)
+		os=`echo $os | sed -e 's|sunos5|solaris2|'`
+		;;
+	-sunos6*)
+		os=`echo $os | sed -e 's|sunos6|solaris3|'`
+		;;
+	-opened*)
+		os=-openedition
+		;;
+        -os400*)
+		os=-os400
+		;;
+	-wince*)
+		os=-wince
+		;;
+	-osfrose*)
+		os=-osfrose
+		;;
+	-osf*)
+		os=-osf
+		;;
+	-utek*)
+		os=-bsd
+		;;
+	-dynix*)
+		os=-bsd
+		;;
+	-acis*)
+		os=-aos
+		;;
+	-atheos*)
+		os=-atheos
+		;;
+	-syllable*)
+		os=-syllable
+		;;
+	-386bsd)
+		os=-bsd
+		;;
+	-ctix* | -uts*)
+		os=-sysv
+		;;
+	-nova*)
+		os=-rtmk-nova
+		;;
+	-ns2 )
+		os=-nextstep2
+		;;
+	-nsk*)
+		os=-nsk
+		;;
+	# Preserve the version number of sinix5.
+	-sinix5.*)
+		os=`echo $os | sed -e 's|sinix|sysv|'`
+		;;
+	-sinix*)
+		os=-sysv4
+		;;
+        -tpf*)
+		os=-tpf
+		;;
+	-triton*)
+		os=-sysv3
+		;;
+	-oss*)
+		os=-sysv3
+		;;
+	-svr4)
+		os=-sysv4
+		;;
+	-svr3)
+		os=-sysv3
+		;;
+	-sysvr4)
+		os=-sysv4
+		;;
+	# This must come after -sysvr4.
+	-sysv*)
+		;;
+	-ose*)
+		os=-ose
+		;;
+	-es1800*)
+		os=-ose
+		;;
+	-xenix)
+		os=-xenix
+		;;
+	-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+		os=-mint
+		;;
+	-aros*)
+		os=-aros
+		;;
+	-kaos*)
+		os=-kaos
+		;;
+	-zvmoe)
+		os=-zvmoe
+		;;
+	-dicos*)
+		os=-dicos
+		;;
+	-none)
+		;;
+	*)
+		# Get rid of the `-' at the beginning of $os.
+		os=`echo $os | sed 's/[^-]*-//'`
+		echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+		exit 1
+		;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system.  Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+        score-*)
+		os=-elf
+		;;
+        spu-*)
+		os=-elf
+		;;
+	*-acorn)
+		os=-riscix1.2
+		;;
+	arm*-rebel)
+		os=-linux
+		;;
+	arm*-semi)
+		os=-aout
+		;;
+        c4x-* | tic4x-*)
+        	os=-coff
+		;;
+	# This must come before the *-dec entry.
+	pdp10-*)
+		os=-tops20
+		;;
+	pdp11-*)
+		os=-none
+		;;
+	*-dec | vax-*)
+		os=-ultrix4.2
+		;;
+	m68*-apollo)
+		os=-domain
+		;;
+	i386-sun)
+		os=-sunos4.0.2
+		;;
+	m68000-sun)
+		os=-sunos3
+		# This also exists in the configure program, but was not the
+		# default.
+		# os=-sunos4
+		;;
+	m68*-cisco)
+		os=-aout
+		;;
+        mep-*)
+		os=-elf
+		;;
+	mips*-cisco)
+		os=-elf
+		;;
+	mips*-*)
+		os=-elf
+		;;
+	or32-*)
+		os=-coff
+		;;
+	*-tti)	# must be before sparc entry or we get the wrong os.
+		os=-sysv3
+		;;
+	sparc-* | *-sun)
+		os=-sunos4.1.1
+		;;
+	*-be)
+		os=-beos
+		;;
+	*-haiku)
+		os=-haiku
+		;;
+	*-ibm)
+		os=-aix
+		;;
+    	*-knuth)
+		os=-mmixware
+		;;
+	*-wec)
+		os=-proelf
+		;;
+	*-winbond)
+		os=-proelf
+		;;
+	*-oki)
+		os=-proelf
+		;;
+	*-hp)
+		os=-hpux
+		;;
+	*-hitachi)
+		os=-hiux
+		;;
+	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+		os=-sysv
+		;;
+	*-cbm)
+		os=-amigaos
+		;;
+	*-dg)
+		os=-dgux
+		;;
+	*-dolphin)
+		os=-sysv3
+		;;
+	m68k-ccur)
+		os=-rtu
+		;;
+	m88k-omron*)
+		os=-luna
+		;;
+	*-next )
+		os=-nextstep
+		;;
+	*-sequent)
+		os=-ptx
+		;;
+	*-crds)
+		os=-unos
+		;;
+	*-ns)
+		os=-genix
+		;;
+	i370-*)
+		os=-mvs
+		;;
+	*-next)
+		os=-nextstep3
+		;;
+	*-gould)
+		os=-sysv
+		;;
+	*-highlevel)
+		os=-bsd
+		;;
+	*-encore)
+		os=-bsd
+		;;
+	*-sgi)
+		os=-irix
+		;;
+	*-siemens)
+		os=-sysv4
+		;;
+	*-masscomp)
+		os=-rtu
+		;;
+	f30[01]-fujitsu | f700-fujitsu)
+		os=-uxpv
+		;;
+	*-rom68k)
+		os=-coff
+		;;
+	*-*bug)
+		os=-coff
+		;;
+	*-apple)
+		os=-macos
+		;;
+	*-atari*)
+		os=-mint
+		;;
+	*)
+		os=-none
+		;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer.  We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+	*-unknown)
+		case $os in
+			-riscix*)
+				vendor=acorn
+				;;
+			-sunos*)
+				vendor=sun
+				;;
+			-cnk*|-aix*)
+				vendor=ibm
+				;;
+			-beos*)
+				vendor=be
+				;;
+			-hpux*)
+				vendor=hp
+				;;
+			-mpeix*)
+				vendor=hp
+				;;
+			-hiux*)
+				vendor=hitachi
+				;;
+			-unos*)
+				vendor=crds
+				;;
+			-dgux*)
+				vendor=dg
+				;;
+			-luna*)
+				vendor=omron
+				;;
+			-genix*)
+				vendor=ns
+				;;
+			-mvs* | -opened*)
+				vendor=ibm
+				;;
+			-os400*)
+				vendor=ibm
+				;;
+			-ptx*)
+				vendor=sequent
+				;;
+			-tpf*)
+				vendor=ibm
+				;;
+			-vxsim* | -vxworks* | -windiss*)
+				vendor=wrs
+				;;
+			-aux*)
+				vendor=apple
+				;;
+			-hms*)
+				vendor=hitachi
+				;;
+			-mpw* | -macos*)
+				vendor=apple
+				;;
+			-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+				vendor=atari
+				;;
+			-vos*)
+				vendor=stratus
+				;;
+		esac
+		basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+		;;
+esac
+
+echo $basic_machine$os
+exit
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
Index: config/depcomp
===================================================================
--- config/depcomp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ config/depcomp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,630 @@
+#! /bin/sh
+# depcomp - compile a program generating dependencies as side-effects
+
+scriptversion=2009-04-28.21; # UTC
+
+# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
+# Software Foundation, Inc.
+
+# This program 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, or (at your option)
+# any later version.
+
+# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
+
+case $1 in
+  '')
+     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
+     exit 1;
+     ;;
+  -h | --h*)
+    cat <<\EOF
+Usage: depcomp [--help] [--version] PROGRAM [ARGS]
+
+Run PROGRAMS ARGS to compile a file, generating dependencies
+as side-effects.
+
+Environment variables:
+  depmode     Dependency tracking mode.
+  source      Source file read by `PROGRAMS ARGS'.
+  object      Object file output by `PROGRAMS ARGS'.
+  DEPDIR      directory where to store dependencies.
+  depfile     Dependency file to output.
+  tmpdepfile  Temporary file to use when outputing dependencies.
+  libtool     Whether libtool is used (yes/no).
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+    exit $?
+    ;;
+  -v | --v*)
+    echo "depcomp $scriptversion"
+    exit $?
+    ;;
+esac
+
+if test -z "$depmode" || test -z "$source" || test -z "$object"; then
+  echo "depcomp: Variables source, object and depmode must be set" 1>&2
+  exit 1
+fi
+
+# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
+depfile=${depfile-`echo "$object" |
+  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
+tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
+
+rm -f "$tmpdepfile"
+
+# Some modes work just like other modes, but use different flags.  We
+# parameterize here, but still list the modes in the big case below,
+# to make depend.m4 easier to write.  Note that we *cannot* use a case
+# here, because this file can only contain one case statement.
+if test "$depmode" = hp; then
+  # HP compiler uses -M and no extra arg.
+  gccflag=-M
+  depmode=gcc
+fi
+
+if test "$depmode" = dashXmstdout; then
+   # This is just like dashmstdout with a different argument.
+   dashmflag=-xM
+   depmode=dashmstdout
+fi
+
+cygpath_u="cygpath -u -f -"
+if test "$depmode" = msvcmsys; then
+   # This is just like msvisualcpp but w/o cygpath translation.
+   # Just convert the backslash-escaped backslashes to single forward
+   # slashes to satisfy depend.m4
+   cygpath_u="sed s,\\\\\\\\,/,g"
+   depmode=msvisualcpp
+fi
+
+case "$depmode" in
+gcc3)
+## gcc 3 implements dependency tracking that does exactly what
+## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
+## it if -MD -MP comes after the -MF stuff.  Hmm.
+## Unfortunately, FreeBSD c89 acceptance of flags depends upon
+## the command line argument order; so add the flags where they
+## appear in depend2.am.  Note that the slowdown incurred here
+## affects only configure: in makefiles, %FASTDEP% shortcuts this.
+  for arg
+  do
+    case $arg in
+    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
+    *)  set fnord "$@" "$arg" ;;
+    esac
+    shift # fnord
+    shift # $arg
+  done
+  "$@"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  mv "$tmpdepfile" "$depfile"
+  ;;
+
+gcc)
+## There are various ways to get dependency output from gcc.  Here's
+## why we pick this rather obscure method:
+## - Don't want to use -MD because we'd like the dependencies to end
+##   up in a subdir.  Having to rename by hand is ugly.
+##   (We might end up doing this anyway to support other compilers.)
+## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
+##   -MM, not -M (despite what the docs say).
+## - Using -M directly means running the compiler twice (even worse
+##   than renaming).
+  if test -z "$gccflag"; then
+    gccflag=-MD,
+  fi
+  "$@" -Wp,"$gccflag$tmpdepfile"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
+## The second -e expression handles DOS-style file names with drive letters.
+  sed -e 's/^[^:]*: / /' \
+      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
+## This next piece of magic avoids the `deleted header file' problem.
+## The problem is that when a header file which appears in a .P file
+## is deleted, the dependency causes make to die (because there is
+## typically no way to rebuild the header).  We avoid this by adding
+## dummy dependencies for each header file.  Too bad gcc doesn't do
+## this for us directly.
+  tr ' ' '
+' < "$tmpdepfile" |
+## Some versions of gcc put a space before the `:'.  On the theory
+## that the space means something, we add a space to the output as
+## well.
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+hp)
+  # This case exists only to let depend.m4 do its work.  It works by
+  # looking at the text of this script.  This case will never be run,
+  # since it is checked for above.
+  exit 1
+  ;;
+
+sgi)
+  if test "$libtool" = yes; then
+    "$@" "-Wp,-MDupdate,$tmpdepfile"
+  else
+    "$@" -MDupdate "$tmpdepfile"
+  fi
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+
+  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
+    echo "$object : \\" > "$depfile"
+
+    # Clip off the initial element (the dependent).  Don't try to be
+    # clever and replace this with sed code, as IRIX sed won't handle
+    # lines with more than a fixed number of characters (4096 in
+    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
+    # the IRIX cc adds comments like `#:fec' to the end of the
+    # dependency line.
+    tr ' ' '
+' < "$tmpdepfile" \
+    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
+    tr '
+' ' ' >> "$depfile"
+    echo >> "$depfile"
+
+    # The second pass generates a dummy entry for each header file.
+    tr ' ' '
+' < "$tmpdepfile" \
+   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
+   >> "$depfile"
+  else
+    # The sourcefile does not contain any dependencies, so just
+    # store a dummy comment line, to avoid errors with the Makefile
+    # "include basename.Plo" scheme.
+    echo "#dummy" > "$depfile"
+  fi
+  rm -f "$tmpdepfile"
+  ;;
+
+aix)
+  # The C for AIX Compiler uses -M and outputs the dependencies
+  # in a .u file.  In older versions, this file always lives in the
+  # current directory.  Also, the AIX compiler puts `$object:' at the
+  # start of each line; $object doesn't have directory information.
+  # Version 6 uses the directory in both cases.
+  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+  test "x$dir" = "x$object" && dir=
+  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+  if test "$libtool" = yes; then
+    tmpdepfile1=$dir$base.u
+    tmpdepfile2=$base.u
+    tmpdepfile3=$dir.libs/$base.u
+    "$@" -Wc,-M
+  else
+    tmpdepfile1=$dir$base.u
+    tmpdepfile2=$dir$base.u
+    tmpdepfile3=$dir$base.u
+    "$@" -M
+  fi
+  stat=$?
+
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+    exit $stat
+  fi
+
+  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+  do
+    test -f "$tmpdepfile" && break
+  done
+  if test -f "$tmpdepfile"; then
+    # Each line is of the form `foo.o: dependent.h'.
+    # Do two passes, one to just change these to
+    # `$object: dependent.h' and one to simply `dependent.h:'.
+    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
+    # That's a tab and a space in the [].
+    sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+  else
+    # The sourcefile does not contain any dependencies, so just
+    # store a dummy comment line, to avoid errors with the Makefile
+    # "include basename.Plo" scheme.
+    echo "#dummy" > "$depfile"
+  fi
+  rm -f "$tmpdepfile"
+  ;;
+
+icc)
+  # Intel's C compiler understands `-MD -MF file'.  However on
+  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
+  # ICC 7.0 will fill foo.d with something like
+  #    foo.o: sub/foo.c
+  #    foo.o: sub/foo.h
+  # which is wrong.  We want:
+  #    sub/foo.o: sub/foo.c
+  #    sub/foo.o: sub/foo.h
+  #    sub/foo.c:
+  #    sub/foo.h:
+  # ICC 7.1 will output
+  #    foo.o: sub/foo.c sub/foo.h
+  # and will wrap long lines using \ :
+  #    foo.o: sub/foo.c ... \
+  #     sub/foo.h ... \
+  #     ...
+
+  "$@" -MD -MF "$tmpdepfile"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+  # Each line is of the form `foo.o: dependent.h',
+  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
+  # Do two passes, one to just change these to
+  # `$object: dependent.h' and one to simply `dependent.h:'.
+  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
+  # Some versions of the HPUX 10.20 sed can't process this invocation
+  # correctly.  Breaking it into two sed invocations is a workaround.
+  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
+    sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+hp2)
+  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
+  # compilers, which have integrated preprocessors.  The correct option
+  # to use with these is +Maked; it writes dependencies to a file named
+  # 'foo.d', which lands next to the object file, wherever that
+  # happens to be.
+  # Much of this is similar to the tru64 case; see comments there.
+  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+  test "x$dir" = "x$object" && dir=
+  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+  if test "$libtool" = yes; then
+    tmpdepfile1=$dir$base.d
+    tmpdepfile2=$dir.libs/$base.d
+    "$@" -Wc,+Maked
+  else
+    tmpdepfile1=$dir$base.d
+    tmpdepfile2=$dir$base.d
+    "$@" +Maked
+  fi
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+     rm -f "$tmpdepfile1" "$tmpdepfile2"
+     exit $stat
+  fi
+
+  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
+  do
+    test -f "$tmpdepfile" && break
+  done
+  if test -f "$tmpdepfile"; then
+    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
+    # Add `dependent.h:' lines.
+    sed -ne '2,${
+	       s/^ *//
+	       s/ \\*$//
+	       s/$/:/
+	       p
+	     }' "$tmpdepfile" >> "$depfile"
+  else
+    echo "#dummy" > "$depfile"
+  fi
+  rm -f "$tmpdepfile" "$tmpdepfile2"
+  ;;
+
+tru64)
+   # The Tru64 compiler uses -MD to generate dependencies as a side
+   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
+   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
+   # dependencies in `foo.d' instead, so we check for that too.
+   # Subdirectories are respected.
+   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+   test "x$dir" = "x$object" && dir=
+   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+
+   if test "$libtool" = yes; then
+      # With Tru64 cc, shared objects can also be used to make a
+      # static library.  This mechanism is used in libtool 1.4 series to
+      # handle both shared and static libraries in a single compilation.
+      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
+      #
+      # With libtool 1.5 this exception was removed, and libtool now
+      # generates 2 separate objects for the 2 libraries.  These two
+      # compilations output dependencies in $dir.libs/$base.o.d and
+      # in $dir$base.o.d.  We have to check for both files, because
+      # one of the two compilations can be disabled.  We should prefer
+      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
+      # automatically cleaned when .libs/ is deleted, while ignoring
+      # the former would cause a distcleancheck panic.
+      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
+      tmpdepfile2=$dir$base.o.d          # libtool 1.5
+      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
+      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
+      "$@" -Wc,-MD
+   else
+      tmpdepfile1=$dir$base.o.d
+      tmpdepfile2=$dir$base.d
+      tmpdepfile3=$dir$base.d
+      tmpdepfile4=$dir$base.d
+      "$@" -MD
+   fi
+
+   stat=$?
+   if test $stat -eq 0; then :
+   else
+      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+      exit $stat
+   fi
+
+   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+   do
+     test -f "$tmpdepfile" && break
+   done
+   if test -f "$tmpdepfile"; then
+      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
+      # That's a tab and a space in the [].
+      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+   else
+      echo "#dummy" > "$depfile"
+   fi
+   rm -f "$tmpdepfile"
+   ;;
+
+#nosideeffect)
+  # This comment above is used by automake to tell side-effect
+  # dependency tracking mechanisms from slower ones.
+
+dashmstdout)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout, regardless of -o.
+  "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test "X$1" != 'X--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
+  # Remove `-o $object'.
+  IFS=" "
+  for arg
+  do
+    case $arg in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
+    *)
+      set fnord "$@" "$arg"
+      shift # fnord
+      shift # $arg
+      ;;
+    esac
+  done
+
+  test -z "$dashmflag" && dashmflag=-M
+  # Require at least two characters before searching for `:'
+  # in the target name.  This is to cope with DOS-style filenames:
+  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
+  "$@" $dashmflag |
+    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
+  rm -f "$depfile"
+  cat < "$tmpdepfile" > "$depfile"
+  tr ' ' '
+' < "$tmpdepfile" | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+dashXmstdout)
+  # This case only exists to satisfy depend.m4.  It is never actually
+  # run, as this mode is specially recognized in the preamble.
+  exit 1
+  ;;
+
+makedepend)
+  "$@" || exit $?
+  # Remove any Libtool call
+  if test "$libtool" = yes; then
+    while test "X$1" != 'X--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+  # X makedepend
+  shift
+  cleared=no eat=no
+  for arg
+  do
+    case $cleared in
+    no)
+      set ""; shift
+      cleared=yes ;;
+    esac
+    if test $eat = yes; then
+      eat=no
+      continue
+    fi
+    case "$arg" in
+    -D*|-I*)
+      set fnord "$@" "$arg"; shift ;;
+    # Strip any option that makedepend may not understand.  Remove
+    # the object too, otherwise makedepend will parse it as a source file.
+    -arch)
+      eat=yes ;;
+    -*|$object)
+      ;;
+    *)
+      set fnord "$@" "$arg"; shift ;;
+    esac
+  done
+  obj_suffix=`echo "$object" | sed 's/^.*\././'`
+  touch "$tmpdepfile"
+  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
+  rm -f "$depfile"
+  cat < "$tmpdepfile" > "$depfile"
+  sed '1,2d' "$tmpdepfile" | tr ' ' '
+' | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile" "$tmpdepfile".bak
+  ;;
+
+cpp)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout.
+  "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test "X$1" != 'X--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
+  # Remove `-o $object'.
+  IFS=" "
+  for arg
+  do
+    case $arg in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
+    *)
+      set fnord "$@" "$arg"
+      shift # fnord
+      shift # $arg
+      ;;
+    esac
+  done
+
+  "$@" -E |
+    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
+       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
+    sed '$ s: \\$::' > "$tmpdepfile"
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  cat < "$tmpdepfile" >> "$depfile"
+  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+msvisualcpp)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout.
+  "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test "X$1" != 'X--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
+  IFS=" "
+  for arg
+  do
+    case "$arg" in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
+    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
+	set fnord "$@"
+	shift
+	shift
+	;;
+    *)
+	set fnord "$@" "$arg"
+	shift
+	shift
+	;;
+    esac
+  done
+  "$@" -E 2>/dev/null |
+  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
+  echo "	" >> "$depfile"
+  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+msvcmsys)
+  # This case exists only to let depend.m4 do its work.  It works by
+  # looking at the text of this script.  This case will never be run,
+  # since it is checked for above.
+  exit 1
+  ;;
+
+none)
+  exec "$@"
+  ;;
+
+*)
+  echo "Unknown depmode $depmode" 1>&2
+  exit 1
+  ;;
+esac
+
+exit 0
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
Index: config/install-sh
===================================================================
--- config/install-sh	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ config/install-sh	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,520 @@
+#!/bin/sh
+# install - install a program, script, or datafile
+
+scriptversion=2009-04-28.21; # UTC
+
+# This originates from X11R5 (mit/util/scripts/install.sh), which was
+# later released in X11R6 (xc/config/util/install.sh) with the
+# following copyright and license.
+#
+# Copyright (C) 1994 X Consortium
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
+# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name of the X Consortium shall not
+# be used in advertising or otherwise to promote the sale, use or other deal-
+# ings in this Software without prior written authorization from the X Consor-
+# tium.
+#
+#
+# FSF changes to this file are in the public domain.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.
+
+nl='
+'
+IFS=" ""	$nl"
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit=${DOITPROG-}
+if test -z "$doit"; then
+  doit_exec=exec
+else
+  doit_exec=$doit
+fi
+
+# Put in absolute file names if you don't have them in your path;
+# or use environment vars.
+
+chgrpprog=${CHGRPPROG-chgrp}
+chmodprog=${CHMODPROG-chmod}
+chownprog=${CHOWNPROG-chown}
+cmpprog=${CMPPROG-cmp}
+cpprog=${CPPROG-cp}
+mkdirprog=${MKDIRPROG-mkdir}
+mvprog=${MVPROG-mv}
+rmprog=${RMPROG-rm}
+stripprog=${STRIPPROG-strip}
+
+posix_glob='?'
+initialize_posix_glob='
+  test "$posix_glob" != "?" || {
+    if (set -f) 2>/dev/null; then
+      posix_glob=
+    else
+      posix_glob=:
+    fi
+  }
+'
+
+posix_mkdir=
+
+# Desired mode of installed file.
+mode=0755
+
+chgrpcmd=
+chmodcmd=$chmodprog
+chowncmd=
+mvcmd=$mvprog
+rmcmd="$rmprog -f"
+stripcmd=
+
+src=
+dst=
+dir_arg=
+dst_arg=
+
+copy_on_change=false
+no_target_directory=
+
+usage="\
+Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
+   or: $0 [OPTION]... SRCFILES... DIRECTORY
+   or: $0 [OPTION]... -t DIRECTORY SRCFILES...
+   or: $0 [OPTION]... -d DIRECTORIES...
+
+In the 1st form, copy SRCFILE to DSTFILE.
+In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
+In the 4th, create DIRECTORIES.
+
+Options:
+     --help     display this help and exit.
+     --version  display version info and exit.
+
+  -c            (ignored)
+  -C            install only if different (preserve the last data modification time)
+  -d            create directories instead of installing files.
+  -g GROUP      $chgrpprog installed files to GROUP.
+  -m MODE       $chmodprog installed files to MODE.
+  -o USER       $chownprog installed files to USER.
+  -s            $stripprog installed files.
+  -t DIRECTORY  install into DIRECTORY.
+  -T            report an error if DSTFILE is a directory.
+
+Environment variables override the default commands:
+  CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
+  RMPROG STRIPPROG
+"
+
+while test $# -ne 0; do
+  case $1 in
+    -c) ;;
+
+    -C) copy_on_change=true;;
+
+    -d) dir_arg=true;;
+
+    -g) chgrpcmd="$chgrpprog $2"
+	shift;;
+
+    --help) echo "$usage"; exit $?;;
+
+    -m) mode=$2
+	case $mode in
+	  *' '* | *'	'* | *'
+'*	  | *'*'* | *'?'* | *'['*)
+	    echo "$0: invalid mode: $mode" >&2
+	    exit 1;;
+	esac
+	shift;;
+
+    -o) chowncmd="$chownprog $2"
+	shift;;
+
+    -s) stripcmd=$stripprog;;
+
+    -t) dst_arg=$2
+	shift;;
+
+    -T) no_target_directory=true;;
+
+    --version) echo "$0 $scriptversion"; exit $?;;
+
+    --)	shift
+	break;;
+
+    -*)	echo "$0: invalid option: $1" >&2
+	exit 1;;
+
+    *)  break;;
+  esac
+  shift
+done
+
+if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
+  # When -d is used, all remaining arguments are directories to create.
+  # When -t is used, the destination is already specified.
+  # Otherwise, the last argument is the destination.  Remove it from $@.
+  for arg
+  do
+    if test -n "$dst_arg"; then
+      # $@ is not empty: it contains at least $arg.
+      set fnord "$@" "$dst_arg"
+      shift # fnord
+    fi
+    shift # arg
+    dst_arg=$arg
+  done
+fi
+
+if test $# -eq 0; then
+  if test -z "$dir_arg"; then
+    echo "$0: no input file specified." >&2
+    exit 1
+  fi
+  # It's OK to call `install-sh -d' without argument.
+  # This can happen when creating conditional directories.
+  exit 0
+fi
+
+if test -z "$dir_arg"; then
+  trap '(exit $?); exit' 1 2 13 15
+
+  # Set umask so as not to create temps with too-generous modes.
+  # However, 'strip' requires both read and write access to temps.
+  case $mode in
+    # Optimize common cases.
+    *644) cp_umask=133;;
+    *755) cp_umask=22;;
+
+    *[0-7])
+      if test -z "$stripcmd"; then
+	u_plus_rw=
+      else
+	u_plus_rw='% 200'
+      fi
+      cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
+    *)
+      if test -z "$stripcmd"; then
+	u_plus_rw=
+      else
+	u_plus_rw=,u+rw
+      fi
+      cp_umask=$mode$u_plus_rw;;
+  esac
+fi
+
+for src
+do
+  # Protect names starting with `-'.
+  case $src in
+    -*) src=./$src;;
+  esac
+
+  if test -n "$dir_arg"; then
+    dst=$src
+    dstdir=$dst
+    test -d "$dstdir"
+    dstdir_status=$?
+  else
+
+    # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
+    # might cause directories to be created, which would be especially bad
+    # if $src (and thus $dsttmp) contains '*'.
+    if test ! -f "$src" && test ! -d "$src"; then
+      echo "$0: $src does not exist." >&2
+      exit 1
+    fi
+
+    if test -z "$dst_arg"; then
+      echo "$0: no destination specified." >&2
+      exit 1
+    fi
+
+    dst=$dst_arg
+    # Protect names starting with `-'.
+    case $dst in
+      -*) dst=./$dst;;
+    esac
+
+    # If destination is a directory, append the input filename; won't work
+    # if double slashes aren't ignored.
+    if test -d "$dst"; then
+      if test -n "$no_target_directory"; then
+	echo "$0: $dst_arg: Is a directory" >&2
+	exit 1
+      fi
+      dstdir=$dst
+      dst=$dstdir/`basename "$src"`
+      dstdir_status=0
+    else
+      # Prefer dirname, but fall back on a substitute if dirname fails.
+      dstdir=`
+	(dirname "$dst") 2>/dev/null ||
+	expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	     X"$dst" : 'X\(//\)[^/]' \| \
+	     X"$dst" : 'X\(//\)$' \| \
+	     X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
+	echo X"$dst" |
+	    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+		   s//\1/
+		   q
+		 }
+		 /^X\(\/\/\)[^/].*/{
+		   s//\1/
+		   q
+		 }
+		 /^X\(\/\/\)$/{
+		   s//\1/
+		   q
+		 }
+		 /^X\(\/\).*/{
+		   s//\1/
+		   q
+		 }
+		 s/.*/./; q'
+      `
+
+      test -d "$dstdir"
+      dstdir_status=$?
+    fi
+  fi
+
+  obsolete_mkdir_used=false
+
+  if test $dstdir_status != 0; then
+    case $posix_mkdir in
+      '')
+	# Create intermediate dirs using mode 755 as modified by the umask.
+	# This is like FreeBSD 'install' as of 1997-10-28.
+	umask=`umask`
+	case $stripcmd.$umask in
+	  # Optimize common cases.
+	  *[2367][2367]) mkdir_umask=$umask;;
+	  .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
+
+	  *[0-7])
+	    mkdir_umask=`expr $umask + 22 \
+	      - $umask % 100 % 40 + $umask % 20 \
+	      - $umask % 10 % 4 + $umask % 2
+	    `;;
+	  *) mkdir_umask=$umask,go-w;;
+	esac
+
+	# With -d, create the new directory with the user-specified mode.
+	# Otherwise, rely on $mkdir_umask.
+	if test -n "$dir_arg"; then
+	  mkdir_mode=-m$mode
+	else
+	  mkdir_mode=
+	fi
+
+	posix_mkdir=false
+	case $umask in
+	  *[123567][0-7][0-7])
+	    # POSIX mkdir -p sets u+wx bits regardless of umask, which
+	    # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
+	    ;;
+	  *)
+	    tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+	    trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
+
+	    if (umask $mkdir_umask &&
+		exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
+	    then
+	      if test -z "$dir_arg" || {
+		   # Check for POSIX incompatibilities with -m.
+		   # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
+		   # other-writeable bit of parent directory when it shouldn't.
+		   # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
+		   ls_ld_tmpdir=`ls -ld "$tmpdir"`
+		   case $ls_ld_tmpdir in
+		     d????-?r-*) different_mode=700;;
+		     d????-?--*) different_mode=755;;
+		     *) false;;
+		   esac &&
+		   $mkdirprog -m$different_mode -p -- "$tmpdir" && {
+		     ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
+		     test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
+		   }
+		 }
+	      then posix_mkdir=:
+	      fi
+	      rmdir "$tmpdir/d" "$tmpdir"
+	    else
+	      # Remove any dirs left behind by ancient mkdir implementations.
+	      rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
+	    fi
+	    trap '' 0;;
+	esac;;
+    esac
+
+    if
+      $posix_mkdir && (
+	umask $mkdir_umask &&
+	$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
+      )
+    then :
+    else
+
+      # The umask is ridiculous, or mkdir does not conform to POSIX,
+      # or it failed possibly due to a race condition.  Create the
+      # directory the slow way, step by step, checking for races as we go.
+
+      case $dstdir in
+	/*) prefix='/';;
+	-*) prefix='./';;
+	*)  prefix='';;
+      esac
+
+      eval "$initialize_posix_glob"
+
+      oIFS=$IFS
+      IFS=/
+      $posix_glob set -f
+      set fnord $dstdir
+      shift
+      $posix_glob set +f
+      IFS=$oIFS
+
+      prefixes=
+
+      for d
+      do
+	test -z "$d" && continue
+
+	prefix=$prefix$d
+	if test -d "$prefix"; then
+	  prefixes=
+	else
+	  if $posix_mkdir; then
+	    (umask=$mkdir_umask &&
+	     $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
+	    # Don't fail if two instances are running concurrently.
+	    test -d "$prefix" || exit 1
+	  else
+	    case $prefix in
+	      *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
+	      *) qprefix=$prefix;;
+	    esac
+	    prefixes="$prefixes '$qprefix'"
+	  fi
+	fi
+	prefix=$prefix/
+      done
+
+      if test -n "$prefixes"; then
+	# Don't fail if two instances are running concurrently.
+	(umask $mkdir_umask &&
+	 eval "\$doit_exec \$mkdirprog $prefixes") ||
+	  test -d "$dstdir" || exit 1
+	obsolete_mkdir_used=true
+      fi
+    fi
+  fi
+
+  if test -n "$dir_arg"; then
+    { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
+    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
+    { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
+      test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
+  else
+
+    # Make a couple of temp file names in the proper directory.
+    dsttmp=$dstdir/_inst.$$_
+    rmtmp=$dstdir/_rm.$$_
+
+    # Trap to clean up those temp files at exit.
+    trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
+
+    # Copy the file name to the temp name.
+    (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
+
+    # and set any options; do chmod last to preserve setuid bits.
+    #
+    # If any of these fail, we abort the whole thing.  If we want to
+    # ignore errors from any of these, just make sure not to ignore
+    # errors from the above "$doit $cpprog $src $dsttmp" command.
+    #
+    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
+    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
+    { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
+    { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
+
+    # If -C, don't bother to copy if it wouldn't change the file.
+    if $copy_on_change &&
+       old=`LC_ALL=C ls -dlL "$dst"	2>/dev/null` &&
+       new=`LC_ALL=C ls -dlL "$dsttmp"	2>/dev/null` &&
+
+       eval "$initialize_posix_glob" &&
+       $posix_glob set -f &&
+       set X $old && old=:$2:$4:$5:$6 &&
+       set X $new && new=:$2:$4:$5:$6 &&
+       $posix_glob set +f &&
+
+       test "$old" = "$new" &&
+       $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
+    then
+      rm -f "$dsttmp"
+    else
+      # Rename the file to the real destination.
+      $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
+
+      # The rename failed, perhaps because mv can't rename something else
+      # to itself, or perhaps because mv is so ancient that it does not
+      # support -f.
+      {
+	# Now remove or move aside any old file at destination location.
+	# We try this two ways since rm can't unlink itself on some
+	# systems and the destination file might be busy for other
+	# reasons.  In this case, the final cleanup might fail but the new
+	# file should still install successfully.
+	{
+	  test ! -f "$dst" ||
+	  $doit $rmcmd -f "$dst" 2>/dev/null ||
+	  { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
+	    { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
+	  } ||
+	  { echo "$0: cannot unlink or rename $dst" >&2
+	    (exit 1); exit 1
+	  }
+	} &&
+
+	# Now rename the file to the real destination.
+	$doit $mvcmd "$dsttmp" "$dst"
+      }
+    fi || exit 1
+
+    trap '' 0
+  fi
+done
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
Index: config/missing
===================================================================
--- config/missing	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ config/missing	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,376 @@
+#! /bin/sh
+# Common stub for a few missing GNU programs while installing.
+
+scriptversion=2009-04-28.21; # UTC
+
+# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
+# 2008, 2009 Free Software Foundation, Inc.
+# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
+
+# This program 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, or (at your option)
+# any later version.
+
+# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+if test $# -eq 0; then
+  echo 1>&2 "Try \`$0 --help' for more information"
+  exit 1
+fi
+
+run=:
+sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
+sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
+
+# In the cases where this matters, `missing' is being run in the
+# srcdir already.
+if test -f configure.ac; then
+  configure_ac=configure.ac
+else
+  configure_ac=configure.in
+fi
+
+msg="missing on your system"
+
+case $1 in
+--run)
+  # Try to run requested program, and just exit if it succeeds.
+  run=
+  shift
+  "$@" && exit 0
+  # Exit code 63 means version mismatch.  This often happens
+  # when the user try to use an ancient version of a tool on
+  # a file that requires a minimum version.  In this case we
+  # we should proceed has if the program had been absent, or
+  # if --run hadn't been passed.
+  if test $? = 63; then
+    run=:
+    msg="probably too old"
+  fi
+  ;;
+
+  -h|--h|--he|--hel|--help)
+    echo "\
+$0 [OPTION]... PROGRAM [ARGUMENT]...
+
+Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
+error status if there is no known handling for PROGRAM.
+
+Options:
+  -h, --help      display this help and exit
+  -v, --version   output version information and exit
+  --run           try to run the given command, and emulate it if it fails
+
+Supported PROGRAM values:
+  aclocal      touch file \`aclocal.m4'
+  autoconf     touch file \`configure'
+  autoheader   touch file \`config.h.in'
+  autom4te     touch the output file, or create a stub one
+  automake     touch all \`Makefile.in' files
+  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
+  flex         create \`lex.yy.c', if possible, from existing .c
+  help2man     touch the output file
+  lex          create \`lex.yy.c', if possible, from existing .c
+  makeinfo     touch the output file
+  tar          try tar, gnutar, gtar, then tar without non-portable flags
+  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
+
+Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
+\`g' are ignored when checking the name.
+
+Send bug reports to <bug-automake@gnu.org>."
+    exit $?
+    ;;
+
+  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+    echo "missing $scriptversion (GNU Automake)"
+    exit $?
+    ;;
+
+  -*)
+    echo 1>&2 "$0: Unknown \`$1' option"
+    echo 1>&2 "Try \`$0 --help' for more information"
+    exit 1
+    ;;
+
+esac
+
+# normalize program name to check for.
+program=`echo "$1" | sed '
+  s/^gnu-//; t
+  s/^gnu//; t
+  s/^g//; t'`
+
+# Now exit if we have it, but it failed.  Also exit now if we
+# don't have it and --version was passed (most likely to detect
+# the program).  This is about non-GNU programs, so use $1 not
+# $program.
+case $1 in
+  lex*|yacc*)
+    # Not GNU programs, they don't have --version.
+    ;;
+
+  tar*)
+    if test -n "$run"; then
+       echo 1>&2 "ERROR: \`tar' requires --run"
+       exit 1
+    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+       exit 1
+    fi
+    ;;
+
+  *)
+    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+       # We have it, but it failed.
+       exit 1
+    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+       # Could not run --version or --help.  This is probably someone
+       # running `$TOOL --version' or `$TOOL --help' to check whether
+       # $TOOL exists and not knowing $TOOL uses missing.
+       exit 1
+    fi
+    ;;
+esac
+
+# If it does not exist, or fails to run (possibly an outdated version),
+# try to emulate it.
+case $program in
+  aclocal*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
+         to install the \`Automake' and \`Perl' packages.  Grab them from
+         any GNU archive site."
+    touch aclocal.m4
+    ;;
+
+  autoconf*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`${configure_ac}'.  You might want to install the
+         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
+         archive site."
+    touch configure
+    ;;
+
+  autoheader*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
+         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
+         from any GNU archive site."
+    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
+    test -z "$files" && files="config.h"
+    touch_files=
+    for f in $files; do
+      case $f in
+      *:*) touch_files="$touch_files "`echo "$f" |
+				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
+      *) touch_files="$touch_files $f.in";;
+      esac
+    done
+    touch $touch_files
+    ;;
+
+  automake*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
+         You might want to install the \`Automake' and \`Perl' packages.
+         Grab them from any GNU archive site."
+    find . -type f -name Makefile.am -print |
+	   sed 's/\.am$/.in/' |
+	   while read f; do touch "$f"; done
+    ;;
+
+  autom4te*)
+    echo 1>&2 "\
+WARNING: \`$1' is needed, but is $msg.
+         You might have modified some files without having the
+         proper tools for further handling them.
+         You can get \`$1' as part of \`Autoconf' from any GNU
+         archive site."
+
+    file=`echo "$*" | sed -n "$sed_output"`
+    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+    if test -f "$file"; then
+	touch $file
+    else
+	test -z "$file" || exec >$file
+	echo "#! /bin/sh"
+	echo "# Created by GNU Automake missing as a replacement of"
+	echo "#  $ $@"
+	echo "exit 0"
+	chmod +x $file
+	exit 1
+    fi
+    ;;
+
+  bison*|yacc*)
+    echo 1>&2 "\
+WARNING: \`$1' $msg.  You should only need it if
+         you modified a \`.y' file.  You may need the \`Bison' package
+         in order for those modifications to take effect.  You can get
+         \`Bison' from any GNU archive site."
+    rm -f y.tab.c y.tab.h
+    if test $# -ne 1; then
+        eval LASTARG="\${$#}"
+	case $LASTARG in
+	*.y)
+	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
+	    if test -f "$SRCFILE"; then
+	         cp "$SRCFILE" y.tab.c
+	    fi
+	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
+	    if test -f "$SRCFILE"; then
+	         cp "$SRCFILE" y.tab.h
+	    fi
+	  ;;
+	esac
+    fi
+    if test ! -f y.tab.h; then
+	echo >y.tab.h
+    fi
+    if test ! -f y.tab.c; then
+	echo 'main() { return 0; }' >y.tab.c
+    fi
+    ;;
+
+  lex*|flex*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified a \`.l' file.  You may need the \`Flex' package
+         in order for those modifications to take effect.  You can get
+         \`Flex' from any GNU archive site."
+    rm -f lex.yy.c
+    if test $# -ne 1; then
+        eval LASTARG="\${$#}"
+	case $LASTARG in
+	*.l)
+	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
+	    if test -f "$SRCFILE"; then
+	         cp "$SRCFILE" lex.yy.c
+	    fi
+	  ;;
+	esac
+    fi
+    if test ! -f lex.yy.c; then
+	echo 'main() { return 0; }' >lex.yy.c
+    fi
+    ;;
+
+  help2man*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+	 you modified a dependency of a manual page.  You may need the
+	 \`Help2man' package in order for those modifications to take
+	 effect.  You can get \`Help2man' from any GNU archive site."
+
+    file=`echo "$*" | sed -n "$sed_output"`
+    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+    if test -f "$file"; then
+	touch $file
+    else
+	test -z "$file" || exec >$file
+	echo ".ab help2man is required to generate this page"
+	exit $?
+    fi
+    ;;
+
+  makeinfo*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified a \`.texi' or \`.texinfo' file, or any other file
+         indirectly affecting the aspect of the manual.  The spurious
+         call might also be the consequence of using a buggy \`make' (AIX,
+         DU, IRIX).  You might want to install the \`Texinfo' package or
+         the \`GNU make' package.  Grab either from any GNU archive site."
+    # The file to touch is that specified with -o ...
+    file=`echo "$*" | sed -n "$sed_output"`
+    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+    if test -z "$file"; then
+      # ... or it is the one specified with @setfilename ...
+      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
+      file=`sed -n '
+	/^@setfilename/{
+	  s/.* \([^ ]*\) *$/\1/
+	  p
+	  q
+	}' $infile`
+      # ... or it is derived from the source name (dir/f.texi becomes f.info)
+      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
+    fi
+    # If the file does not exist, the user really needs makeinfo;
+    # let's fail without touching anything.
+    test -f $file || exit 1
+    touch $file
+    ;;
+
+  tar*)
+    shift
+
+    # We have already tried tar in the generic part.
+    # Look for gnutar/gtar before invocation to avoid ugly error
+    # messages.
+    if (gnutar --version > /dev/null 2>&1); then
+       gnutar "$@" && exit 0
+    fi
+    if (gtar --version > /dev/null 2>&1); then
+       gtar "$@" && exit 0
+    fi
+    firstarg="$1"
+    if shift; then
+	case $firstarg in
+	*o*)
+	    firstarg=`echo "$firstarg" | sed s/o//`
+	    tar "$firstarg" "$@" && exit 0
+	    ;;
+	esac
+	case $firstarg in
+	*h*)
+	    firstarg=`echo "$firstarg" | sed s/h//`
+	    tar "$firstarg" "$@" && exit 0
+	    ;;
+	esac
+    fi
+
+    echo 1>&2 "\
+WARNING: I can't seem to be able to run \`tar' with the given arguments.
+         You may want to install GNU tar or Free paxutils, or check the
+         command line arguments."
+    exit 1
+    ;;
+
+  *)
+    echo 1>&2 "\
+WARNING: \`$1' is needed, and is $msg.
+         You might have modified some files without having the
+         proper tools for further handling them.  Check the \`README' file,
+         it often tells you about the needed prerequisites for installing
+         this package.  You may also peek at any GNU archive site, in case
+         some other package would contain this missing \`$1' program."
+    exit 1
+    ;;
+esac
+
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
Index: configure.ac
===================================================================
--- configure.ac	(revision b21cb9dbead4d40950777be4260bea1a6560f9b6)
+++ configure.ac	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -3,14 +3,116 @@
 
 AC_PREREQ(2.59)
-AC_INIT([ElectronicStructurePACKage], 1.1, heber@ins.uni-bonn.de, ESPACK)
-AC_CONFIG_AUX_DIR([config])
-AC_CONFIG_SRCDIR([pcp/src/pcp.c])
+AC_INIT(Molecuilder, 1.0, heber@ins.uni-bonn.de, molecuilder)
+AC_CONFIG_AUX_DIR(config)
+AC_CONFIG_SRCDIR([src/builder.cpp])
 AC_CONFIG_HEADER([config.h])
 
 AM_INIT_AUTOMAKE(dist-bzip2)
 
-AC_CANONICAL_HOST
+# Checks for programs.
+AM_PATH_CPPUNIT(1.9.6)
+AC_PROG_CXX
+AC_PROG_CC
+AC_PROG_RANLIB
+AC_PROG_INSTALL
+AC_CHECK_PROG([LATEX],[latex],[latex],[:])
+AC_CHECK_PROG([BIBTEX],[bibtex],[bibtex],[:])
+AC_CHECK_PROG([DVIPS],[dvips],[dvips],[:])
+AC_CHECK_PROG([PDFLATEX],[pdflatex],[pdflatex],[:])
+AC_CHECK_PROG([XMLTO],[xmlto],[xmlto],[:])
+AM_MISSING_PROG([DOXYGEN], [doxygen])
 
-AC_CONFIG_FILES([Makefile])
-AC_CONFIG_SUBDIRS([pcp util molecuilder])
+# Checks for libraries.
+AC_CHECK_LIB(m, sqrt, ,AC_MSG_ERROR([compatible libc math library not found]))
+
+# Boost libraries
+AX_BOOST_BASE([1.40])
+AX_BOOST_PROGRAM_OPTIONS
+#AX_BOOST_FOREACH
+#AX_BOOST_FILESYSTEM
+AX_BOOST_THREAD
+#AX_BOOST_SERIALIZATION
+
+#QT4 libraries
+gw_CHECK_QT4
+AX_CHECK_GLU
+AC_MSG_NOTICE(["GLU_CFLAGS: $GLU_CFLAGS, GLU_CXXFLAGS: $GLU_CXXFLAGS, GLU_LDFLAGS: $GLU_LDFLAGS, GLU_LIBS: $GLU_LIBS"])
+
+
+# Checks for header files.
+AC_HEADER_STDC
+AC_CHECK_HEADERS([sys/time.h])
+AC_HEADER_STDBOOL
+
+AC_FUNC_MALLOC
+AC_FUNC_REALLOC
+AC_CHECK_FUNCS([floor pow sqrt strchr])
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+AC_C_INLINE
+AC_C_RESTRICT
+AC_TYPE_SIZE_T
+
+# Checks for library functions.
+# check for GNU Scientific Library
+AC_CHECK_HEADERS([gsl/gsl_blas.h])
+AC_SEARCH_LIBS(dnrm2, goto blas cblas gslblas gslcblas)
+AC_CHECK_LIB(gsl, main, [], 
+	[AC_SEARCH_LIBS(cblas_dnrm2, blas cblas gslblas gslcblas)])
+AC_CHECK_LIB(gsl, gsl_blas_dnrm2, , [AC_MSG_ERROR(["No working BLAS found for GSL, stopping."])])
+
+# add replacement/saturation hydrogen or not 
+AC_ARG_ENABLE([hydrogen],AS_HELP_STRING([--enable-hydrogen],[Adding saturation hydrogen (default is yes)]),
+              [enable_hydrogen=$enableval], [enable_hydrogen=yes])
+if test x"$enable_hydrogen" = xyes; then
+  AC_DEFINE(ADDHYDROGEN,1, ["Adding saturation hydrogen"])
+  AC_SUBST(ADDHYDROGEN)
+fi
+
+# add replacement/saturation hydrogen or not 
+AC_ARG_ENABLE([ecut],AS_HELP_STRING([--enable-ecut],[Use ECut TestRunnerClient (default is no)]),
+              [enable_ecut=$enableval], [enable_ecut=no])
+if test x"$enable_ecut" = xyes; then
+  AC_DEFINE(HAVE_ECUT,1, ["Use ECut TestRunnerClient instead of our own."])
+  AC_SUBST(HAVE_ECUT)
+fi
+
+# Check for "extern inline", using a modified version
+# of the test for AC_C_INLINE from acspecific.mt
+AC_CACHE_CHECK([for extern inline], ac_cv_c_extern_inline,
+[ac_cv_c_extern_inline=no
+AC_TRY_COMPILE([extern $ac_cv_c_inline double foo(double x);
+extern $ac_cv_c_inline double foo(double x) { return x+1.0; };
+double foo (double x) { return x + 1.0; };], 
+[  foo(1.0)  ],
+[ac_cv_c_extern_inline="yes"])
+])
+
+if test "$ac_cv_c_inline" != no ; then
+  AC_DEFINE(HAVE_INLINE,1, ["May use inline routines"])
+  AC_SUBST(HAVE_INLINE)
+fi
+
+#AC_MSG_NOTICE(["CFLAGS: $CFLAGS, CXXFLAGS: $CXXFLAGS, LDFLAGS: $LDFLAGS, CC: $CC, CXX:, $CXX, MPICC: $MPICC, MPILIBS: $MPILIBS, LIBS: $LIBS"])
+
+# test suite
+AC_CONFIG_TESTDIR(tests/regression)
+AC_CONFIG_FILES([
+	tests/Makefile
+	tests/regression/atlocal 
+	tests/regression/Makefile])
+AC_CONFIG_FILES([tests/regression/molecuilder], [chmod +x tests/regression/molecuilder])
+AC_CONFIG_FILES([
+	tests/Tesselations/Makefile 
+	tests/Tesselations/defs])
+AC_CONFIG_FILES([
+	doc/molecuilder.xml])
+AC_CONFIG_FILES([
+	Makefile 
+	doc/Makefile 
+	src/Makefile 
+	src/Actions/Makefile
+	src/UIElements/Makefile
+	src/unittests/Makefile])
 AC_OUTPUT
Index: doc/Doxyfile
===================================================================
--- doc/Doxyfile	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ doc/Doxyfile	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,260 @@
+# Doxyfile 1.4.5
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+PROJECT_NAME           = Molecuilder
+PROJECT_NUMBER         = 1.0
+OUTPUT_DIRECTORY       = ../doc
+CREATE_SUBDIRS         = NO
+OUTPUT_LANGUAGE        = English
+USE_WINDOWS_ENCODING   = YES
+BRIEF_MEMBER_DESC      = YES
+REPEAT_BRIEF           = YES
+ABBREVIATE_BRIEF       = "The $name class" \
+                         "The $name widget" \
+                         "The $name file" \
+                         is \
+                         provides \
+                         specifies \
+                         contains \
+                         represents \
+                         a \
+                         an \
+                         the
+ALWAYS_DETAILED_SEC    = NO
+INLINE_INHERITED_MEMB  = NO
+FULL_PATH_NAMES        = YES
+STRIP_FROM_PATH        = ../bin/
+STRIP_FROM_INC_PATH    = 
+SHORT_NAMES            = NO
+JAVADOC_AUTOBRIEF      = YES
+MULTILINE_CPP_IS_BRIEF = NO
+DETAILS_AT_TOP         = NO
+INHERIT_DOCS           = YES
+SEPARATE_MEMBER_PAGES  = NO
+TAB_SIZE               = 3
+ALIASES                = 
+OPTIMIZE_OUTPUT_FOR_C  = YES
+OPTIMIZE_OUTPUT_JAVA   = NO
+#BUILTIN_STL_SUPPORT    = NO
+DISTRIBUTE_GROUP_DOC   = NO
+SUBGROUPING            = YES
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+EXTRACT_ALL            = YES
+EXTRACT_PRIVATE        = YES
+EXTRACT_STATIC         = YES
+EXTRACT_LOCAL_CLASSES  = YES
+EXTRACT_LOCAL_METHODS  = YES
+HIDE_UNDOC_MEMBERS     = NO
+HIDE_UNDOC_CLASSES     = NO
+HIDE_FRIEND_COMPOUNDS  = NO
+HIDE_IN_BODY_DOCS      = NO
+INTERNAL_DOCS          = YES
+CASE_SENSE_NAMES       = NO
+HIDE_SCOPE_NAMES       = NO
+SHOW_INCLUDE_FILES     = YES
+INLINE_INFO            = YES
+SORT_MEMBER_DOCS       = YES
+SORT_BRIEF_DOCS        = NO
+SORT_BY_SCOPE_NAME     = NO
+GENERATE_TODOLIST      = YES
+GENERATE_TESTLIST      = YES
+GENERATE_BUGLIST       = YES
+GENERATE_DEPRECATEDLIST= YES
+ENABLED_SECTIONS       = 
+MAX_INITIALIZER_LINES  = 30
+SHOW_USED_FILES        = YES
+SHOW_DIRECTORIES       = NO
+FILE_VERSION_FILTER    = 
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+QUIET                  = NO
+WARNINGS               = YES
+WARN_IF_UNDOCUMENTED   = YES
+WARN_IF_DOC_ERROR      = YES
+WARN_NO_PARAMDOC       = NO
+WARN_FORMAT            = "$file:$line: $text"
+WARN_LOGFILE           = 
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+INPUT                  = ../src
+FILE_PATTERNS          = *.c \
+                         *.cc \
+                         *.cxx \
+                         *.cpp \
+                         *.c++ \
+                         *.d \
+                         *.java \
+                         *.ii \
+                         *.ixx \
+                         *.ipp \
+                         *.i++ \
+                         *.inl \
+                         *.h \
+                         *.hh \
+                         *.hxx \
+                         *.hpp \
+                         *.h++ \
+                         *.idl \
+                         *.odl \
+                         *.cs \
+                         *.php \
+                         *.php3 \
+                         *.inc \
+                         *.m \
+                         *.mm \
+                         *.dox \
+                         *.py
+RECURSIVE              = YES
+EXCLUDE                = 
+EXCLUDE_SYMLINKS       = NO
+EXCLUDE_PATTERNS       = */unittests/* \
+						 */test/*
+EXAMPLE_PATH           = 
+EXAMPLE_PATTERNS       = *
+EXAMPLE_RECURSIVE      = NO
+IMAGE_PATH             = 
+INPUT_FILTER           = 
+FILTER_PATTERNS        = 
+FILTER_SOURCE_FILES    = NO
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+SOURCE_BROWSER         = YES
+INLINE_SOURCES         = YES
+STRIP_CODE_COMMENTS    = NO
+REFERENCED_BY_RELATION = NO
+REFERENCES_RELATION    = NO
+USE_HTAGS              = NO
+VERBATIM_HEADERS       = NO
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+ALPHABETICAL_INDEX     = NO
+COLS_IN_ALPHA_INDEX    = 5
+IGNORE_PREFIX          = 
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+GENERATE_HTML          = YES
+HTML_OUTPUT            = html
+HTML_FILE_EXTENSION    = .html
+HTML_HEADER            = 
+HTML_FOOTER            = 
+HTML_STYLESHEET        = 
+HTML_ALIGN_MEMBERS     = YES
+GENERATE_HTMLHELP      = NO
+CHM_FILE               = 
+HHC_LOCATION           = 
+GENERATE_CHI           = NO
+BINARY_TOC             = NO
+TOC_EXPAND             = NO
+DISABLE_INDEX          = NO
+ENUM_VALUES_PER_LINE   = 4
+GENERATE_TREEVIEW      = NO
+TREEVIEW_WIDTH         = 250
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+GENERATE_LATEX         = NO
+LATEX_OUTPUT           = latex
+LATEX_CMD_NAME         = latex
+MAKEINDEX_CMD_NAME     = makeindex
+COMPACT_LATEX          = NO
+PAPER_TYPE             = a4wide
+EXTRA_PACKAGES         = 
+LATEX_HEADER           = 
+PDF_HYPERLINKS         = YES
+USE_PDFLATEX           = YES
+LATEX_BATCHMODE        = NO
+LATEX_HIDE_INDICES     = NO
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+GENERATE_RTF           = NO
+RTF_OUTPUT             = rtf
+COMPACT_RTF            = NO
+RTF_HYPERLINKS         = NO
+RTF_STYLESHEET_FILE    = 
+RTF_EXTENSIONS_FILE    = 
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+GENERATE_MAN           = NO
+MAN_OUTPUT             = man
+MAN_EXTENSION          = .3
+MAN_LINKS              = NO
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+GENERATE_XML           = NO
+XML_OUTPUT             = xml
+XML_SCHEMA             = 
+XML_DTD                = 
+XML_PROGRAMLISTING     = YES
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+GENERATE_AUTOGEN_DEF   = NO
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+GENERATE_PERLMOD       = NO
+PERLMOD_LATEX          = NO
+PERLMOD_PRETTY         = YES
+PERLMOD_MAKEVAR_PREFIX = 
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor   
+#---------------------------------------------------------------------------
+ENABLE_PREPROCESSING   = YES
+MACRO_EXPANSION        = NO
+EXPAND_ONLY_PREDEF     = NO
+SEARCH_INCLUDES        = YES
+INCLUDE_PATH           = 
+INCLUDE_FILE_PATTERNS  = 
+PREDEFINED             = 
+EXPAND_AS_DEFINED      = 
+SKIP_FUNCTION_MACROS   = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references   
+#---------------------------------------------------------------------------
+TAGFILES               = 
+GENERATE_TAGFILE       = 
+ALLEXTERNALS           = NO
+EXTERNAL_GROUPS        = YES
+PERL_PATH              = /usr/bin/perl
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool   
+#---------------------------------------------------------------------------
+CLASS_DIAGRAMS         = YES
+HIDE_UNDOC_RELATIONS   = YES
+HAVE_DOT               = NO
+CLASS_GRAPH            = YES
+COLLABORATION_GRAPH    = YES
+GROUP_GRAPHS           = YES
+UML_LOOK               = NO
+TEMPLATE_RELATIONS     = NO
+INCLUDE_GRAPH          = YES
+INCLUDED_BY_GRAPH      = YES
+CALL_GRAPH             = NO
+GRAPHICAL_HIERARCHY    = YES
+DIRECTORY_GRAPH        = YES
+DOT_IMAGE_FORMAT       = png
+DOT_PATH               = 
+DOTFILE_DIRS           = 
+MAX_DOT_GRAPH_WIDTH    = 1024
+MAX_DOT_GRAPH_HEIGHT   = 1024
+MAX_DOT_GRAPH_DEPTH    = 1000
+DOT_TRANSPARENT        = NO
+DOT_MULTI_TARGETS      = NO
+GENERATE_LEGEND        = YES
+DOT_CLEANUP            = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to the search engine   
+#---------------------------------------------------------------------------
+SEARCHENGINE           = YES
Index: doc/Makefile.am
===================================================================
--- doc/Makefile.am	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ doc/Makefile.am	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,52 @@
+EXTRA_DIST = \
+	Doxyfile \
+	html \
+        man-molecuilder.xml \
+	userguide.xml
+
+SRCMANDOCS =
+
+GENMANDOCS = \
+	molecuilder.1 \
+	espack.conf.5
+
+dist_man_MANS = $(SRCMANDOCS) $(GENMANDOCS)
+dist_doc_DATA = $(PDFFILES)
+
+SUFFIXES = .pdf .ps .dvi .tex .xml .html
+
+html-local: doxygen-docs
+
+doxygen-docs:
+	cd $(srcdir) && $(DOXYGEN)
+
+.xml.ps:
+	$(XMLTO) $(XMLTOFLAGS) ps $<
+	@touch $@
+
+.xml.html:
+	$(XMLTO) $(XMLTOFLAGS) html-nochunks $<
+	@touch $@
+
+molecuilder.stamp: molecuilder.xml
+	@rm -f molecuilder.tmp
+	@touch molecuilder.tmp
+	$(XMLTO) $(XMLTOFLAGS) man $<
+	@touch $(GENMANDOCS)
+	@mv -f molecuilder.tmp $@
+
+$(GENMANDOCS): molecuilder.stamp
+	@if test -f $@; then touch $@; else \
+	  rm -f molecuilder.stamp; \
+	  $(MAKE) $(AM_MAKEFLAGS) molecuilder.stamp; \
+	fi
+
+clean-local: 
+	rm -f *.aux *.bbl *.blg *.log *.aux.bak
+distclean-local:
+	rm -f *.dvi *.ps *.pdf *.html $(GENMANDOCS) molecuilder.stamp
+
+.PHONY: allclean doxygen-docs
+allclean: distclean
+
+
Index: doc/class structure todo.uxf
===================================================================
--- doc/class structure todo.uxf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ doc/class structure todo.uxf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8"?><umlet_diagram><help_text>// Uncomment the following line to change the fontsize:
+// fontsize=14
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+// Welcome to UMLet!
+//
+// Double-click on UML elements to add them to the diagram, or to copy them
+// Edit elements by modifying the text in this panel
+// Hold Ctrl to select multiple elements
+// Use Ctrl+mouse to select via lasso
+//
+// Use Â± or Ctrl+mouse wheel to zoom
+// Drag a whole relation at its central square icon
+//
+// Press Ctrl+C to copy the whole diagram to the system clipboard (then just paste it to, eg, Word)
+// Edit the files in the "palettes" directory to create your own element palettes
+//
+// Select "Custom Elements &gt; New..." to create new element types
+//////////////////////////////////////////////////////////////////////////////////////////////
+
+
+// This text will be stored with each diagram;  use it for notes.</help_text><zoom_level>10</zoom_level><element><type>com.umlet.element.base.Class</type><coordinates><x>340</x><y>240</y><w>210</w><h>190</h></coordinates><panel_attributes>&lt;&lt;Singleton&gt;&gt;
+World
+{Some Properties}
+--
+-id: Long
+_-ClassAttribute: Long_
+--
+#Operation(i: int): int
+/+AbstractOperation()/
+--
+Responsibilities
+-- Resp1
+*-- Resp2*</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>540</x><y>590</y><w>210</w><h>190</h></coordinates><panel_attributes>Particle
+--
+-id: Long
+_-ClassAttribute: Long_
+--
+/+Tesselierung/
+--
+Responsibilities
+-- Resp1
+*-- Resp2*</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>470</x><y>870</y><w>210</w><h>190</h></coordinates><panel_attributes>&lt;&lt;Composite&gt;&gt;
+ParticleGroup
+{Some Properties}
+--
+-id: Long
+_-ClassAttribute: Long_
+--
+#Operation(i: int): int
+/+AbstractOperation()/
+--
+Responsibilities
+-- Resp1
+*-- Resp2*</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>550</x><y>750</y><w>100</w><h>140</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>80;30;80;80;30;80;30;120</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>390</x><y>640</y><w>170</w><h>350</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>80;330;30;330;30;30;150;30</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1020</x><y>1160</y><w>210</w><h>190</h></coordinates><panel_attributes>Atom
+{Some Properties}
+--
+-id: Long
+_-ClassAttribute: Long_
+--
+#Operation(i: int): int
+/+AbstractOperation()/
+--
+Responsibilities
+-- Can have many roles
+*-- Resp2*</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>800</x><y>1030</y><w>340</w><h>150</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>30;30;30;90;320;90;320;130</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>420</x><y>400</y><w>230</w><h>210</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>30;30;30;130;210;130;210;190</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>170</x><y>610</y><w>210</w><h>190</h></coordinates><panel_attributes>PeriodenTafel
+{Some Properties}
+--
+-id: Long
+_-ClassAttribute: Long_
+--
+#Operation(i: int): int
+/+AbstractOperation()/
+--
+Responsibilities
+-- Resp1
+*-- Resp2*</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>750</x><y>1160</y><w>210</w><h>190</h></coordinates><panel_attributes>&lt;&lt;Composite&gt;&gt;
+Molecule
+{Some Properties}
+--
+-id: Long
+_-ClassAttribute: Long_
+--
+#Operation(i: int): int
+/+AbstractOperation()/
+--
+Responsibilities
+-- Resp1
+*-- Resp2*</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>800</x><y>1030</y><w>50</w><h>150</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>30;30;30;130</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>730</x><y>870</y><w>210</w><h>190</h></coordinates><panel_attributes>BondedParticle
+Package::FatClass
+{Some Properties}
+--
+-id: Long
+_-ClassAttribute: Long_
+--
+#Operation(i: int): int
+/+AbstractOperation()/
+--
+Responsibilities
+-- Resp1
+*-- Resp2*</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>600</x><y>750</y><w>250</w><h>140</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>30;30;30;80;230;80;230;120</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>670</x><y>950</y><w>100</w><h>320</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>80;300;30;300;30;30;60;30</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>740</x><y>240</y><w>210</w><h>190</h></coordinates><panel_attributes>TesselNode
+{Some Properties}
+--
+-id: Long
+_-ClassAttribute: Long_
+--
+#Operation(i: int): int
+/+AbstractOperation()/
+--
+Responsibilities
+-- Resp1
+*-- Resp2*</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>650</x><y>400</y><w>200</w><h>210</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>180;30;180;130;30;130;30;190</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>240</x><y>400</y><w>230</w><h>230</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>210;30;210;130;30;130;30;210</additional_attributes></element></umlet_diagram>
Index: doc/class structure.uxf
===================================================================
--- doc/class structure.uxf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ doc/class structure.uxf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,334 @@
+<?xml version="1.0" encoding="UTF-8"?><umlet_diagram><help_text>// Uncomment the following line to change the fontsize:
+// fontsize=14
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+// Welcome to UMLet!
+//
+// Double-click on UML elements to add them to the diagram, or to copy them
+// Edit elements by modifying the text in this panel
+// Hold Ctrl to select multiple elements
+// Use Ctrl+mouse to select via lasso
+//
+// Use Â± or Ctrl+mouse wheel to zoom
+// Drag a whole relation at its central square icon
+//
+// Press Ctrl+C to copy the whole diagram to the system clipboard (then just paste it to, eg, Word)
+// Edit the files in the "palettes" directory to create your own element palettes
+//
+// Select "Custom Elements &gt; New..." to create new element types
+//////////////////////////////////////////////////////////////////////////////////////////////
+
+
+// This text will be stored with each diagram;  use it for notes.</help_text><zoom_level>7</zoom_level><element><type>com.umlet.element.base.Class</type><coordinates><x>1855</x><y>210</y><w>147</w><h>70</h></coordinates><panel_attributes>AtomInfo
+--
+-x,v,F: Vector
+  element *type;  //!&lt; pointing to element
+--
+#AtomInfo();
+#~AtomInfo();
+</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1645</x><y>231</y><w>223</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>210;21;21;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1274</x><y>63</y><w>392</w><h>259</h></coordinates><panel_attributes>Element
+--
+mass: double
+CovalentRadius: double
+VanDerWaalsRadius: double
+Z: int
+name: char[64]
+symbol: char[3]
+period: char[8]
+group: char[8]
+block: char[8]
+sort: int *
+No: int
+Valence: double
+NoValenceOrbitals: int
+HBondDistance: double[NDIM]
+HBondAngle: double[NDIM]
+--
+#element();
+#~element();
+#Output(ofstream * const out) const: bool
+#Checkout(ofstream * const out, const int No, const int NoOfAtoms) const: bool</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1960</x><y>448</y><w>280</w><h>161</h></coordinates><panel_attributes>BondedParticle
+--
+--
+#Operation(i: int): int
+#BondedParticle()
+/+virtual ~BondedParticle()/
+#RegisterBond(bond *Binder): bool
+#UnregisterBond(bond *Binder): bool
+#IsBondedTo(BondedParticle * const BondPartner): bool 
+#UnregisterAllBond();
+#CountBonds() const: int
+#CorrectBondDegree(): int
+#OutputBondOfAtom() const
+#OutputAdjacency(ofstream *AdjacencyFile) const
+#OutputOrder(ofstream *file) const</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>2184</x><y>259</y><w>258</w><h>202</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>245;21;245;154;21;154;21;189</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1925</x><y>259</y><w>293</w><h>202</h></coordinates><panel_attributes>lt=&lt;&lt;-
+</panel_attributes><additional_attributes>21;21;21;154;280;154;280;189</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>2184</x><y>259</y><w>34</w><h>202</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;189</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2359</x><y>210</y><w>147</w><h>70</h></coordinates><panel_attributes>BondedParticleInfo
+--
+AdaptiveOrder: unsigned char
+MaxOrder: bool
+--
+#BondedParticleInfo()
+#~BondedParticleInfo()
+</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2079</x><y>196</y><w>217</w><h>84</h></coordinates><panel_attributes>ParticleInfo
+--
+nr: int
+Name: char *
+--
+#ParticleInfo()
+#~ParticleInfo()
+#ostream &amp; operator &lt;&lt; (ostream &amp;ost) const
+</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>2485</x><y>231</y><w>174</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>21;21;161;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2646</x><y>161</y><w>147</w><h>133</h></coordinates><panel_attributes>BondList
+{Some Properties}
+--
+-id: Long
+_-ClassAttribute: Long_
+--
+#Operation(i: int): int
+/+AbstractOperation()/
+--
+Responsibilities
+-- Resp1
+*-- Resp2*</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1372</x><y>343</y><w>147</w><h>105</h></coordinates><panel_attributes>GraphNodeInfo
+--
+--
+GraphNr: int
+ComponentNr: int *
+LowpointNr: int 
+SeparationVertex: bool 
+IsCyclic: bool
+
+--
+#GraphNodeInfo()
+#~GraphNodeInfo()
+</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1484</x><y>525</y><w>126</w><h>70</h></coordinates><panel_attributes>GraphNode
+--
+--
+#GraphNode()
+/+~GraphNode()/
+#OutputGraphInfo() const
+#OutputComponentNumber() const
+</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1484</x><y>259</y><w>748</w><h>279</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>735;21;735;70;217;70;217;210;21;210;21;266</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1484</x><y>427</y><w>34</w><h>111</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;98</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1288</x><y>672</y><w>588</w><h>245</h></coordinates><panel_attributes>Atom
+--
+sort: int*
+--
+#atom()
+#atom(class atom *pointer)
+/+~atom()/
+#OutputIndexed(ofstream * const out, const int ElementNo, const int AtomNo, const char *comment = NULL) const: bool 
+#OutputArrayIndexed(ofstream * const out, const int *ElementNo, 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: bool
+#OutputTrajectoryXYZ(ofstream * const out, const int step) const: bool
+#OutputMPQCLine(ofstream * const out, const Vector *center, int *AtomNo) const
+#InitComponentNr()
+#EqualsFather ( const atom *ptr, const atom **res ) const
+#CorrectFather()
+#GetTrueFather(): atom *
+#Compare(const atom &amp;ptr) const: bool
+#DistanceToVector(const Vector &amp;origin) const: double 
+#DistanceSquaredToVector(const Vector &amp;origin) const: double
+#IsInParallelepiped(const Vector offset, const double *parallelepiped) const: bool</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1379</x><y>427</y><w>83</w><h>258</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;182;70;182;70;245</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2226</x><y>665</y><w>504</w><h>210</h></coordinates><panel_attributes>TrajectoryParticle
+--
+--
+#TrajectoryParticle()
+/+~TrajectoryParticle()/
+#AddKineticToTemperature(double *temperature, int step) const
+#EvaluateConstrainedForce(int startstep, int endstep, atom **PermutationMap, ForceMatrix *Force) const
+#CorrectVelocity(double *ActualTemp, int Step, Vector *CoGVelocity)
+#ResizeTrajectory(int MaxSteps)
+#CopyStepOnStep(int dest, int src)
+#VelocityVerletUpdate(int MDSteps, config *configuration, ForceMatrix *Force)
+#SumUpKineticEnergy( int Step, double *TotalMass, Vector *TotalVelocity ) const
+#Thermostat_Woodcock(double ScaleTempFactor, int Step, double *ekin)
+#Thermostat_Gaussian_init(int Step, double *G, double *E)
+#Thermostat_Gaussian_least_constraint(int Step, double G_over_E, double *ekin, config *configuration)
+#Thermostat_Langevin(int Step, gsl_rng * r, double *ekin, config *configuration)
+#Thermostat_Berendsen(int Step, double ScaleTempFactor, double *ekin, config *configuration)
+#Thermostat_NoseHoover_init(int Step, double *delta_alpha)
+#Thermostat_NoseHoover_scale(int Step, double *ekin, config *configuration)</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>2149</x><y>259</y><w>209</w><h>419</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;112;196;112;196;406</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1967</x><y>259</y><w>391</w><h>419</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;112;378;112;378;406</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1617</x><y>490</y><w>203</w><h>70</h></coordinates><panel_attributes>TrajectoryParticleInfo
+--
+Trajectory: struct {vector&lt;Vector&gt; R,U,V}
+FixedIon: int
+--
+#TrajectoryParticleInfo()
+#~TrajectoryParticleInfo()</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1757</x><y>539</y><w>601</w><h>139</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;105;588;105;588;126</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>539</y><w>34</w><h>146</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;133</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1519</x><y>574</y><w>244</w><h>111</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;56;231;56;231;98</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1736</x><y>364</y><w>147</w><h>112</h></coordinates><panel_attributes>TesselPoint
+--
+-id: Long
+_-ClassAttribute: Long_
+--
+#Operation(i: int): int
+/+AbstractOperation()/
+--
+Responsibilities
+-- Resp1
+*-- Resp2*</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>455</y><w>146</w><h>230</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>133;21;133;175;21;175;21;217</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>588</y><w>398</w><h>97</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>385;21;385;42;21;42;21;84</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>259</y><w>398</w><h>426</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>385;21;385;168;196;168;196;371;21;371;21;413</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>259</y><w>209</w><h>426</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>196;21;196;371;21;371;21;413</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>833</x><y>770</y><w>357</w><h>224</h></coordinates><panel_attributes>Bond
+--
+HydrogenBond: int
+BondDegree: int
+nr: int
+Cyclic: bool
+Type: enum EdgeType
+Used: enum Shading
+--
+#GetOtherAtom(const ParticleInfo * const Atom) const: atom *
+#MarkUsed(const enum Shading color): bool
+#IsUsed(): enum Shading
+#ResetUsed()
+#Contains(const ParticleInfo * const ptr): bool
+#Contains(const int nr): bool
+#GetDistance() const: double
+#GetDistanceSquared() const: double
+#bond()
+#bond(atom *left, atom *right, const int degree=1, const int number=0)
+#~bond()</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1834</x><y>623</y><w>107</w><h>125</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-
+3</panel_attributes><additional_attributes>42;112;91;112;91;35;21;35;21;49</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1169</x><y>812</y><w>132</w><h>49</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-
+2</panel_attributes><additional_attributes>21;35;119;35</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>770</x><y>658</y><w>111</w><h>167</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-
+2</panel_attributes><additional_attributes>63;154;28;154;28;35;98;35;98;112</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1113</x><y>1246</y><w>504</w><h>168</h></coordinates><panel_attributes>BondGraph
+--
+max_distance: double
+IsAngstroem: bool
+--
+#BondGraph(bool IsA);
+#~BondGraph();
+#LoadBondLengthTable(const string &amp;filename): bool
+#ConstructBondGraph(molecule * const mol): bool
+#GetBondLength(int firstelement, int secondelement): double
+#SetMaxDistanceToMaxOfCovalentRadii(const molecule * const mol): double
+#BondLengthMatrixMinMaxDistance(BondedParticle * const Walker, BondedParticle * const OtherWalker,
+                                                        double &amp;MinDistance, double &amp;MaxDistance, bool IsAngstroem)
+#CovalentMinMaxDistance(BondedParticle * const Walker, BondedParticle * const OtherWalker,
+                                          double &amp;MinDistance, double &amp;MaxDistance, bool IsAngstroem)</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1596</x><y>1323</y><w>167</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>21;21;154;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1750</x><y>1281</y><w>147</w><h>133</h></coordinates><panel_attributes>MatrixContainer
+--
+-id: Long
+_-ClassAttribute: Long_
+--
+#Operation(i: int): int
+/+AbstractOperation()/
+--
+Responsibilities
+-- Resp1
+*-- Resp2*</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>0</x><y>455</y><w>511</w><h>1050</h></coordinates><panel_attributes>config
+--
+PsiType: int
+MaxPsiDouble: int
+PsiMaxNoUp: int
+PsiMaxNoDown: int
+MaxMinStopStep: int
+InitMaxMinStopStep: int
+ProcPEGamma: int
+ProcPEPsi: int
+configpath: char *
+configname: char *
+FastParsing: bool
+Deltat: double
+basis: string
+databasepath: char *
+DoConstrainedMD: int
+MaxOuterStep: int
+Thermostat: int
+ThermostatImplemented: int *
+ThermostatNames: char **
+TempFrequency: double
+alpha: double
+HooverMass: double
+TargetTemp: double
+ScaleTempStep: int
+mainname: char *
+defaultpath: char *
+pseudopotpath: char *
+DoOutVis: int
+DoOutMes: int
+DoOutNICS: int
+DoOutOrbitals: int
+DoOutCurrent: int
+DoFullCurrent: int
+DoPerturbation: int
+DoWannier: int
+CommonWannier: int
+SawtoothStart: double
+VectorPlane: int
+VectorCut: double
+UseAddGramSch: int 
+Seed: int
+OutVisStep: int 
+OutSrcStep: int
+MaxPsiStep: int
+EpsWannier: double
+MaxMinStep: int
+RelEpsTotalEnergy: double
+RelEpsKineticEnergy: double
+MaxMinGapStopStep: int
+MaxInitMinStep: int
+InitRelEpsTotalEnergy: double
+InitRelEpsKineticEnergy: double
+InitMaxMinGapStopStep: int
+ECut: double
+MaxLevel: int
+RiemannTensor: int
+LevRFactor: int
+RiemannLevel: int
+Lev0Factor: int
+RTActualUse: int
+AddPsis: int
+RCut: double
+StructOpt: int
+IsAngstroem: int
+RelativeCoord: int
+MaxTypes: int
+--
+#config();
+#~config();
+#TestSyntax(const char * const filename, const periodentafel * const periode) const: int
+#Load(const char * const filename, const string &amp;BondGraphFileName,
+          const periodentafel * const periode, MoleculeListClass * const &amp;MolList);
+#LoadOld(const char * const filename, const string &amp;BondGraphFileName,
+                const periodentafel * const periode, MoleculeListClass * const &amp;MolList);
+#RetrieveConfigPathAndName(const string filename);
+#Save(const char * const filename, const periodentafel * const periode, molecule * const mol) const: bool
+#SaveMPQC(const char * const filename, const molecule * const mol) const: bool
+#SavePDB(const char * const filename, const MoleculeListClass * const MolList) const: bool
+#SavePDB(const char * const filename, const molecule * const mol) const: bool
+#SaveTREMOLO(const char * const filename, const molecule * const mol) const: bool
+#SaveTREMOLO(const char * const filename, const MoleculeListClass * const MolList) const: bool
+#Edit();
+#GetIsAngstroem() const: bool
+#GetDefaultPath() const: char *
+#SetDefaultPath(const char * const path);
+#InitThermostats();
+#ParseThermostats(class ConfigFileBuffer * const fb);</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>490</x><y>1344</y><w>636</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>21;21;623;21</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1596</x><y>0</y><w>121</w><h>139</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-
+2</panel_attributes><additional_attributes>70;126;105;126;105;35;21;35;21;63</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2520</x><y>896</y><w>224</w><h>140</h></coordinates><panel_attributes>&lt;&lt;Singleton&gt;&gt;
+errorLogger
+--
+static ostream *nix;
+static int verbosity;
+static errorLogger* instance;
+--
+#static getInstance(): errorLogger*
+#static purgeInstance()
+#static DoOutput(): bool
+#static setVerbosity(int verbosityLevel);
+#protected errorLogger()
+#protected ~errorLogger()</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2093</x><y>980</y><w>364</w><h>35</h></coordinates><panel_attributes>KeyCompare
+--
+--
+#operator() (const KeySet SubgraphA, const KeySet SubgraphB) const: bool
+</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1169</x><y>1134</y><w>147</w><h>105</h></coordinates><panel_attributes>UniqueFragments
+--
+ANOVAOrder: int
+FragmentCounter: int
+CurrentIndex: int
+TEFactor: double
+ShortestPathList: int *
+UsedList: bool **
+BondsPerSPCount: int *</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>490</x><y>1169</y><w>692</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>679;21;21;21</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1120</x><y>896</y><w>251</w><h>307</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>49;294;21;294;21;224;238;224;238;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>840</x><y>1043</y><w>245</w><h>28</h></coordinates><panel_attributes>Graph
+{map &lt;KeySet, NumberValuePair, KeyCompare&gt;}
+</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>861</x><y>1050</y><w>321</w><h>153</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>308;140;21;140;21;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>945</x><y>1106</y><w>56</w><h>28</h></coordinates><panel_attributes>KeySet
+{set&lt;int&gt;}</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>945</x><y>1113</y><w>237</w><h>90</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>224;77;21;77;21;21</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1085</x><y>973</y><w>99</w><h>230</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-
+0...N X 0...N</panel_attributes><additional_attributes>84;217;56;217;56;112;21;112;21;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1736</x><y>2198</y><w>147</w><h>42</h></coordinates><panel_attributes>LSQ_params
+--
+vectors: const Vector **
+num: int
+</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1043</x><y>182</y><w>147</w><h>35</h></coordinates><panel_attributes>lsq_params
+--
+x: gsl_vector *</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1169</x><y>182</y><w>118</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>21;21;105;21</additional_attributes></element></umlet_diagram>
Index: doc/menu classes.uxf
===================================================================
--- doc/menu classes.uxf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ doc/menu classes.uxf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,270 @@
+<?xml version="1.0" encoding="UTF-8"?><umlet_diagram><help_text>// Uncomment the following line to change the fontsize:
+// fontsize=14
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+// Welcome to UMLet!
+//
+// Double-click on UML elements to add them to the diagram, or to copy them
+// Edit elements by modifying the text in this panel
+// Hold Ctrl to select multiple elements
+// Use Ctrl+mouse to select via lasso
+//
+// Use Â± or Ctrl+mouse wheel to zoom
+// Drag a whole relation at its central square icon
+//
+// Press Ctrl+C to copy the whole diagram to the system clipboard (then just paste it to, eg, Word)
+// Edit the files in the "palettes" directory to create your own element palettes
+//
+// Select "Custom Elements &gt; New..." to create new element types
+//////////////////////////////////////////////////////////////////////////////////////////////
+
+
+// This text will be stored with each diagram;  use it for notes.</help_text><zoom_level>7</zoom_level><element><type>com.umlet.element.base.Class</type><coordinates><x>1057</x><y>42</y><w>147</w><h>98</h></coordinates><panel_attributes>Menu
+--
+--
+#Menu()
+/+~Menu()/
+#addItem(MenuItem*)
+#removeItem(MenuItem*)
+#display()
+--
+-- Base class for all Menus</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1057</x><y>189</y><w>147</w><h>175</h></coordinates><panel_attributes>TextMenu
+--
+outputter: ostream
+title: string;
+spacer: char
+length: int
+--
+#TextMenu(ostream&amp;,string,char,int)
+#TextMenu(ostream&amp;,string)
+/+~TextMenu()/
+addItem(MenuItem*)
+removeItem(MenuItem*)
+display()
+doQuit()
+hasQuit(): bool
+showEntry(MenuItem*)
+</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1575</x><y>21</y><w>259</w><h>266</h></coordinates><panel_attributes>MenuItem
+--
+char trigger: char
+description: string*
+added: bool
+--
+#MenuItem(char,const char*,Menu*);
+/+~MenuItem();/
+/+doTrigger()/
+/+checkTrigger(char)/
+/+formatEntry(): const string/
+/+getDescription(): const string/
+/+getTrigger(): char/
+/+add_to_menu(Menu*)/
+/+wasAdded(): bool/
+#setDescription(string);
+--
+Responsibilities
+-- Store Items in a menu 
+-- check a trigger, 
+     if the trigger matches call doTrigger() on subclass
+--
+Constraints
+-- A MenuItem always belongs to a single
+-- Destruction is done by the owning menu</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1183</x><y>63</y><w>405</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-
+m1=1
+m2=1...N</panel_attributes><additional_attributes>21;21;392;21</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1106</x><y>119</y><w>34</w><h>83</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;70</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1582</x><y>651</y><w>252</w><h>84</h></coordinates><panel_attributes>ActionMenuItem
+--
+
+--
+#ActionMenuItem(char,const char*,Menu*,Action*)
+/+~ActionMenuItem()/
+/+doTrigger()/
+--
+Responsibilities
+-- Call action.call() when the trigger is recieved
+</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1673</x><y>266</y><w>34</w><h>398</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;385</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2037</x><y>392</y><w>238</w><h>182</h></coordinates><panel_attributes>DisplayMenuItem
+--
+string title;
+int length;
+char spacer;
+--
+#DisplayMenuItem(Menu*, StringView *);
+#DisplayMenuItem(Menu*, StringView *, string, char, int);
+/+~DisplayMenuItem()/
+/+doTrigger()/
+/+checkTrigger(char)/
+/+formatEntry(): const string/
+/getDescription(): const string/
+--
+Responsibilities
+-- Display any kind of stringView within a Menu
+-- All trigger are ignored</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2380</x><y>427</y><w>287</w><h>84</h></coordinates><panel_attributes>StringView
+--
+--
+#StringView()
+/+~StringView()/
+/+toString(): const string/
+--
+Responsibilities
+-- Base class for anything that can be displayed as a String</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>2254</x><y>441</y><w>139</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-
+m1=1...N
+m2=1</panel_attributes><additional_attributes>21;21;126;21</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1673</x><y>266</y><w>447</w><h>139</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;105;434;105;434;126</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1729</x><y>406</y><w>217</w><h>154</h></coordinates><panel_attributes>SeperatorItem
+--
+spacer: char
+length: int
+--
+#SeperatorItem(Menu*)
+#SeperatorItem(Menu*,char,int)
+/+virtual ~SeperatorItem()/
+/+doTrigger()/
+/+checkTrigger(char)/
+/+getDescription(): const string/
+/+formatEntry(): const string/
+--
+Responsibilities
+-- Display a seperating line of spacers </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1673</x><y>266</y><w>174</w><h>153</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;105;161;105;161;140</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1302</x><y>343</y><w>252</w><h>98</h></coordinates><panel_attributes>&lt;&lt;composite&gt;&gt;
+SubMenuItem
+--
+--
+#SubMenuItem(char,const char*,Menu*,Menu*)
+/+~SubMenuItem()/
+/+doTrigger()/
+--
+Responsibilities
+-- Produce a submenu when this item is triggered</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1183</x><y>98</y><w>132</w><h>321</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-
+m1=1
+m2=1</panel_attributes><additional_attributes>119;308;77;308;77;21;21;21</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1400</x><y>266</y><w>307</w><h>90</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>294;21;294;56;21;56;21;77</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1288</x><y>644</y><w>231</w><h>133</h></coordinates><panel_attributes>&lt;&lt;Command&gt;&gt;
+Action
+--
+name : string
+--
+#Action(std::string _name,bool _doRegister=true)
+/+~Action()/
+/+call()/
+/+undo()/
+/+canUndo(): bool/
+/+getName(): const string/
+--
+Responsibilities
+-- Perfom an Operation on call</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1498</x><y>658</y><w>97</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-
+m1=0...N
+m2=1</panel_attributes><additional_attributes>84;21;21;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1484</x><y>847</y><w>238</w><h>133</h></coordinates><panel_attributes>&lt;&lt;Wrapper&gt;&gt;
+MethodAction
+--
+executeMethod : boost::function&lt;void()&gt;  
+--
+#MethodAction(boost::function&lt;void()&gt;)
+/+~MethodAction()/
+/+call()/
+/+undo()/
+/+canUndo(): bool/
+--
+Responsibilities
+-- Transform an ordinary method into an Action</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1386</x><y>756</y><w>223</w><h>104</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;56;210;56;210;91</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2436</x><y>259</y><w>182</w><h>56</h></coordinates><panel_attributes>&lt;&lt;View&gt;&gt;
+View
+--
+--
+--
+Responsibilities
+-- Anything that needs to be shown
+</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>2506</x><y>294</y><w>34</w><h>146</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;133</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2219</x><y>644</y><w>287</w><h>105</h></coordinates><panel_attributes>&lt;&lt;Wrapper&gt;&gt;
+MethodStringView
+--
+displayMethod: boost::function&lt;string()&gt;
+--
+#MethodStringView(boost::function&lt;string()&gt;)
+/+~MethodStringView()/
+/+toString(): const string/
+--
+Responsibilities
+-- Turn any method that returns a string into a StringView</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2562</x><y>644</y><w>329</w><h>105</h></coordinates><panel_attributes>&lt;&lt;Wrapper&gt;&gt;
+StreamStringView
+--
+displayMethod: boost::function&lt;void(ofstream *)&gt;
+--
+StreamStringView(boost::function&lt;void(ofstream *)&gt;)
+/+~StreamStringView()/
+/+toString(): const string/
+--
+Responsibilities
+-- Turn any method that uses a stream for output into a StringView</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>2338</x><y>490</y><w>195</w><h>167</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>182;21;182;84;21;84;21;154</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>2499</x><y>490</y><w>244</w><h>167</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;84;231;84;231;154</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1022</x><y>847</y><w>196</w><h>119</h></coordinates><panel_attributes>&lt;&lt;composite&gt;&gt;
+MakroAction
+--
+--
+#MakroAction(ActionSequence*)
+/+~MakroAction()/
+/+call()/
+/+undo()/
+/+canUndo(): bool/
+--
+Responsibilities
+-- Group several small actions together</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>700</x><y>644</y><w>231</w><h>133</h></coordinates><panel_attributes>ActionSequence
+--
+--
+#ActionSequence();
+/+~ActionSequence();/
+#addAction(Action*)
+#removeLastAction(): Action*
+#callAll()
+#undoAll()
+#canUndo(): bool
+--
+Responsibilities
+-- Group several actions together for later use</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>910</x><y>686</y><w>391</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-
+m1=0...N
+m2=1...N</panel_attributes><additional_attributes>21;21;378;21</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>910</x><y>714</y><w>125</w><h>202</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-
+m1=1
+m2=1</panel_attributes><additional_attributes>112;189;77;189;77;21;21;21</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1099</x><y>756</y><w>321</w><h>104</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>308;21;308;56;21;56;21;91</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1890</x><y>868</y><w>217</w><h>91</h></coordinates><panel_attributes>&lt;&lt;singleton&gt;&gt;
+ActionRegistry
+--
+--
+getActionByName(const std::string) : Action*;
+registerAction(Action*);
+--
+Responsibilities
+-- Stores all actions by name for later retrieval
+-- handle destruction of all registered actions</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1498</x><y>728</y><w>398</w><h>181</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>385;168;294;168;294;21;21;21</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1498</x><y>742</y><w>405</w><h>195</h></coordinates><panel_attributes>lt=&lt;.
+registers itself upon creation
+</panel_attributes><additional_attributes>392;182;273;182;273;84;133;84;133;21;21;21</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1295</x><y>756</y><w>125</w><h>111</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>112;21;112;56;21;56;21;98</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1246</x><y>854</y><w>182</w><h>77</h></coordinates><panel_attributes>ErrorAction
+--
+--
+/+call()/
+/+undo()/
+/+canUndo()/
+--
+Responsibilities
+-- Display some kind of error Message</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>399</x><y>21</y><w>469</w><h>91</h></coordinates><panel_attributes>&lt;&lt;Abstract Factory&gt;&gt;
+&lt;&lt;Singleton&gt;&gt;
+UIFactory
+--
+--
+/+makeMainWindow(menuPopulaters,MoleculeListClass *, config *, periodentafel *, char *): MainWindow*/
+/+makeDialog() : Dialog*/
+--
+Responsibilities
+-- Handles creation of all UIElements</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>399</x><y>238</y><w>462</w><h>133</h></coordinates><panel_attributes>&lt;&lt;Concrete Factory&gt;&gt;
+TextUIFactory
+--
+--
+/+makeMainWindow(menuPopulaters,MoleculeListClass *, config *, periodentafel *, char *): MainWindow*/
+/+makeDialog() : Dialog*/
+--
+Responsibilities
+-- Production of all kinds of TextWidgets</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>714</x><y>91</y><w>120</w><h>160</h></coordinates><panel_attributes>lt=&lt;.
+creates and stores</panel_attributes><additional_attributes>63;147;63;21</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>847</x><y>56</y><w>223</w><h>49</h></coordinates><panel_attributes>lt=&lt;.
+creates abstract</panel_attributes><additional_attributes>210;35;21;35</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>840</x><y>259</y><w>230</w><h>49</h></coordinates><panel_attributes>lt=&lt;.
+creates concrete</panel_attributes><additional_attributes>217;35;21;35</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>0</x><y>28</y><w>238</w><h>63</h></coordinates><panel_attributes>MainWindow
+--
+--
+/+display()/
+--
+Responsibilities
+-- Abstract base class for all kinds of MainWindows</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>217</x><y>35</y><w>195</w><h>49</h></coordinates><panel_attributes>lt=&lt;.
+creates abstract</panel_attributes><additional_attributes>21;35;182;35</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>21</x><y>259</y><w>196</w><h>56</h></coordinates><panel_attributes>TextWindow
+--
+--
+/+display()/
+--
+Responsibilities
+-- Special class for MainWindow in TextUIs</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>91</x><y>70</y><w>34</w><h>202</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;189</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>196</x><y>259</y><w>216</w><h>49</h></coordinates><panel_attributes>lt=&lt;.
+creates concrete
+</panel_attributes><additional_attributes>21;35;203;35</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>560</x><y>91</y><w>34</w><h>160</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;147</additional_attributes></element></umlet_diagram>
Index: doc/molecuilder.xml.in
===================================================================
--- doc/molecuilder.xml.in	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ doc/molecuilder.xml.in	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,327 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE article PUBLIC "-//OASIS/DTD DocBook XML V4.4/EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
+<!-- address will be used within (white-space sensitive) <address> markup -->
+<!-- do not use for now
+<!ENTITY ins-street-address "University of Bonn, Institute for Numerical Simulation
+        <street>Wegelerstrasse 6</street>
+        <postcode>53115</postcode> <city>Bonn</city>, <country>Germany</country>
+        <phone>+49-228-73-3427</phone>, <fax>+49-228-73-7527</fax>
+">
+use empty replacement instead: -->
+<!ENTITY ins-street-address "">
+<!ENTITY ins-nolink "<orgdiv>Institute for Numerical Simulation</orgdiv>">
+<!ENTITY ins "<ulink url='http://www.ins.uni-bonn.de/'>Institute for Numerical Simulation</ulink>">
+<!ENTITY ins-maildom "ins.uni-bonn.de">
+<!ENTITY unibn-nolink "<orgname>University of Bonn</orgname>">
+<!ENTITY unibn "<ulink url='http://www.uni-bonn.de/'>University of Bonn</ulink>">
+<!ENTITY tremolo "<acronym>TREMOLO</acronym>">
+<!-- pull in iso-num.ent -->
+<!-- <!ENTITY PUBLIC "ISO 8879:1986//ENTITIES Numeric and Special Graphic//EN" "ent/iso-num.ent"> -->
+]>
+<article lang="en">
+
+  <articleinfo>
+    <title>MoleCuilder User's Guide</title>
+    <authorgroup>
+      <author>
+        <firstname>Frederik</firstname>
+        <surname>Heber</surname>
+        <affiliation>
+          <!-- address is white space sensitive! -->
+          <address><email>heber@&ins-maildom;</email>
+&ins-street-address;</address>
+        </affiliation>
+      </author>
+    </authorgroup>
+
+    <date>13.08.2009</date>
+    <releaseinfo role="meta">
+      $Id$
+    </releaseinfo>
+    <copyright>
+      <year>2009</year><holder>University of Bonn</holder>
+    </copyright>
+
+    <revhistory>
+      <revision>
+        <revnumber>0.1</revnumber>
+        <date>08/13/09</date>
+        <authorinitials>heber</authorinitials>
+        <revremark>Initial version of documentation</revremark>
+      </revision>
+      <!-- could also do $ Revision $ here -->
+      <revision>
+        <revnumber>$Revision$</revnumber>
+        <date>$Date$</date>
+        <authorinitials>$Author$</authorinitials>
+        <revremark>Use CVS keywords as much as possible
+          (do <emphasis>not</emphasis> use $Log&#36;, however);
+          use many DocBook features.
+        </revremark>
+      </revision>
+      <!-- enter new revision summary above this line -->
+    </revhistory>
+
+    <abstract>
+      <para>
+        The MoleCuilder's man page describes briefly its command synopsis
+      </para>
+    </abstract>
+
+    <keywordset>
+      <keyword>MoleCuilder</keyword>
+      <keyword>molecule</keyword>
+      <keyword>builder</keyword>
+      <keyword>molecular dynamics</keyword>
+    </keywordset>
+
+  </articleinfo>
+
+  <!-- This is an example of a more or less usual unix manpage.
+  It could appear by itself in a DOCTYPE refentry.  -->
+
+  <refentry id="molecuilder">
+    <refmeta>
+      <refentrytitle>MoleCuilder</refentrytitle>
+      <manvolnum>1</manvolnum>
+    </refmeta>
+    <refnamediv>
+      <refname>molecuilder</refname>
+      <refpurpose>Manipulate molecular geometries and construct molecular systems.</refpurpose>
+    </refnamediv>
+  
+    <refsynopsisdiv>
+      <cmdsynopsis>
+        <command>molecuilder</command>
+        <arg choice ="req">
+         <replaceable>sample.conf</replaceable>
+        </arg>
+        <arg choice="req">
+         <option>-e @prefix@bin</option>
+        </arg>
+        <arg choice="opt">
+          <option>-aAbBcdDfFhHlmMnoOpPrRsStTuvV</option>
+          <option>...</option>
+        </arg>
+      </cmdsynopsis>
+    </refsynopsisdiv>
+       
+    <refsection>
+      <title>Description</title>
+      <para><command>MoleCuilder</command> is a very powerful package to manipulate nuclear geometries. It works on three different levels:</para>
+      <itemizedlist>
+        <listitem>
+          <para>Manipulating of single atoms: adding, removing, translating, changing the element, ...</para>    
+        </listitem>
+        <listitem>
+          <para>Manipulating of bonds: recognizing, measuring length/angle, scaling, fragmenting, ...</para>    
+        </listitem>
+        <listitem>
+          <para>Manipulating of single molecules: parsing atoms into a molecule, translating a molecule, calculating surface and volume of a molecule...</para>    
+        </listitem>
+        <listitem>
+          <para>Manipulating of the domain: changing the domain, specifying a periodic bounding box, centering all atoms, shifting all atoms, ...</para>    
+        </listitem>
+      </itemizedlist>
+      <para>As it is written for the command-line, it is best suited to use in scripts in order to mass-create many structures at the same time that only differ in a few key parameters.</para>
+    </refsection>  
+  
+    <refsection>
+      <title>Options</title>
+      <para>Note that multiple options may be given at the same time, i.e. we may concatenate (-a) an atom, then translate all (-t) by some vector, the center at origin (-O) and so on. </para>
+      <cmdsynopsis>
+        <arg choice="opt">
+          <option>-a</option>
+          <option> Z x y z</option>  - add atom
+        </arg>
+      </cmdsynopsis>
+      <cmdsynopsis>
+        <arg choice="opt">
+          <option>-a</option>
+          <option> <replaceable>DBOND</replaceable></option> - create adjacency graph from DBOND file.
+        </arg>
+      </cmdsynopsis>
+      <cmdsynopsis>
+        <arg choice="opt">
+          <option>-b</option>
+          <option>xx xy xz yy yz zz</option> - center atoms in domain.
+        </arg>
+      </cmdsynopsis>
+      <cmdsynopsis>
+        <arg choice="opt">
+          <option>-B</option>
+          <option>xx xy xz yy yz zz</option> - bound atoms by domain.
+        </arg>
+      </cmdsynopsis>
+      <cmdsynopsis>
+        <arg choice="opt">
+          <option>-c</option>
+          <option>x y z</option> - center atoms in rectangular domain with distance to boundary.
+        </arg>
+      </cmdsynopsis>
+      <cmdsynopsis>
+        <arg choice="opt">
+          <option>-d</option>
+          <option>x y z</option> - duplicate domain along each axis by given factor.
+        </arg>
+      </cmdsynopsis>
+      <cmdsynopsis>
+        <arg choice="opt">
+          <option>-D</option>
+          <option>distance</option> - Depth-First-Search Analysis of the system. 
+        </arg>
+      </cmdsynopsis>
+      <cmdsynopsis>
+        <arg choice="opt">
+          <option>-fF</option>
+          <option>distance order</option> - fragment the molecule in BOSSANOVA manner
+        </arg>
+      </cmdsynopsis>
+      <cmdsynopsis>
+        <arg choice="opt">
+          <option>-[h|H|?]</option> - print help.
+        </arg>
+      </cmdsynopsis>
+      <cmdsynopsis>
+        <arg choice="opt">
+          <option>-L</option>
+          <option>step0 step1 prefix</option> - linear interpolation between step0 and step1 in config file.
+        </arg>
+      </cmdsynopsis>
+      <cmdsynopsis>
+        <arg choice="opt">
+          <option>-m</option>
+          <option>[0|1]</option> - calculate(0), align in(1) Principal Axis System. 
+        </arg>
+      </cmdsynopsis>
+      <cmdsynopsis>
+        <arg choice="opt">
+          <option>-M</option>
+          <option>basis</option> - set basis to store in mpqc config files.
+        </arg>
+      </cmdsynopsis>
+      <cmdsynopsis>
+        <arg choice="opt">
+          <option>-n</option> - don't parse trajectories.
+        </arg>
+      </cmdsynopsis>
+      <cmdsynopsis>
+        <arg choice="opt">
+          <option>-o</option>
+          <option>file</option> - calculate and store convex envelope of molecule in file.
+        </arg>
+      </cmdsynopsis>
+      <cmdsynopsis>
+        <arg choice="opt">
+          <option>-O</option> center atoms in origin.
+        </arg>
+      </cmdsynopsis>
+      <cmdsynopsis>
+        <arg choice="opt">
+          <option>-p</option>
+          <option>file</option> - parse XYZ file into molecule.
+        </arg>
+      </cmdsynopsis>
+      <cmdsynopsis>
+        <arg choice="opt">
+          <option>-P</option>
+          <option>file</option> - Parse given forces file, time integrate and append as subsequent MD step.
+        </arg>
+      </cmdsynopsis>
+      <cmdsynopsis>
+        <arg choice="opt">
+          <option>-s</option>
+          <option>x y z</option> - scale all atom coordinates by the factor per axis.
+        </arg>
+      </cmdsynopsis>
+      <cmdsynopsis>
+        <arg choice="opt">
+          <option>-S</option>
+          <option>file</option> - Store temperatyre from config file in file.
+        </arg>
+      </cmdsynopsis>
+      <cmdsynopsis>
+        <arg choice="opt">
+          <option>-t</option>
+          <option>x y z</option> - translate all atoms by vector.
+        </arg>
+      </cmdsynopsis>
+      <cmdsynopsis>
+        <arg choice="opt">
+          <option>-T</option>
+          <option>x y z</option> - translate all atoms by vector in periodic domain.
+        </arg>
+      </cmdsynopsis>
+      <cmdsynopsis>
+        <arg choice="opt">
+          <option>-u</option>
+          <option>rho</option>- suspend molecular system in watery solution such that average density is rho.
+        </arg>
+      </cmdsynopsis>
+      <cmdsynopsis>
+        <arg choice="opt">
+          <option>-[v|V]</option> - print version information.
+        </arg>
+      </cmdsynopsis>
+    </refsection>
+    
+    <refsection>
+      <title>Files</title>
+      <para></para>
+      <itemizedlist>
+        <listitem>
+          <para><replaceable>sample.conf</replaceable> is the config file, which is needed as temporary storage. Must not begin with '-'.</para>    
+        </listitem>
+        <listitem>
+          <para><command>-e database_path</command> is the path to the element's database. The files are provided with <command>molecuilder</command>.</para>    
+        </listitem>
+        <listitem>
+          <para><replaceable>molecule.xyz</replaceable> is a typical XYZ file containing the geometry for a molecule.</para>    
+        </listitem>
+      </itemizedlist>
+    </refsection>  
+  
+    <refsection>
+      <title>Examples</title>
+      <para>Below a typical examples of how to use molecuilder are given.</para>
+      <itemizedlist>
+        <listitem>
+          <para><computeroutput>molecuilder sample.conf -e @prefix@ -p molecule.xyz -f 4 2.</computeroutput>
+           - creates a number of fragmented output files up to bond order 4 with bonds between atoms at most 2 length units apart.</para>   
+        </listitem>
+      </itemizedlist>
+      <itemizedlist>
+        <listitem>
+          <para><computeroutput>molecuilder sample.conf -e @prefix@ -p molecule.xyz -t -5 0. 0. -a 1 0. 0. 0.</computeroutput>
+           - parses the XYZ file <filename>molecule.xyz</filename> into the molecular system, translates the whole by (-5,0,0) and adds a hydrogen atom at the origin.</para>   
+        </listitem>
+      </itemizedlist>
+    </refsection>  
+  
+    <refsection>
+      <title>Exit Status</title>
+      <para></para>
+      <itemizedlist>
+        <listitem>
+          <para>0 - success.</para>    
+        </listitem>
+        <listitem>
+          <para>1 - failure.</para>    
+        </listitem>
+        <listitem>
+          <para>2 - adaptive refinement of fragmentation not finished.</para>    
+        </listitem>
+        <listitem>
+          <para>255 - critical failure.</para>    
+        </listitem>
+      </itemizedlist>
+    </refsection>  
+  
+    <refsection>
+      <title>Reporting Bugs</title>
+      <para>Please report any bugs you may encounter to <email>heber@&ins-maildom;</email>.</para>
+    </refsection>  
+  
+  </refentry>
+  
+</article>
Index: doc/userguide.xml
===================================================================
--- doc/userguide.xml	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ doc/userguide.xml	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,230 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<book version="5.0" xmlns="http://docbook.org/ns/docbook"
+      xmlns:xlink="http://www.w3.org/1999/xlink"
+      xmlns:xi="http://www.w3.org/2001/XInclude"
+      xmlns:svg="http://www.w3.org/2000/svg"
+      xmlns:m="http://www.w3.org/1998/Math/MathML"
+      xmlns:html="http://www.w3.org/1999/xhtml"
+      xmlns:db="http://docbook.org/ns/docbook">
+  <info>
+    <title>MoleCuilder - a Molecule Builder</title>
+
+    <author>
+      <personname><firstname>Frederik</firstname><surname>Heber</surname></personname>
+
+      <affiliation>
+        <orgname>heber@ins.uni-bonn.de</orgname>
+      </affiliation>
+    </author>
+
+    <pubdate>08/11/09</pubdate>
+  </info>
+
+  <chapter>
+    <title>Introduction</title>
+
+    <section>
+      <title>What is MoleCuilder?</title>
+
+      <para><command>MoleCuilder</command> allows to construct atomic and
+      molecular geometries by a simple point&amp;click approach, combined with
+      a powerful library of known structures. It is intended to be a
+      CAD-pendant on the nanoscale. Specific emphasis is placed on a
+      simple-to-use interface, allowing for the quick-and-dirty building of
+      molecular systems. </para>
+
+      <para>Geometries should henceforth be simulated with molecular dynamics
+      packages, that are either ab-initio or used specific empirical
+      potentials to simulate the acting quantum-mechanical forces.</para>
+
+      <section>
+        <title>Installation requirements</title>
+
+        <para>The following packages are required to build the executables
+        from its source code.</para>
+
+        <para><simplelist>
+            <member>C/C++ Compiler (such as GCC)</member>
+          </simplelist></para>
+
+        <para><simplelist>
+            <member>Gnu Scientific Library
+            (<uri>http://www.gnu.org/software/gsl/</uri>)</member>
+          </simplelist></para>
+
+        <para><simplelist>
+            <member>Qt3 (<uri>http://www.trolltech.com/</uri>)</member>
+          </simplelist>The code has been tested develeoped on Linux/GNU. It
+        was also tested with Win/Cygwin.</para>
+
+        <para>Note that there are two executables:
+        <command>molecuilder</command> and <command>molecuildergui</command>.
+        The former is the command-line interfaces which, if no commands are
+        given, launches a interactive menu in a terminal session. The latter
+        is the graphical user interface with the same functionality as the
+        command-line interface but in a different approach, explained in more
+        detail in the chapter on the <olink>GUI</olink>.</para>
+
+        <para><command>MoleCuilder</command> makes uses of GNU autotools to
+        allow for compilation on different platforms. Please be refered to the
+        INSTALL file that is included in the archive and the web
+        (<uri>http://www.gnu.org/software/autoconf</uri>).</para>
+      </section>
+
+      <section>
+        <title>License</title>
+
+        <para>As long as no other license statement is given, MoleCuilder is
+        free for user under the GNU Public License (GPL) Version 2 (see
+        <uri>www.gnu.de/documents/gpl-2.0.de.html</uri>).</para>
+      </section>
+    </section>
+  </chapter>
+
+  <chapter>
+    <title>Features</title>
+
+    <para>Basically, <command>MoleCuilder</command> parses geometries from
+    files, manipulates them and stores them again in files. The manipulation
+    can be done either via a command-line interface or via the graphical user
+    interface.</para>
+
+    <section>
+      <title>Concepts</title>
+
+      <para>In general, we divide the molecular systems into three different
+      components or scales.</para>
+
+      <orderedlist>
+        <listitem>
+          <para>Atoms</para>
+
+          <para>Atoms are the undividable objects of the molecular systems.
+          They have an element <quote>Z</quote> and three coordinates
+          <quote>(x,y,z)</quote>.</para>
+        </listitem>
+
+        <listitem>
+          <para>Molecules</para>
+
+          <para>Molecules are conglomeration of atoms, bound or unbound. They
+          contain a number of atoms and a specific center in the domain such
+          that its atoms are placed relative to this center.</para>
+        </listitem>
+
+        <listitem>
+          <para>Domain</para>
+
+          <para>The domain refers to the simulation domain. It is either
+          infinite or finite if periodic boundary conditions are to be
+          applied. In the latter case, atoms are always shifted back into the
+          domain periodically. A domain contains a number of molecules.</para>
+        </listitem>
+      </orderedlist>
+    </section>
+
+    <section>
+      <title>Command-line interface</title>
+
+      <para>The command-line interface reads options or command from the
+      command line and executes them sequentially. This may be for example:
+      Open an empty file, add 2 hydrogen at ... and add 1 oxygen at ...,
+      choose a simulation box, fill the box with this given "filler" molecule,
+      save the file. This enables the use of MoleCuilder in simple
+      script-files to create a whole range of geometries that only differ in a
+      few parameters automatically.</para>
+
+      <para>Traditionally, <command>MoleCuilder</command> operates on a single
+      configuration file which stores additional information to the pure
+      geometry such as parameters for the ab-initio computation. An example
+      for the above procedure is given below:</para>
+
+      <screen>./molecuilder sample.conf -e &lt;path_to_db&gt; -a H 0. 0. 0. -a H 0. 0.176 0. -a O 1. 0.176 0. ...
+</screen>
+
+      <para>The first argument is the executable itself, the second the
+      arbitrarilty named file <computeroutput>sample.conf</computeroutput>,
+      which may be empty, the third is the command -e immediately followed by
+      the path to the databases, then follow step by step each of the above
+      commands. A command is always introduced via a hyphen and a single
+      letter, e.g. -a for adding an atom to the system. It is followed by a
+      fixed number of options. </para>
+
+      <para><emphasis>Note that these first three arguments are always
+      mandatory.</emphasis> The databases are supplied with the archive and
+      usually installed in the same directory as the executables. The output
+      file on finish will be <computeroutput>sample.conf</computeroutput> and
+      various other formats desired.</para>
+
+      <para>Below we have divided the various features into distinct the
+      scales upon which the manipulation takes places - single atoms, multiple
+      atoms organised as molecules, and all atoms organised by their
+      containing domain - and explain in more detail.</para>
+
+      <section>
+        <title>Manipulate atoms</title>
+
+        <para>Here, we explain in detail how to add, remove atoms, change its
+        element type, scale the bond in between or measure the bond length or
+        angle.</para>
+      </section>
+
+      <section>
+        <title>Manipulate domain</title>
+
+        <para>Here, we elaborate on how to duplicate all the atoms inside the
+        domain, how the scale the coordinate system, how to center the atoms
+        with respect to certain points, how to realign them by given
+        constraints, how to mirror and most importantly how to specify the
+        domain.</para>
+      </section>
+
+      <section>
+        <title>Merge molecules</title>
+
+        <para>As we may create, add and remove molecules, there can be more
+        than one, joining of molecules into a single one can be done in a
+        number of ways which is explained in this section in greater
+        detail.</para>
+
+        <section>
+          <title>Editing molecules</title>
+
+          <para>In this category we explain how to create new empty molecules,
+          how to load them from file, how to change their names and filenames,
+          how to set them active and inactive, how to parse more atoms into a
+          given molecules and how to remove a molecule.</para>
+        </section>
+
+        <section>
+          <title>Merging molecules</title>
+
+          <para>As we may create, add and remove molecules, there can be more
+          than one, joining of molecules into a single one can be done in a
+          number of ways which is explained in this section in greater
+          detail.</para>
+        </section>
+      </section>
+    </section>
+
+    <section>
+      <title linkend="GUI">Graphical user interface</title>
+
+      <para>The main point of the GUI is that it renders the atoms and
+      molecules visually. These are either represented by the common
+      stick-and-ball-model or as tesselated molecular surfaces. Single or
+      multiple atoms and molecules can easily be accessed, activated and
+      manipulated via tables. Changes made in the tables cause immediate
+      update of the visual representation.</para>
+
+      <para>This is mostly helpful to design more advanced structures that are
+      conceptually difficult to imagine without visual aid.</para>
+
+      <section>
+        <title>The interface sections</title>
+
+        <para></para>
+      </section>
+    </section>
+  </chapter>
+</book>
Index: m4/ac_doxygen.m4
===================================================================
--- m4/ac_doxygen.m4	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ m4/ac_doxygen.m4	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,312 @@
+# This file is part of Autoconf.                       -*- Autoconf -*-
+
+# Copyright (C) 2004 Oren Ben-Kiki
+# This file is distributed under the same terms as the Autoconf macro files.
+
+# Generate automatic documentation using Doxygen. Works in concert with the
+# aminclude.m4 file and a compatible doxygen configuration file. Defines the
+# following public macros:
+#
+# DX_???_FEATURE(ON|OFF) - control the default setting fo a Doxygen feature.
+# Supported features are 'DOXYGEN' itself, 'DOT' for generating graphics,
+# 'HTML' for plain HTML, 'CHM' for compressed HTML help (for MS users), 'CHI'
+# for generating a seperate .chi file by the .chm file, and 'MAN', 'RTF',
+# 'XML', 'PDF' and 'PS' for the appropriate output formats. The environment
+# variable DOXYGEN_PAPER_SIZE may be specified to override the default 'a4wide'
+# paper size.
+#
+# By default, HTML, PDF and PS documentation is generated as this seems to be
+# the most popular and portable combination. MAN pages created by Doxygen are
+# usually problematic, though by picking an appropriate subset and doing some
+# massaging they might be better than nothing. CHM and RTF are specific for MS
+# (note that you can't generate both HTML and CHM at the same time). The XML is
+# rather useless unless you apply specialized post-processing to it.
+#
+# The macro mainly controls the default state of the feature. The use can
+# override the default by specifying --enable or --disable. The macros ensure
+# that contradictory flags are not given (e.g., --enable-doxygen-html and
+# --enable-doxygen-chm, --enable-doxygen-anything with --disable-doxygen, etc.)
+# Finally, each feature will be automatically disabled (with a warning) if the
+# required programs are missing.
+#
+# Once all the feature defaults have been specified, call DX_INIT_DOXYGEN with
+# the following parameters: a one-word name for the project for use as a
+# filename base etc., an optional configuration file name (the default is
+# 'Doxyfile', the same as Doxygen's default), and an optional output directory
+# name (the default is 'doxygen-doc').
+
+## ----------##
+## Defaults. ##
+## ----------##
+
+DX_ENV=""
+AC_DEFUN([DX_FEATURE_doc],  ON)
+AC_DEFUN([DX_FEATURE_dot],  ON)
+AC_DEFUN([DX_FEATURE_man],  OFF)
+AC_DEFUN([DX_FEATURE_html], ON)
+AC_DEFUN([DX_FEATURE_chm],  OFF)
+AC_DEFUN([DX_FEATURE_chi],  OFF)
+AC_DEFUN([DX_FEATURE_rtf],  OFF)
+AC_DEFUN([DX_FEATURE_xml],  OFF)
+AC_DEFUN([DX_FEATURE_pdf],  ON)
+AC_DEFUN([DX_FEATURE_ps],   ON)
+
+## --------------- ##
+## Private macros. ##
+## --------------- ##
+
+# DX_ENV_APPEND(VARIABLE, VALUE)
+# ------------------------------
+# Append VARIABLE="VALUE" to DX_ENV for invoking doxygen.
+AC_DEFUN([DX_ENV_APPEND], [AC_SUBST([DX_ENV], ["$DX_ENV $1='$2'"])])
+
+# DX_DIRNAME_EXPR
+# ---------------
+# Expand into a shell expression prints the directory part of a path.
+AC_DEFUN([DX_DIRNAME_EXPR],
+         [[expr ".$1" : '\(\.\)[^/]*$' \| "x$1" : 'x\(.*\)/[^/]*$']])
+
+# DX_IF_FEATURE(FEATURE, IF-ON, IF-OFF)
+# -------------------------------------
+# Expands according to the M4 (static) status of the feature.
+AC_DEFUN([DX_IF_FEATURE], [ifelse(DX_FEATURE_$1, ON, [$2], [$3])])
+
+# DX_REQUIRE_PROG(VARIABLE, PROGRAM)
+# ----------------------------------
+# Require the specified program to be found for the DX_CURRENT_FEATURE to work.
+AC_DEFUN([DX_REQUIRE_PROG], [
+AC_PATH_TOOL([$1], [$2])
+if test "$DX_FLAG_[]DX_CURRENT_FEATURE$$1" = 1; then
+    AC_MSG_WARN([$2 not found - will not DX_CURRENT_DESCRIPTION])
+    AC_SUBST([DX_FLAG_[]DX_CURRENT_FEATURE], 0)
+fi
+])
+
+# DX_TEST_FEATURE(FEATURE)
+# ------------------------
+# Expand to a shell expression testing whether the feature is active.
+AC_DEFUN([DX_TEST_FEATURE], [test "$DX_FLAG_$1" = 1])
+
+# DX_CHECK_DEPEND(REQUIRED_FEATURE, REQUIRED_STATE)
+# -------------------------------------------------
+# Verify that a required features has the right state before trying to turn on
+# the DX_CURRENT_FEATURE.
+AC_DEFUN([DX_CHECK_DEPEND], [
+test "$DX_FLAG_$1" = "$2" \
+|| AC_MSG_ERROR([doxygen-DX_CURRENT_FEATURE ifelse([$2], 1,
+                            requires, contradicts) doxygen-DX_CURRENT_FEATURE])
+])
+
+# DX_CLEAR_DEPEND(FEATURE, REQUIRED_FEATURE, REQUIRED_STATE)
+# ----------------------------------------------------------
+# Turn off the DX_CURRENT_FEATURE if the required feature is off.
+AC_DEFUN([DX_CLEAR_DEPEND], [
+test "$DX_FLAG_$1" = "$2" || AC_SUBST([DX_FLAG_[]DX_CURRENT_FEATURE], 0)
+])
+
+# DX_FEATURE_ARG(FEATURE, DESCRIPTION,
+#                CHECK_DEPEND, CLEAR_DEPEND,
+#                REQUIRE, DO-IF-ON, DO-IF-OFF)
+# --------------------------------------------
+# Parse the command-line option controlling a feature. CHECK_DEPEND is called
+# if the user explicitly turns the feature on (and invokes DX_CHECK_DEPEND),
+# otherwise CLEAR_DEPEND is called to turn off the default state if a required
+# feature is disabled (using DX_CLEAR_DEPEND). REQUIRE performs additional
+# requirement tests (DX_REQUIRE_PROG). Finally, an automake flag is set and
+# DO-IF-ON or DO-IF-OFF are called according to the final state of the feature.
+AC_DEFUN([DX_ARG_ABLE], [
+    AC_DEFUN([DX_CURRENT_FEATURE], [$1])
+    AC_DEFUN([DX_CURRENT_DESCRIPTION], [$2])
+    AC_ARG_ENABLE(doxygen-$1,
+                  [AS_HELP_STRING(DX_IF_FEATURE([$1], [--disable-doxygen-$1],
+                                                      [--enable-doxygen-$1]),
+                                  DX_IF_FEATURE([$1], [don't $2], [$2]))],
+                  [
+case "$enableval" in
+#(
+y|Y|yes|Yes|YES)
+    AC_SUBST([DX_FLAG_$1], 1)
+    $3
+;; #(
+n|N|no|No|NO)
+    AC_SUBST([DX_FLAG_$1], 0)
+;; #(
+*)
+    AC_MSG_ERROR([invalid value '$enableval' given to doxygen-$1])
+;;
+esac
+], [
+AC_SUBST([DX_FLAG_$1], [DX_IF_FEATURE([$1], 1, 0)])
+$4
+])
+if DX_TEST_FEATURE([$1]); then
+    $5
+    :
+fi
+if DX_TEST_FEATURE([$1]); then
+    AM_CONDITIONAL(DX_COND_$1, :)
+    $6
+    :
+else
+    AM_CONDITIONAL(DX_COND_$1, false)
+    $7
+    :
+fi
+])
+
+## -------------- ##
+## Public macros. ##
+## -------------- ##
+
+# DX_XXX_FEATURE(DEFAULT_STATE)
+# -----------------------------
+AC_DEFUN([DX_DOXYGEN_FEATURE], [AC_DEFUN([DX_FEATURE_doc],  [$1])])
+AC_DEFUN([DX_MAN_FEATURE],     [AC_DEFUN([DX_FEATURE_man],  [$1])])
+AC_DEFUN([DX_HTML_FEATURE],    [AC_DEFUN([DX_FEATURE_html], [$1])])
+AC_DEFUN([DX_CHM_FEATURE],     [AC_DEFUN([DX_FEATURE_chm],  [$1])])
+AC_DEFUN([DX_CHI_FEATURE],     [AC_DEFUN([DX_FEATURE_chi],  [$1])])
+AC_DEFUN([DX_RTF_FEATURE],     [AC_DEFUN([DX_FEATURE_rtf],  [$1])])
+AC_DEFUN([DX_XML_FEATURE],     [AC_DEFUN([DX_FEATURE_xml],  [$1])])
+AC_DEFUN([DX_XML_FEATURE],     [AC_DEFUN([DX_FEATURE_xml],  [$1])])
+AC_DEFUN([DX_PDF_FEATURE],     [AC_DEFUN([DX_FEATURE_pdf],  [$1])])
+AC_DEFUN([DX_PS_FEATURE],      [AC_DEFUN([DX_FEATURE_ps],   [$1])])
+
+# DX_INIT_DOXYGEN(PROJECT, [CONFIG-FILE], [OUTPUT-DOC-DIR])
+# ---------------------------------------------------------
+# PROJECT also serves as the base name for the documentation files.
+# The default CONFIG-FILE is "Doxyfile" and OUTPUT-DOC-DIR is "doxygen-doc".
+AC_DEFUN([DX_INIT_DOXYGEN], [
+
+# Files:
+AC_SUBST([DX_PROJECT], [$1])
+AC_SUBST([DX_CONFIG], [ifelse([$2], [], Doxyfile, [$2])])
+AC_SUBST([DX_DOCDIR], [ifelse([$3], [], doxygen-doc, [$3])])
+
+# Environment variables used inside doxygen.cfg:
+DX_ENV_APPEND(SRCDIR, $srcdir)
+DX_ENV_APPEND(PROJECT, $DX_PROJECT)
+DX_ENV_APPEND(DOCDIR, $DX_DOCDIR)
+DX_ENV_APPEND(VERSION, $PACKAGE_VERSION)
+
+# Doxygen itself:
+DX_ARG_ABLE(doc, [generate any doxygen documentation],
+            [],
+            [],
+            [DX_REQUIRE_PROG([DX_DOXYGEN], doxygen)
+             DX_REQUIRE_PROG([DX_PERL], perl)],
+            [DX_ENV_APPEND(PERL_PATH, $DX_PERL)])
+
+# Dot for graphics:
+DX_ARG_ABLE(dot, [generate graphics for doxygen documentation],
+            [DX_CHECK_DEPEND(doc, 1)],
+            [DX_CLEAR_DEPEND(doc, 1)],
+            [DX_REQUIRE_PROG([DX_DOT], dot)],
+            [DX_ENV_APPEND(HAVE_DOT, YES)
+             DX_ENV_APPEND(DOT_PATH, [`DX_DIRNAME_EXPR($DX_DOT)`])],
+            [DX_ENV_APPEND(HAVE_DOT, NO)])
+
+# Man pages generation:
+DX_ARG_ABLE(man, [generate doxygen manual pages],
+            [DX_CHECK_DEPEND(doc, 1)],
+            [DX_CLEAR_DEPEND(doc, 1)],
+            [],
+            [DX_ENV_APPEND(GENERATE_MAN, YES)],
+            [DX_ENV_APPEND(GENERATE_MAN, NO)])
+
+# RTF file generation:
+DX_ARG_ABLE(rtf, [generate doxygen RTF documentation],
+            [DX_CHECK_DEPEND(doc, 1)],
+            [DX_CLEAR_DEPEND(doc, 1)],
+            [],
+            [DX_ENV_APPEND(GENERATE_RTF, YES)],
+            [DX_ENV_APPEND(GENERATE_RTF, NO)])
+
+# XML file generation:
+DX_ARG_ABLE(xml, [generate doxygen XML documentation],
+            [DX_CHECK_DEPEND(doc, 1)],
+            [DX_CLEAR_DEPEND(doc, 1)],
+            [],
+            [DX_ENV_APPEND(GENERATE_XML, YES)],
+            [DX_ENV_APPEND(GENERATE_XML, NO)])
+
+# (Compressed) HTML help generation:
+DX_ARG_ABLE(chm, [generate doxygen compressed HTML help documentation],
+            [DX_CHECK_DEPEND(doc, 1)],
+            [DX_CLEAR_DEPEND(doc, 1)],
+            [DX_REQUIRE_PROG([DX_HHC], hhc)],
+            [DX_ENV_APPEND(HHC_PATH, $DX_HHC)
+             DX_ENV_APPEND(GENERATE_HTML, YES)
+             DX_ENV_APPEND(GENERATE_HTMLHELP, YES)],
+            [DX_ENV_APPEND(GENERATE_HTMLHELP, NO)])
+
+# Seperate CHI file generation.
+DX_ARG_ABLE(chi, [generate doxygen seperate compressed HTML help index file],
+            [DX_CHECK_DEPEND(chm, 1)],
+            [DX_CLEAR_DEPEND(chm, 1)],
+            [],
+            [DX_ENV_APPEND(GENERATE_CHI, YES)],
+            [DX_ENV_APPEND(GENERATE_CHI, NO)])
+
+# Plain HTML pages generation:
+DX_ARG_ABLE(html, [generate doxygen plain HTML documentation],
+            [DX_CHECK_DEPEND(doc, 1) DX_CHECK_DEPEND(chm, 0)],
+            [DX_CLEAR_DEPEND(doc, 1) DX_CLEAR_DEPEND(chm, 0)],
+            [],
+            [DX_ENV_APPEND(GENERATE_HTML, YES)],
+            [DX_TEST_FEATURE(chm) || DX_ENV_APPEND(GENERATE_HTML, NO)])
+
+# PostScript file generation:
+DX_ARG_ABLE(ps, [generate doxygen PostScript documentation],
+            [DX_CHECK_DEPEND(doc, 1)],
+            [DX_CLEAR_DEPEND(doc, 1)],
+            [DX_REQUIRE_PROG([DX_LATEX], latex)
+             DX_REQUIRE_PROG([DX_MAKEINDEX], makeindex)
+             DX_REQUIRE_PROG([DX_DVIPS], dvips)
+             DX_REQUIRE_PROG([DX_EGREP], egrep)])
+
+# PDF file generation:
+DX_ARG_ABLE(pdf, [generate doxygen PDF documentation],
+            [DX_CHECK_DEPEND(doc, 1)],
+            [DX_CLEAR_DEPEND(doc, 1)],
+            [DX_REQUIRE_PROG([DX_PDFLATEX], pdflatex)
+             DX_REQUIRE_PROG([DX_MAKEINDEX], makeindex)
+             DX_REQUIRE_PROG([DX_EGREP], egrep)])
+
+# LaTeX generation for PS and/or PDF:
+if DX_TEST_FEATURE(ps) || DX_TEST_FEATURE(pdf); then
+    AM_CONDITIONAL(DX_COND_latex, :)
+    DX_ENV_APPEND(GENERATE_LATEX, YES)
+else
+    AM_CONDITIONAL(DX_COND_latex, false)
+    DX_ENV_APPEND(GENERATE_LATEX, NO)
+fi
+
+# Paper size for PS and/or PDF:
+AC_ARG_VAR(DOXYGEN_PAPER_SIZE,
+           [a4wide (default), a4, letter, legal or executive])
+case "$DOXYGEN_PAPER_SIZE" in
+#(
+"")
+    AC_SUBST(DOXYGEN_PAPER_SIZE, "")
+;; #(
+a4wide|a4|letter|legal|executive)
+    DX_ENV_APPEND(PAPER_SIZE, $DOXYGEN_PAPER_SIZE)
+;; #(
+*)
+    AC_MSG_ERROR([unknown DOXYGEN_PAPER_SIZE='$DOXYGEN_PAPER_SIZE'])
+;;
+esac
+
+#For debugging:
+#echo DX_FLAG_doc=$DX_FLAG_doc
+#echo DX_FLAG_dot=$DX_FLAG_dot
+#echo DX_FLAG_man=$DX_FLAG_man
+#echo DX_FLAG_html=$DX_FLAG_html
+#echo DX_FLAG_chm=$DX_FLAG_chm
+#echo DX_FLAG_chi=$DX_FLAG_chi
+#echo DX_FLAG_rtf=$DX_FLAG_rtf
+#echo DX_FLAG_xml=$DX_FLAG_xml
+#echo DX_FLAG_pdf=$DX_FLAG_pdf
+#echo DX_FLAG_ps=$DX_FLAG_ps
+#echo DX_ENV=$DX_ENV
+])
Index: m4/acx_compilerflags.m4
===================================================================
--- m4/acx_compilerflags.m4	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ m4/acx_compilerflags.m4	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,48 @@
+# AC_SET_COMPILER_FLAGS(optimization, debugging, warnings)
+#----------------------------------------------------------------
+AC_DEFUN([AC_SET_COMPILER_FLAGS],[
+AC_MSG_NOTICE([Using AC@&t@_SET_COMPILER_FLAGS macro])
+
+dnl optimization
+if test ! x"$1" = xno; then
+	if test x"$2" = xno; then
+		if test x"$1" = xyes; then
+			optimization="-O2"
+		else
+			optimization="-O$1"
+		fi
+	fi
+fi
+dnl debugging info
+if ! test x"$2" = xno; then
+	if test x"$2" = xyes; then
+		debugging="-g3"
+	else
+		debugging="-g$2"
+	fi
+  AC_DEFINE(HAVE_DEBUG,1, ["Output debugging info"])
+  AC_SUBST(HAVE_DEBUG)
+fi
+
+dnl enable all warnings
+if test x"$3" = xsome; then
+	dnl even without debugging we want some minimal info of something's utterly wrong
+	Cwarnings="-Wall"
+	CXXwarnings="-Wall"
+fi
+if test x"$3" = xfull; then
+	Cwarnings="-Wall -W -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wshadow -Wpointer-arith -Wcast-align -Wcast-qual -Wwrite-strings -Wredundant-decls -Wnested-externs -Wmissing-noreturn -Wformat-security -Wmissing-format-attribute -Winit-self"
+	CXXwarnings="-Wall -W -Wshadow -Wpointer-arith -Wcast-align -Wcast-qual -Wwrite-strings -Wredundant-decls -Wmissing-noreturn -Wformat-security -Wmissing-format-attribute -Winit-self"
+fi
+if test x"$3" = xnone; then
+	unset Cwarnings
+	unset CXXwarnings
+else
+	AC_DEFINE(HAVE_WARNINGS,$enable_warnings, ["Output compiler warnings"])
+fi
+
+# finally, apply whatever was set
+CFLAGS="$CFLAGS $debugging $optimization $Cwarnings"
+CXXFLAGS="$CXXFLAGS $debugging $optimization $CXXwarnings"
+
+])
Index: m4/acx_pthread.m4
===================================================================
--- m4/acx_pthread.m4	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ m4/acx_pthread.m4	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,275 @@
+# ===========================================================================
+#              http://autoconf-archive.cryp.to/acx_pthread.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
+#
+# DESCRIPTION
+#
+#   This macro figures out how to build C programs using POSIX threads. It
+#   sets the PTHREAD_LIBS output variable to the threads library and linker
+#   flags, and the PTHREAD_CFLAGS output variable to any special C compiler
+#   flags that are needed. (The user can also force certain compiler
+#   flags/libs to be tested by setting these environment variables.)
+#
+#   Also sets PTHREAD_CC to any special C compiler that is needed for
+#   multi-threaded programs (defaults to the value of CC otherwise). (This
+#   is necessary on AIX to use the special cc_r compiler alias.)
+#
+#   NOTE: You are assumed to not only compile your program with these flags,
+#   but also link it with them as well. e.g. you should link with
+#   $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
+#
+#   If you are only building threads programs, you may wish to use these
+#   variables in your default LIBS, CFLAGS, and CC:
+#
+#          LIBS="$PTHREAD_LIBS $LIBS"
+#          CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+#          CC="$PTHREAD_CC"
+#
+#   In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
+#   has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name
+#   (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
+#
+#   ACTION-IF-FOUND is a list of shell commands to run if a threads library
+#   is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
+#   is not found. If ACTION-IF-FOUND is not specified, the default action
+#   will define HAVE_PTHREAD.
+#
+#   Please let the authors know if this macro fails on any platform, or if
+#   you have any other suggestions or comments. This macro was based on work
+#   by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
+#   from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
+#   Alejandro Forero Cuervo to the autoconf macro repository. We are also
+#   grateful for the helpful feedback of numerous users.
+#
+# LAST MODIFICATION
+#
+#   2008-04-12
+#
+# COPYLEFT
+#
+#   Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
+#
+#   This program 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 3 of the License, or (at your
+#   option) any later version.
+#
+#   This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Macro Archive. When you make and
+#   distribute a modified version of the Autoconf Macro, you may extend this
+#   special exception to the GPL to apply to your modified version as well.
+
+AC_DEFUN([ACX_PTHREAD], [
+AC_REQUIRE([AC_CANONICAL_HOST])
+AC_LANG_SAVE
+AC_LANG_C
+acx_pthread_ok=no
+
+# We used to check for pthread.h first, but this fails if pthread.h
+# requires special compiler flags (e.g. on True64 or Sequent).
+# It gets checked for in the link test anyway.
+
+# First of all, check if the user has set any of the PTHREAD_LIBS,
+# etcetera environment variables, and if threads linking works using
+# them:
+if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
+        save_CFLAGS="$CFLAGS"
+        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+        save_LIBS="$LIBS"
+        LIBS="$PTHREAD_LIBS $LIBS"
+        AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
+        AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
+        AC_MSG_RESULT($acx_pthread_ok)
+        if test x"$acx_pthread_ok" = xno; then
+                PTHREAD_LIBS=""
+                PTHREAD_CFLAGS=""
+        fi
+        LIBS="$save_LIBS"
+        CFLAGS="$save_CFLAGS"
+fi
+
+# We must check for the threads library under a number of different
+# names; the ordering is very important because some systems
+# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
+# libraries is broken (non-POSIX).
+
+# Create a list of thread flags to try.  Items starting with a "-" are
+# C compiler flags, and other items are library names, except for "none"
+# which indicates that we try without any flags at all, and "pthread-config"
+# which is a program returning the flags for the Pth emulation library.
+
+acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
+
+# The ordering *is* (sometimes) important.  Some notes on the
+# individual items follow:
+
+# pthreads: AIX (must check this before -lpthread)
+# none: in case threads are in libc; should be tried before -Kthread and
+#       other compiler flags to prevent continual compiler warnings
+# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
+# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
+# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
+# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
+# -pthreads: Solaris/gcc
+# -mthreads: Mingw32/gcc, Lynx/gcc
+# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
+#      doesn't hurt to check since this sometimes defines pthreads too;
+#      also defines -D_REENTRANT)
+#      ... -mt is also the pthreads flag for HP/aCC
+# pthread: Linux, etcetera
+# --thread-safe: KAI C++
+# pthread-config: use pthread-config program (for GNU Pth library)
+
+case "${host_cpu}-${host_os}" in
+        *solaris*)
+
+        # On Solaris (at least, for some versions), libc contains stubbed
+        # (non-functional) versions of the pthreads routines, so link-based
+        # tests will erroneously succeed.  (We need to link with -pthreads/-mt/
+        # -lpthread.)  (The stubs are missing pthread_cleanup_push, or rather
+        # a function called by this macro, so we could check for that, but
+        # who knows whether they'll stub that too in a future libc.)  So,
+        # we'll just look for -pthreads and -lpthread first:
+
+        acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
+        ;;
+esac
+
+if test x"$acx_pthread_ok" = xno; then
+for flag in $acx_pthread_flags; do
+
+        case $flag in
+                none)
+                AC_MSG_CHECKING([whether pthreads work without any flags])
+                ;;
+
+                -*)
+                AC_MSG_CHECKING([whether pthreads work with $flag])
+                PTHREAD_CFLAGS="$flag"
+                ;;
+
+		pthread-config)
+		AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
+		if test x"$acx_pthread_config" = xno; then continue; fi
+		PTHREAD_CFLAGS="`pthread-config --cflags`"
+		PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
+		;;
+
+                *)
+                AC_MSG_CHECKING([for the pthreads library -l$flag])
+                PTHREAD_LIBS="-l$flag"
+                ;;
+        esac
+
+        save_LIBS="$LIBS"
+        save_CFLAGS="$CFLAGS"
+        LIBS="$PTHREAD_LIBS $LIBS"
+        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+
+        # Check for various functions.  We must include pthread.h,
+        # since some functions may be macros.  (On the Sequent, we
+        # need a special flag -Kthread to make this header compile.)
+        # We check for pthread_join because it is in -lpthread on IRIX
+        # while pthread_create is in libc.  We check for pthread_attr_init
+        # due to DEC craziness with -lpthreads.  We check for
+        # pthread_cleanup_push because it is one of the few pthread
+        # functions on Solaris that doesn't have a non-functional libc stub.
+        # We try pthread_create on general principles.
+        AC_TRY_LINK([#include <pthread.h>],
+                    [pthread_t th; pthread_join(th, 0);
+                     pthread_attr_init(0); pthread_cleanup_push(0, 0);
+                     pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
+                    [acx_pthread_ok=yes])
+
+        LIBS="$save_LIBS"
+        CFLAGS="$save_CFLAGS"
+
+        AC_MSG_RESULT($acx_pthread_ok)
+        if test "x$acx_pthread_ok" = xyes; then
+                break;
+        fi
+
+        PTHREAD_LIBS=""
+        PTHREAD_CFLAGS=""
+done
+fi
+
+# Various other checks:
+if test "x$acx_pthread_ok" = xyes; then
+        save_LIBS="$LIBS"
+        LIBS="$PTHREAD_LIBS $LIBS"
+        save_CFLAGS="$CFLAGS"
+        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+
+        # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
+	AC_MSG_CHECKING([for joinable pthread attribute])
+	attr_name=unknown
+	for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
+	    AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],
+                        [attr_name=$attr; break])
+	done
+        AC_MSG_RESULT($attr_name)
+        if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
+            AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
+                               [Define to necessary symbol if this constant
+                                uses a non-standard name on your system.])
+        fi
+
+        AC_MSG_CHECKING([if more special flags are required for pthreads])
+        flag=no
+        case "${host_cpu}-${host_os}" in
+            *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
+            *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
+        esac
+        AC_MSG_RESULT(${flag})
+        if test "x$flag" != xno; then
+            PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
+        fi
+
+        LIBS="$save_LIBS"
+        CFLAGS="$save_CFLAGS"
+
+        # More AIX lossage: must compile with xlc_r or cc_r
+	if test x"$GCC" != xyes; then
+          AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
+        else
+          PTHREAD_CC=$CC
+	fi
+else
+        PTHREAD_CC="$CC"
+fi
+
+AC_SUBST(PTHREAD_LIBS)
+AC_SUBST(PTHREAD_CFLAGS)
+AC_SUBST(PTHREAD_CC)
+
+# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
+if test x"$acx_pthread_ok" = xyes; then
+        ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
+        :
+else
+        acx_pthread_ok=no
+        $2
+fi
+AC_LANG_RESTORE
+])dnl ACX_PTHREAD
Index: m4/ax_boost_base.m4
===================================================================
--- m4/ax_boost_base.m4	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ m4/ax_boost_base.m4	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,219 @@
+# ===========================================================================
+#          http://www.nongnu.org/autoconf-archive/ax_boost_base.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_BOOST_BASE([MINIMUM-VERSION])
+#
+# DESCRIPTION
+#
+#   Test for the Boost C++ libraries of a particular version (or newer)
+#
+#   If no path to the installed boost library is given the macro searchs
+#   under /usr, /usr/local, /opt and /opt/local and evaluates the
+#   $BOOST_ROOT environment variable. Further documentation is available at
+#   <http://randspringer.de/boost/index.html>.
+#
+#   This macro calls:
+#
+#     AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS)
+#
+#   And sets:
+#
+#     HAVE_BOOST
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved.
+
+AC_DEFUN([AX_BOOST_BASE],
+[
+AC_ARG_WITH([boost],
+	AS_HELP_STRING([--with-boost@<:@=DIR@:>@], [use boost (default is yes) - it is possible to specify the root directory for boost (optional)]),
+	[
+    if test "$withval" = "no"; then
+		want_boost="no"
+    elif test "$withval" = "yes"; then
+        want_boost="yes"
+        ac_boost_path=""
+    else
+	    want_boost="yes"
+        ac_boost_path="$withval"
+	fi
+    ],
+    [want_boost="yes"])
+
+
+AC_ARG_WITH([boost-libdir],
+        AS_HELP_STRING([--with-boost-libdir=LIB_DIR],
+        [Force given directory for boost libraries. Note that this will overwrite library path detection, so use this parameter only if default library detection fails and you know exactly where your boost libraries are located.]),
+        [
+        if test -d $withval
+        then
+                ac_boost_lib_path="$withval"
+        else
+                AC_MSG_ERROR(--with-boost-libdir expected directory name)
+        fi
+        ],
+        [ac_boost_lib_path=""]
+)
+
+if test "x$want_boost" = "xyes"; then
+	boost_lib_version_req=ifelse([$1], ,1.20.0,$1)
+	boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'`
+	boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'`
+	boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
+	boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
+	if test "x$boost_lib_version_req_sub_minor" = "x" ; then
+		boost_lib_version_req_sub_minor="0"
+    	fi
+	WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+  $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor`
+	AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req)
+	succeeded=no
+
+	dnl first we check the system location for boost libraries
+	dnl this location ist chosen if boost libraries are installed with the --layout=system option
+	dnl or if you install boost with RPM
+	if test "$ac_boost_path" != ""; then
+		BOOST_LDFLAGS="-L$ac_boost_path/lib"
+		BOOST_CPPFLAGS="-I$ac_boost_path/include"
+	else
+		for ac_boost_path_tmp in /usr /usr/local /opt /opt/local ; do
+			if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then
+				BOOST_LDFLAGS="-L$ac_boost_path_tmp/lib"
+				BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include"
+				break;
+			fi
+		done
+	fi
+
+    dnl overwrite ld flags if we have required special directory with
+    dnl --with-boost-libdir parameter
+    if test "$ac_boost_lib_path" != ""; then
+       BOOST_LDFLAGS="-L$ac_boost_lib_path"
+    fi
+
+	CPPFLAGS_SAVED="$CPPFLAGS"
+	CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
+	export CPPFLAGS
+
+	LDFLAGS_SAVED="$LDFLAGS"
+	LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
+	export LDFLAGS
+
+	AC_LANG_PUSH(C++)
+     	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+	@%:@include <boost/version.hpp>
+	]], [[
+	#if BOOST_VERSION >= $WANT_BOOST_VERSION
+	// Everything is okay
+	#else
+	#  error Boost version is too old
+	#endif
+	]])],[
+        AC_MSG_RESULT(yes)
+	succeeded=yes
+	found_system=yes
+       	],[
+       	])
+	AC_LANG_POP([C++])
+
+
+
+	dnl if we found no boost with system layout we search for boost libraries
+	dnl built and installed without the --layout=system option or for a staged(not installed) version
+	if test "x$succeeded" != "xyes"; then
+		_version=0
+		if test "$ac_boost_path" != ""; then
+			if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
+				for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
+					_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
+					V_CHECK=`expr $_version_tmp \> $_version`
+					if test "$V_CHECK" = "1" ; then
+						_version=$_version_tmp
+					fi
+					VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
+					BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE"
+				done
+			fi
+		else
+			for ac_boost_path in /usr /usr/local /opt /opt/local ; do
+				if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
+					for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
+						_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
+						V_CHECK=`expr $_version_tmp \> $_version`
+						if test "$V_CHECK" = "1" ; then
+							_version=$_version_tmp
+	               					best_path=$ac_boost_path
+						fi
+					done
+				fi
+			done
+
+			VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
+			BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE"
+            if test "$ac_boost_lib_path" = ""
+            then
+               BOOST_LDFLAGS="-L$best_path/lib"
+            fi
+
+	    		if test "x$BOOST_ROOT" != "x"; then
+				if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/lib" && test -r "$BOOST_ROOT/stage/lib"; then
+					version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'`
+					stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'`
+			        	stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'`
+					V_CHECK=`expr $stage_version_shorten \>\= $_version`
+                    if test "$V_CHECK" = "1" -a "$ac_boost_lib_path" = "" ; then
+						AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT)
+						BOOST_CPPFLAGS="-I$BOOST_ROOT"
+						BOOST_LDFLAGS="-L$BOOST_ROOT/stage/lib"
+					fi
+				fi
+	    		fi
+		fi
+
+		CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
+		export CPPFLAGS
+		LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
+		export LDFLAGS
+
+		AC_LANG_PUSH(C++)
+	     	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+		@%:@include <boost/version.hpp>
+		]], [[
+		#if BOOST_VERSION >= $WANT_BOOST_VERSION
+		// Everything is okay
+		#else
+		#  error Boost version is too old
+		#endif
+		]])],[
+        	AC_MSG_RESULT(yes)
+		succeeded=yes
+		found_system=yes
+       		],[
+	       	])
+		AC_LANG_POP([C++])
+	fi
+
+	if test "$succeeded" != "yes" ; then
+		if test "$_version" = "0" ; then
+			AC_MSG_ERROR([[We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option.  If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>. See http://randspringer.de/boost for more documentation.]])
+		else
+			AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).])
+		fi
+	else
+		AC_SUBST(BOOST_CPPFLAGS)
+		AC_SUBST(BOOST_LDFLAGS)
+		AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available])
+	fi
+
+        CPPFLAGS="$CPPFLAGS_SAVED"
+       	LDFLAGS="$LDFLAGS_SAVED"
+fi
+
+])
Index: m4/ax_boost_program_options.m4
===================================================================
--- m4/ax_boost_program_options.m4	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ m4/ax_boost_program_options.m4	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,102 @@
+# ===========================================================================
+#    http://www.nongnu.org/autoconf-archive/ax_boost_program_options.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_BOOST_PROGRAM_OPTIONS
+#
+# DESCRIPTION
+#
+#   Test for program options library from the Boost C++ libraries. The macro
+#   requires a preceding call to AX_BOOST_BASE. Further documentation is
+#   available at <http://randspringer.de/boost/index.html>.
+#
+#   This macro calls:
+#
+#     AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB)
+#
+#   And sets:
+#
+#     HAVE_BOOST_PROGRAM_OPTIONS
+#
+# LICENSE
+#
+#   Copyright (c) 2009 Thomas Porschberg <thomas@randspringer.de>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved.
+
+AC_DEFUN([AX_BOOST_PROGRAM_OPTIONS],
+[
+	AC_ARG_WITH([boost-program-options],
+		AS_HELP_STRING([--with-boost-program-options@<:@=special-lib@:>@],
+                       [use the program options library from boost - it is possible to specify a certain library for the linker
+                        e.g. --with-boost-program-options=boost_program_options-gcc-mt-1_33_1 ]),
+        [
+        if test "$withval" = "no"; then
+			want_boost="no"
+        elif test "$withval" = "yes"; then
+            want_boost="yes"
+            ax_boost_user_program_options_lib=""
+        else
+		    want_boost="yes"
+        	ax_boost_user_program_options_lib="$withval"
+		fi
+        ],
+        [want_boost="yes"]
+	)
+
+	if test "x$want_boost" = "xyes"; then
+        AC_REQUIRE([AC_PROG_CC])
+	    export want_boost
+		CPPFLAGS_SAVED="$CPPFLAGS"
+		CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
+		export CPPFLAGS
+		LDFLAGS_SAVED="$LDFLAGS"
+		LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
+		export LDFLAGS
+		AC_CACHE_CHECK([whether the Boost::Program_Options library is available],
+					   ax_cv_boost_program_options,
+					   [AC_LANG_PUSH(C++)
+ 		                AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include <boost/program_options.hpp>
+                                                          ]],
+                                  [[boost::program_options::options_description generic("Generic options");
+                                   return 0;]]),
+                           ax_cv_boost_program_options=yes, ax_cv_boost_program_options=no)
+			               	AC_LANG_POP([C++])
+		])
+		if test "$ax_cv_boost_program_options" = yes; then
+				AC_DEFINE(HAVE_BOOST_PROGRAM_OPTIONS,,[define if the Boost::PROGRAM_OPTIONS library is available])
+                  BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
+                if test "x$ax_boost_user_program_options_lib" = "x"; then
+                for libextension in `ls $BOOSTLIBDIR/libboost_program_options*.so* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_program_options.*\)\.so.*$;\1;'` `ls $BOOSTLIBDIR/libboost_program_options*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_program_options.*\)\.a*$;\1;'` ; do
+                     ax_lib=${libextension}
+				    AC_CHECK_LIB($ax_lib, exit,
+                                 [BOOST_PROGRAM_OPTIONS_LIB="-l$ax_lib"; AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB) link_program_options="yes"; break],
+                                 [link_program_options="no"])
+  				done
+                if test "x$link_program_options" != "xyes"; then
+                for libextension in `ls $BOOSTLIBDIR/boost_program_options*.dll* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_program_options.*\)\.dll.*$;\1;'` `ls $BOOSTLIBDIR/boost_program_options*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_program_options.*\)\.a*$;\1;'` ; do
+                     ax_lib=${libextension}
+				    AC_CHECK_LIB($ax_lib, exit,
+                                 [BOOST_PROGRAM_OPTIONS_LIB="-l$ax_lib"; AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB) link_program_options="yes"; break],
+                                 [link_program_options="no"])
+  				done
+                fi
+                else
+                  for ax_lib in $ax_boost_user_program_options_lib boost_program_options-$ax_boost_user_program_options_lib; do
+				      AC_CHECK_LIB($ax_lib, main,
+                                   [BOOST_PROGRAM_OPTIONS_LIB="-l$ax_lib"; AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB) link_program_options="yes"; break],
+                                   [link_program_options="no"])
+                  done
+                fi
+				if test "x$link_program_options" != "xyes"; then
+					AC_MSG_ERROR([Could not link against [$ax_lib] !])
+				fi
+		fi
+		CPPFLAGS="$CPPFLAGS_SAVED"
+    	LDFLAGS="$LDFLAGS_SAVED"
+	fi
+])
Index: m4/ax_check_gl.m4
===================================================================
--- m4/ax_check_gl.m4	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ m4/ax_check_gl.m4	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,87 @@
+dnl Available from the GNU Autoconf Macro Archive at:
+dnl http://www.gnu.org/software/ac-archive/htmldoc/ax_check_gl.html
+dnl
+AC_DEFUN([AX_CHECK_GL],
+[AC_REQUIRE([AC_PATH_X])dnl
+AC_REQUIRE([ACX_PTHREAD])dnl
+
+#
+# There isn't a reliable way to know we should use the Apple OpenGL framework
+# without a configure option.  A Mac OS X user may have installed an
+# alternative GL implementation (e.g., Mesa), which may or may not depend on X.
+#
+AC_ARG_WITH([apple-opengl-framework],
+            [AC_HELP_STRING([--with-apple-opengl-framework],
+                            [use Apple OpenGL framework (Mac OS X only)])])
+if test "X$with_apple_opengl_framework" = "Xyes"; then
+  AC_DEFINE([HAVE_APPLE_OPENGL_FRAMEWORK], [1],
+            [Use the Apple OpenGL framework.])
+  GL_LIBS="-framework OpenGL"
+else
+  AC_LANG_PUSH(C)
+
+  AX_LANG_COMPILER_MS
+  if test X$ax_compiler_ms = Xno; then
+    GL_CFLAGS="${PTHREAD_CFLAGS}"
+    GL_CXXFLAGS="${PTHREAD_CXXFLAGS}"
+    GL_LIBS="${PTHREAD_LIBS} -lm"
+  fi
+
+  #
+  # Use x_includes and x_libraries if they have been set (presumably by
+  # AC_PATH_X).
+  #
+  if test "X$no_x" != "Xyes"; then
+    if test -n "$x_includes"; then
+      GL_CFLAGS="-I${x_includes} ${GL_CFLAGS}"
+      GL_CXXFLAGS="-I${x_includes} ${GL_CXXFLAGS}"
+    fi
+    if test -n "$x_libraries"; then
+      GL_LIBS="-L${x_libraries} -lX11 ${GL_LIBS}"
+    fi
+  fi
+
+  AC_CHECK_HEADERS([windows.h])
+
+  AC_CACHE_CHECK([for OpenGL library], [ax_cv_check_gl_libgl],
+  [ax_cv_check_gl_libgl="no"
+  ax_save_CPPFLAGS="${CPPFLAGS}"
+  CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
+  CXXFLAGS="${GL_CXXFLAGS} ${CXXFLAGS}"
+  ax_save_LIBS="${LIBS}"
+  LIBS=""
+  ax_check_libs="-lopengl32 -lGL"
+  for ax_lib in ${ax_check_libs}; do
+    if test X$ax_compiler_ms = Xyes; then
+      ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'`
+    else
+      ax_try_lib="${ax_lib}"
+    fi
+    LIBS="${ax_try_lib} ${GL_LIBS} ${ax_save_LIBS}"
+    AC_LINK_IFELSE(
+    [AC_LANG_PROGRAM([[
+# if HAVE_WINDOWS_H && defined(_WIN32)
+#   include <windows.h>
+# endif
+# include <GL/gl.h>]],
+                     [[glBegin(0)]])],
+    [ax_cv_check_gl_libgl="${ax_try_lib}"; break])
+  done
+  LIBS=${ax_save_LIBS}
+  CPPFLAGS=${ax_save_CPPFLAGS}])
+
+  if test "X${ax_cv_check_gl_libgl}" = "Xno"; then
+    no_gl="yes"
+    GL_CFLAGS=""
+    GL_CXXFLAGS=""
+    GL_LIBS=""
+  else
+    GL_LIBS="${ax_cv_check_gl_libgl} ${GL_LIBS}"
+  fi
+  AC_LANG_POP(C)
+fi
+
+AC_SUBST([GL_CFLAGS])
+AC_SUBST([GL_CXXFLAGS])
+AC_SUBST([GL_LIBS])
+])dnl
Index: m4/ax_check_glu.m4
===================================================================
--- m4/ax_check_glu.m4	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ m4/ax_check_glu.m4	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,105 @@
+AC_DEFUN([AX_CHECK_GLU],
+[AC_REQUIRE([AX_CHECK_GL])dnl
+AC_REQUIRE([AC_PROG_CXX])dnl
+GLU_CFLAGS="${GL_CFLAGS}"
+GLU_CXXFLAGS="${GL_CXXFLAGS}"
+
+ax_save_CPPFLAGS="${CPPFLAGS}"
+CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
+CFLAGS="${GL_CXXFLAGS} ${CXXFLAGS}"
+AC_CHECK_HEADERS([GL/glu.h OpenGL/glu.h])
+CPPFLAGS="${ax_save_CPPFLAGS}"
+
+m4_define([AX_CHECK_GLU_PROGRAM],
+          [AC_LANG_PROGRAM([[
+# if defined(HAVE_WINDOWS_H) && defined(_WIN32)
+#   include <windows.h>
+# endif
+# ifdef HAVE_GL_GLU_H
+#   include <GL/glu.h>
+# elif defined(HAVE_OPENGL_GLU_H)
+#   include <OpenGL/glu.h>
+# else
+#   error no glu.h
+# endif]],
+                          [[gluBeginCurve(0)]])])
+
+AC_CACHE_CHECK([for OpenGL Utility library], [ax_cv_check_glu_libglu],
+[ax_cv_check_glu_libglu="no"
+ax_save_CPPFLAGS="${CPPFLAGS}"
+CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
+CXXFLAGS="${GL_CXXFLAGS} ${CXXFLAGS}"
+ax_save_LIBS="${LIBS}"
+
+#
+# First, check for the possibility that everything we need is already in
+# GL_LIBS.
+#
+LIBS="${GL_LIBS} ${ax_save_LIBS}"
+#
+# libGLU typically links with libstdc++ on POSIX platforms.
+# However, setting the language to C++ means that test program
+# source is named "conftest.cc"; and Microsoft cl doesn't know what
+# to do with such a file.
+#
+AC_LANG_PUSH([C++])
+AS_IF([test X$ax_compiler_ms = Xyes],
+      [AC_LANG_PUSH([C])])
+AC_LINK_IFELSE(
+[AX_CHECK_GLU_PROGRAM],
+[ax_cv_check_glu_libglu=yes],
+[LIBS=""
+ax_check_libs="-lglu32 -lGLU"
+for ax_lib in ${ax_check_libs}; do
+  AS_IF([test X$ax_compiler_ms = Xyes],
+        [ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'`],
+        [ax_try_lib="${ax_lib}"])
+  LIBS="${ax_try_lib} ${GL_LIBS} ${ax_save_LIBS}"
+  AC_LINK_IFELSE([AX_CHECK_GLU_PROGRAM],
+                 [ax_cv_check_glu_libglu="${ax_try_lib}"; break])
+done
+])
+AS_IF([test X$ax_compiler_ms = Xyes],
+      [AC_LANG_POP([C])])
+AC_LANG_POP([C++])
+
+LIBS=${ax_save_LIBS}
+CPPFLAGS=${ax_save_CPPFLAGS}])
+AS_IF([test "X$ax_cv_check_glu_libglu" = Xno],
+      [no_glu=yes; GLU_CFLAGS=""; GLU_CXXFLAGS=""; GLU_LIBS=""],
+      [AS_IF([test "X$ax_cv_check_glu_libglu" = Xyes],
+             [GLU_LIBS="$GL_LIBS"],
+             [GLU_LIBS="${ax_cv_check_glu_libglu} ${GL_LIBS}"])])
+AC_SUBST([GLU_CFLAGS])
+AC_SUBST([GLU_CXXFLAGS])
+AC_SUBST([GLU_LIBS])
+
+#
+# Some versions of Mac OS X include a broken interpretation of the GLU
+# tesselation callback function signature.
+#
+AS_IF([test "X$ax_cv_check_glu_libglu" != Xno],
+[AC_CACHE_CHECK([for varargs GLU tesselator callback function type],
+                [ax_cv_varargs_glu_tesscb],
+[ax_cv_varargs_glu_tesscb=no
+ax_save_CFLAGS="${CFLAGS}"
+ax_save_CXXFLAGS="${CXXFLAGS}"
+CFLAGS="${GL_CFLAGS} ${CFLAGS}"
+CXXFLAGS="${GL_CXXFLAGS} ${CXXFLAGS}"
+AC_COMPILE_IFELSE(
+[AC_LANG_PROGRAM([[
+# ifdef HAVE_GL_GLU_H
+#   include <GL/glu.h>
+# else
+#   include <OpenGL/glu.h>
+# endif]],
+                 [[GLvoid (*func)(...); gluTessCallback(0, 0, func)]])],
+[ax_cv_varargs_glu_tesscb=yes])
+CFLAGS="$ax_save_CFLAGS"]
+CXXFLAGS="$ax_save_CXXFLAGS"]))
+AS_IF([test X$ax_cv_varargs_glu_tesscb = Xyes],
+      [AC_DEFINE([HAVE_VARARGS_GLU_TESSCB], [1],
+                 [Use nonstandard varargs form for the GLU tesselator callback])])
+])
+])
+
Index: m4/ax_lang_compiler_ms.m4
===================================================================
--- m4/ax_lang_compiler_ms.m4	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ m4/ax_lang_compiler_ms.m4	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,37 @@
+# ===========================================================================
+#    http://www.gnu.org/software/autoconf-archive/ax_lang_compiler_ms.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_LANG_COMPILER_MS
+#
+# DESCRIPTION
+#
+#   Check whether the compiler for the current language is Microsoft.
+#
+#   This macro is modeled after _AC_LANG_COMPILER_GNU in the GNU Autoconf
+#   implementation.
+#
+# LICENSE
+#
+#   Copyright (c) 2009 Braden McDaniel <braden@endoframe.com>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 8
+
+AC_DEFUN([AX_LANG_COMPILER_MS],
+[AC_CACHE_CHECK([whether we are using the Microsoft _AC_LANG compiler],
+                [ax_cv_[]_AC_LANG_ABBREV[]_compiler_ms],
+[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[#ifndef _MSC_VER
+       choke me
+#endif
+]])],
+                   [ax_compiler_ms=yes],
+                   [ax_compiler_ms=no])
+ax_cv_[]_AC_LANG_ABBREV[]_compiler_ms=$ax_compiler_ms
+])])
Index: m4/cppunit.m4
===================================================================
--- m4/cppunit.m4	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ m4/cppunit.m4	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,92 @@
+dnl
+dnl AM_PATH_CPPUNIT(MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
+dnl
+AC_DEFUN([AM_PATH_CPPUNIT],
+[
+
+AC_ARG_WITH(cppunit-prefix,[  --with-cppunit-prefix=PFX   Prefix where CppUnit is installed (optional)],
+            cppunit_config_prefix="$withval", cppunit_config_prefix="")
+AC_ARG_WITH(cppunit-exec-prefix,[  --with-cppunit-exec-prefix=PFX  Exec prefix where CppUnit is installed (optional)],
+            cppunit_config_exec_prefix="$withval", cppunit_config_exec_prefix="")
+
+  if test x$cppunit_config_exec_prefix != x ; then
+     cppunit_config_args="$cppunit_config_args --exec-prefix=$cppunit_config_exec_prefix"
+     if test x${CPPUNIT_CONFIG+set} != xset ; then
+        CPPUNIT_CONFIG=$cppunit_config_exec_prefix/bin/cppunit-config
+     fi
+  fi
+  if test x$cppunit_config_prefix != x ; then
+     cppunit_config_args="$cppunit_config_args --prefix=$cppunit_config_prefix"
+     if test x${CPPUNIT_CONFIG+set} != xset ; then
+        CPPUNIT_CONFIG=$cppunit_config_prefix/bin/cppunit-config
+     fi
+  fi
+
+  AC_PATH_PROG(CPPUNIT_CONFIG, cppunit-config, no)
+  cppunit_version_min=$1
+
+  AC_MSG_CHECKING(for Cppunit - version >= $cppunit_version_min)
+  no_cppunit=""
+  if test "$CPPUNIT_CONFIG" = "no" ; then
+    AC_MSG_RESULT(no)
+    no_cppunit=yes
+  else
+    CPPUNIT_CFLAGS=`$CPPUNIT_CONFIG --cflags`
+    CPPUNIT_LIBS=`$CPPUNIT_CONFIG --libs`
+    cppunit_version=`$CPPUNIT_CONFIG --version`
+
+    cppunit_major_version=`echo $cppunit_version | \
+           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
+    cppunit_minor_version=`echo $cppunit_version | \
+           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
+    cppunit_micro_version=`echo $cppunit_version | \
+           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
+
+    cppunit_major_min=`echo $cppunit_version_min | \
+           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
+    if test "x${cppunit_major_min}" = "x" ; then
+       cppunit_major_min=0
+    fi
+    
+    cppunit_minor_min=`echo $cppunit_version_min | \
+           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
+    if test "x${cppunit_minor_min}" = "x" ; then
+       cppunit_minor_min=0
+    fi
+    
+    cppunit_micro_min=`echo $cppunit_version_min | \
+           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
+    if test "x${cppunit_micro_min}" = "x" ; then
+       cppunit_micro_min=0
+    fi
+
+    cppunit_version_proper=`expr \
+        $cppunit_major_version \> $cppunit_major_min \| \
+        $cppunit_major_version \= $cppunit_major_min \& \
+        $cppunit_minor_version \> $cppunit_minor_min \| \
+        $cppunit_major_version \= $cppunit_major_min \& \
+        $cppunit_minor_version \= $cppunit_minor_min \& \
+        $cppunit_micro_version \>= $cppunit_micro_min `
+
+    if test "$cppunit_version_proper" = "1" ; then
+      AC_MSG_RESULT([$cppunit_major_version.$cppunit_minor_version.$cppunit_micro_version])
+    else
+      AC_MSG_RESULT(no)
+      no_cppunit=yes
+    fi
+  fi
+
+  if test "x$no_cppunit" = x ; then
+     ifelse([$2], , :, [$2])     
+  else
+     CPPUNIT_CFLAGS=""
+     CPPUNIT_LIBS=""
+     ifelse([$3], , :, [$3])
+  fi
+
+  AC_SUBST(CPPUNIT_CFLAGS)
+  AC_SUBST(CPPUNIT_LIBS)
+])
+
+
+
Index: m4/gwqt4.m4
===================================================================
--- m4/gwqt4.m4	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ m4/gwqt4.m4	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,193 @@
+# Check for Qt compiler flags, linker flags, and binary packages
+AC_DEFUN([gw_CHECK_QT4],
+[
+AC_REQUIRE([AC_PROG_CXX])
+AC_REQUIRE([AC_PATH_X])
+
+AC_MSG_CHECKING([QTDIR])
+AC_ARG_WITH([qtdir], [  --with-qtdir=DIR        Qt installation directory [default=$QTDIR]], QTDIR=$withval)
+# Check that QTDIR is defined or that --with-qtdir given
+if test x"$QTDIR" = x ; then
+	# some usual Qt-locations
+	QT_SEARCH="/usr /usr/lib/qt /usr/X11R6 /usr/local/Trolltech/Qt-4.0.0 /usr/local/Trolltech/Qt-4.0.1 /usr/local/Trolltech/Qt-4.1.0 /usr/local/Trolltech/Qt-4.2.0 /usr/local/Trolltech/Qt-4.2.1 /usr/local/Trolltech/Qt-4.2.2"
+else
+	QT_SEARCH=$QTDIR
+	QTDIR=""
+fi
+for i in $QT_SEARCH ; do
+	QT_INCLUDE_SEARCH="include/qt4 include"
+	for j in $QT_INCLUDE_SEARCH ; do
+	        if test -f $i/$j/Qt/qglobal.h -a x$QTDIR = x ; then
+			QTDIR=$i
+			QT_INCLUDES=$i/$j
+		fi
+	done
+done
+if test x"$QTDIR" = x ; then
+	AC_MSG_ERROR([*** QTDIR must be defined, or --with-qtdir option given])
+fi
+AC_MSG_RESULT([$QTDIR])
+
+# Change backslashes in QTDIR to forward slashes to prevent escaping
+# problems later on in the build process, mainly for Cygwin build
+# environment using MSVC as the compiler
+QTDIR=`echo $QTDIR | sed 's/\\\\/\\//g'`
+
+AC_MSG_CHECKING([Qt includes])
+# Check where includes are located
+if test x"$QT_INCLUDES" = x ; then
+	AC_MSG_ERROR([*** could not find Qt-includes! Make sure you have the Qt-devel-files installed!])
+fi
+AC_MSG_RESULT([$QT_INCLUDES])
+
+
+if test -z "$QTHOSTDIR" ; then
+	case "${prefix}" in
+		/opt/mingw*)
+			QTHOSTDIR=/usr
+			;;
+		*)
+			if test -n "$QTDIR" ; then
+				QTHOSTDIR="$QTDIR"
+			else
+				QTHOSTDIR=/usr
+			fi
+			;;
+	esac
+fi
+
+
+# Check that moc is in path
+AC_CHECK_PROG(MOC, moc-qt4, $QTHOSTDIR/bin/moc-qt4,,$QTHOSTDIR/bin/)
+if test x$MOC = x ; then
+	AC_CHECK_PROG(MOC, moc, $QTHOSTDIR/bin/moc,,$QTHOSTDIR/bin/)
+	if test x$MOC = x ; then
+        	AC_MSG_ERROR([*** not found! Make sure you have Qt-devel-tools installed!])
+	fi
+fi
+
+# Check that uic is in path
+AC_CHECK_PROG(UIC, uic-qt4, $QTHOSTDIR/bin/uic-qt4,,$QTHOSTDIR/bin/)
+if test x$UIC = x ; then
+	AC_CHECK_PROG(UIC, uic, $QTHOSTDIR/bin/uic,,$QTHOSTDIR/bin/)
+	if test x$UIC = x ; then
+        	AC_MSG_ERROR([*** not found! Make sure you have Qt-devel-tools installed!])
+	fi
+fi
+
+# lupdate is the Qt translation-update utility.
+AC_CHECK_PROG(LUPDATE, lupdate-qt4, $QTHOSTDIR/bin/lupdate-qt4,,$QTHOSTDIR/bin/)
+if test x$LUPDATE = x ; then
+	AC_CHECK_PROG(LUPDATE, lupdate, $QTHOSTDIR/bin/lupdate,,$QTHOSTDIR/bin/)
+	if test x$MOC = x ; then
+	        AC_MSG_WARN([*** not found! It's not needed just for compiling but should be part of a proper Qt-devel-tools-installation!])
+	fi
+fi
+
+# lrelease is the Qt translation-release utility.
+AC_CHECK_PROG(LRELEASE, lrelease-qt4, $QTHOSTDIR/bin/lrelease-qt4,,$QTHOSTDIR/bin/)
+if test x$LRELEASE = x ; then
+	AC_CHECK_PROG(LRELEASE, lrelease, $QTHOSTDIR/bin/lrelease,,$QTHOSTDIR/bin/)
+	if test x$MOC = x ; then
+	        AC_MSG_WARN([*** not found! It's not needed just for compiling but should be part of a proper Qt-devel-tools-installation!])
+	fi
+fi
+
+# Calculate Qt include path
+QT_CXXFLAGS="-I$QT_INCLUDES -I$QT_INCLUDES/Qt"
+
+# On unix, figure out if we're doing a static or dynamic link
+case "${host}" in
+      *mingw32)
+        QT_IS_STATIC=`ls $QTDIR/lib/*.a 2> /dev/null`
+       	if test "x$QT_IS_STATIC" = x; then
+            QT_IS_STATIC="no"
+       	else
+            QT_IS_STATIC="yes"
+        fi
+        if test x$QT_IS_STATIC = xno ; then
+            QT_IS_DYNAMIC=`ls $QTDIR/lib/*.so 2> /dev/null` 
+            if test "x$QT_IS_DYNAMIC" = x;  then
+                AC_MSG_ERROR([*** Couldn't find any Qt libraries])
+            fi
+        fi
+	QT_LIB="-L$QTDIR/bin -lQtCore4 -lQtXml4 -lQtNetwork4 -lws2_32"
+	QT_LIB_GUI="-lQtGui4"
+	# Check that windres is in path
+	AC_PATH_PROGS([WINDRES],[i586-mingw32-windres windres],,[${prefix}/bin:$PATH])
+	if test x$WINDRES = x ; then
+		AC_MSG_ERROR([*** not found! Make sure you have binutils installed!])
+	fi
+        ;;
+    *)
+        QT_IS_STATIC=`ls $QTDIR/lib/*.a 2> /dev/null`
+       	if test "x$QT_IS_STATIC" = x; then
+            QT_IS_STATIC="no"
+       	else
+            QT_IS_STATIC="yes"
+        fi
+        if test x$QT_IS_STATIC = xno ; then
+            QT_IS_DYNAMIC=`ls $QTDIR/lib/*.so 2> /dev/null` 
+            if test "x$QT_IS_DYNAMIC" = x;  then
+                AC_MSG_ERROR([*** Couldn't find any Qt libraries])
+            fi
+        fi
+	QT_LIB="-L$QTDIR/lib -L$QTDIR/lib/qt4 -lQtCore -lQtXml -lQtNetwork"
+	QT_LIB_GUI="-lQtGui"
+        ;;
+esac
+AC_MSG_CHECKING([if Qt is static])
+AC_MSG_RESULT([$QT_IS_STATIC])
+
+QT_LIBS="$QT_LIB"
+
+
+case "${host}" in
+    *irix*)
+        QT_LIBS="$QT_LIB"
+        if test $QT_IS_STATIC = yes ; then
+            QT_LIBS="$QT_LIBS -L$x_libraries -lXext -lX11 -lm -lSM -lICE"
+        fi
+        ;;
+
+    *linux*)
+        QT_LIBS="$QT_LIB"
+        if test $QT_IS_STATIC = yes ; then
+            QT_LIBS="$QT_LIBS -L$x_libraries -lXext -lX11 -lm -lSM -lICE -ldl"
+        fi
+        ;;
+
+    *osf*) 
+        # Digital Unix (aka DGUX aka Tru64)
+        QT_LIBS="$QT_LIB"
+        if test $QT_IS_STATIC = yes ; then
+            QT_LIBS="$QT_LIBS -L$x_libraries -lXext -lX11 -lm -lSM -lICE"
+        fi
+        ;;
+
+    *solaris*)
+        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"
+        fi
+        ;;
+
+esac
+
+
+QT_CXXFLAGS="$QT_CXXFLAGS -D_REENTRANT -DQT_NO_DEBUG -DQT_THREAD_SUPPORT"
+
+QT_LDADD="$QT_LIBS"
+
+AC_MSG_CHECKING([QT_CXXFLAGS])
+AC_MSG_RESULT([$QT_CXXFLAGS])
+AC_MSG_CHECKING([QT_LDADD])
+AC_MSG_RESULT([$QT_LDADD])
+
+AC_SUBST(QT_CXXFLAGS)
+AC_SUBST(QT_LDADD)
+AC_SUBST(QT_LIB_GUI)
+
+])
+
+
Index: m4/m4_ax_boost_thread.m4
===================================================================
--- m4/m4_ax_boost_thread.m4	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ m4/m4_ax_boost_thread.m4	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,146 @@
+# ===========================================================================
+#         http://www.nongnu.org/autoconf-archive/ax_boost_thread.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_BOOST_THREAD
+#
+# DESCRIPTION
+#
+#   Test for Thread library from the Boost C++ libraries. The macro requires
+#   a preceding call to AX_BOOST_BASE. Further documentation is available at
+#   <http://randspringer.de/boost/index.html>.
+#
+#   This macro calls:
+#
+#     AC_SUBST(BOOST_THREAD_LIB)
+#
+#   And sets:
+#
+#     HAVE_BOOST_THREAD
+#
+# LICENSE
+#
+#   Copyright (c) 2009 Thomas Porschberg <thomas@randspringer.de>
+#   Copyright (c) 2009 Michael Tindal
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 14
+
+AC_DEFUN([AX_BOOST_THREAD],
+[
+	AC_ARG_WITH([boost-thread],
+	AS_HELP_STRING([--with-boost-thread@<:@=special-lib@:>@],
+                   [use the Thread library from boost - it is possible to specify a certain library for the linker
+                        e.g. --with-boost-thread=boost_thread-gcc-mt ]),
+        [
+        if test "$withval" = "no"; then
+			want_boost="no"
+        elif test "$withval" = "yes"; then
+            want_boost="yes"
+            ax_boost_user_thread_lib=""
+        else
+		    want_boost="yes"
+        	ax_boost_user_thread_lib="$withval"
+		fi
+        ],
+        [want_boost="yes"]
+	)
+
+	if test "x$want_boost" = "xyes"; then
+        AC_REQUIRE([AC_PROG_CC])
+        AC_REQUIRE([AC_CANONICAL_BUILD])
+		CPPFLAGS_SAVED="$CPPFLAGS"
+		CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
+		export CPPFLAGS
+
+		LDFLAGS_SAVED="$LDFLAGS"
+		LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
+		export LDFLAGS
+
+        AC_CACHE_CHECK(whether the Boost::Thread library is available,
+					   ax_cv_boost_thread,
+        [AC_LANG_PUSH([C++])
+			 CXXFLAGS_SAVE=$CXXFLAGS
+
+			 if test "x$build_os" = "xsolaris" ; then
+  				 CXXFLAGS="-pthreads $CXXFLAGS"
+			 elif test "x$build_os" = "xming32" ; then
+				 CXXFLAGS="-mthreads $CXXFLAGS"
+			 else
+				CXXFLAGS="-pthread $CXXFLAGS"
+			 fi
+			 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include <boost/thread/thread.hpp>]],
+                                   [[boost::thread_group thrds;
+                                   return 0;]]),
+                   ax_cv_boost_thread=yes, ax_cv_boost_thread=no)
+			 CXXFLAGS=$CXXFLAGS_SAVE
+             AC_LANG_POP([C++])
+		])
+		if test "x$ax_cv_boost_thread" = "xyes"; then
+           if test "x$build_os" = "xsolaris" ; then
+			  BOOST_CPPFLAGS="-pthreads $BOOST_CPPFLAGS"
+		   elif test "x$build_os" = "xming32" ; then
+			  BOOST_CPPFLAGS="-mthreads $BOOST_CPPFLAGS"
+		   else
+			  BOOST_CPPFLAGS="-pthread $BOOST_CPPFLAGS"
+		   fi
+
+			AC_SUBST(BOOST_CPPFLAGS)
+
+			AC_DEFINE(HAVE_BOOST_THREAD,,[define if the Boost::Thread library is available])
+            BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
+
+			LDFLAGS_SAVE=$LDFLAGS
+                        case "x$build_os" in
+                          *bsd* )
+                               LDFLAGS="-pthread $LDFLAGS"
+                          break;
+                          ;;
+                        esac
+            if test "x$ax_boost_user_thread_lib" = "x"; then
+                for libextension in `ls $BOOSTLIBDIR/libboost_thread*.so* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_thread.*\)\.so.*$;\1;'` `ls $BOOSTLIBDIR/libboost_thread*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_thread.*\)\.a*$;\1;'`; do
+                     ax_lib=${libextension}
+				    AC_CHECK_LIB($ax_lib, exit,
+                                 [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break],
+                                 [link_thread="no"])
+  				done
+                if test "x$link_thread" != "xyes"; then
+                for libextension in `ls $BOOSTLIBDIR/boost_thread*.dll* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_thread.*\)\.dll.*$;\1;'` `ls $BOOSTLIBDIR/boost_thread*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_thread.*\)\.a*$;\1;'` ; do
+                     ax_lib=${libextension}
+				    AC_CHECK_LIB($ax_lib, exit,
+                                 [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break],
+                                 [link_thread="no"])
+  				done
+                fi
+
+            else
+               for ax_lib in $ax_boost_user_thread_lib boost_thread-$ax_boost_user_thread_lib; do
+				      AC_CHECK_LIB($ax_lib, exit,
+                                   [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break],
+                                   [link_thread="no"])
+                  done
+
+            fi
+			if test "x$link_thread" = "xno"; then
+				AC_MSG_ERROR(Could not link against $ax_lib !)
+                        else
+                           case "x$build_os" in
+                              *bsd* )
+			        BOOST_LDFLAGS="-pthread $BOOST_LDFLAGS"
+                              break;
+                              ;;
+                           esac
+
+			fi
+		fi
+
+		CPPFLAGS="$CPPFLAGS_SAVED"
+    	LDFLAGS="$LDFLAGS_SAVED"
+	fi
+])
Index: src/Actions/Action.cpp
===================================================================
--- src/Actions/Action.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/Action.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,69 @@
+/*
+ * Action.cpp
+ *
+ *  Created on: Dec 8, 2009
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include <string>
+
+#include "Actions/Action.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Actions/ActionHistory.hpp"
+#include "Helpers/MemDebug.hpp"
+
+using namespace std;
+
+Action::state_ptr getEmptyState() {
+  return Action::state_ptr(Memory::ignore(new ActionState()));
+}
+
+// An empty state to indicate success
+Action::state_ptr Action::success = getEmptyState();
+Action::state_ptr Action::failure = getEmptyState();
+
+Action::Action(std::string _name,bool _doRegister) :
+name(_name)
+{
+  if(_doRegister){
+    ActionRegistry::getInstance().registerAction(this);
+  }
+}
+
+Action::~Action()
+{}
+
+const string Action::getName(){
+  return name;
+}
+
+void Action::call(){
+  if(!isActive()){
+    return;
+  }
+  // forward to private virtual
+  state_ptr state = performCall();
+  if(shouldUndo() && state != failure){
+    if(canUndo()){
+      ActionHistory::getInstance().addElement(this,state);
+    }
+    else{
+      ActionHistory::getInstance().clear();
+    }
+  }
+}
+Action::state_ptr Action::undo(state_ptr _state) {
+  // forward to private virtual
+  return performUndo(_state);
+}
+Action::state_ptr Action::redo(state_ptr _state) {
+  // forward to private virtual
+  return performRedo(_state);
+}
+
+
+bool Action::isActive(){
+  return true;
+}
Index: src/Actions/Action.hpp
===================================================================
--- src/Actions/Action.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/Action.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,381 @@
+/*
+ * Action.h
+ *
+ *  Created on: Dec 8, 2009
+ *      Author: crueger
+ */
+
+#ifndef ACTION_H_
+#define ACTION_H_
+
+#include <string>
+#include <boost/shared_ptr.hpp>
+
+// forward declaration
+
+class ActionState;
+class ActionSequence;
+
+/**
+ * @file
+ * <H1> Action Howto </H1>
+ *
+ * <H2> Introduction </H2>
+ *
+ * Actions are used in object oriented design as a replacement for callback functions.
+ * In most ways Actions can be used in the same way that callbacks were used in non
+ * OO-Systems, but can contain support for several extra mechanism such as undo/redo
+ * or progress indicators.
+ *
+ * The main purpose of an action class is to contain small procedures, that can be repeatedly
+ * called. These procedures can also be stored, passed around, so that the execution of an
+ * action can happen quite far away from the place of creation. For a detailed description of
+ * the Action pattern see GOF:1996.
+ *
+ * <H3> How to use an action </H3>
+ *
+ * The process of using an action is as easy as calling the call() method of the action. The
+ * action will then do whatever it is supposed to do. If it is an action that can be undone, it
+ * will also register itself in the history to make itself available for undo. To undo the last
+ * action, you can either use the undoLast() method inside the ActionHistory class or call the
+ * UndoAction also provided by the ActionHistory. If an action was undone it will be available for
+ * redo, using the redoLast() method of the ActionHistory or the RedoAction also provided by this
+ * class. To check whether undo/redo is available at any moment you can use the hasUndo() or
+ * hasRedo() method respectively.
+ *
+ * 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
+ * UndoAction will set itself to inactive, when there is no action at that time that can be undone.
+ * Using call() on an inactive Action results in a no-op. You can query the state of an action using
+ * the isActive() method.
+ *
+ * The undo capabilities of actions come in three types as signaled by two boolean flags (one
+ * combination of these flags is left empty as can be seen later).
+ * <ul>
+ * <li/> The first flag indicates if the undo mechanism for this action should be considered at all, i.e.
+ *   if the state of the application changes in a way that needs to be reverted. Actions that should
+ *   consider the undo mechanism are for example adding a molecule, moving atoms, changing
+ *   the name of a molecule etc. Changing the View-Area on the other hand should be an action that
+ *   does not consider the undo mechanism. This flag can be queried using the shouldUndo() method.
+ *
+ * <li/> The second flag indicates whether the changes can be undo for this action. If this flag is true
+ *   the action will be made available for undo using the ActionHistory class and the actions of this
+ *   class. If this flag is false while the shoudlUndo() flag is true this means that this action
+ *   changes the state of the application changes in a way that cannot be undone, but might cause
+ *   the undo of previous actions to fail. In this case the whole History is cleared, as to keep
+ *   the state of the application intact by avoiding dangerous undos. This flag can be queried
+ *   using the canUndo() method.
+ *</ul>
+ *
+ * Each action has a name, that can be used to identify it throughout the run of the application.
+ * This name can be retrieved using the getName() method. Most actions also register themselves with
+ * a global structure, called the ActionRegistry. Actions that register themselves need to have a
+ * unique name for the whole application. If the name is known these actions can be retrieved from
+ * the registry by their name and then be used as normal.
+ *
+ * <H2> Building your own actions </H2>
+ *
+ * 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 shouldUndo() and canUndo() methods to return the appropriate flags.
+ *
+ * The constructor of your derived class also needs to call the Base constructor, passing it the
+ * name of the Action and a flag indicating whether this action should be made available in the
+ * registry. WARNING: Do not use the virtual getName() method of the derived action to provide the
+ * constructor with the name, even if you overloaded this method to return a constant. Doing this
+ * will most likely not do what you think it does (see: http://www.parashift.com/c++-faq-lite/strange-inheritance.html#faq-23.5
+ * if you want to know why this wont work)
+ *
+ * <H3> Interfacing your Action with the Undo mechanism </H3>
+ *
+ * The performX() methods need to comply to a simple standard to allow for undo and redo. The first
+ * convention in this standard concerns the return type. All methods that handle calling, undoing
+ * or redoing return an object of Action::state_ptr. This is a smart pointer to a State object, that
+ * can be used to store state information that is needed by your action for later redo. A rename
+ * Action for example would need to store which object has been renamed and what the old name was.
+ * A move Action on the other hand would need to store the object that has been moved as well as the
+ * old position. If your Action does not need to store any kind of information for redo you can
+ * simply return Action::success and skip the rest of this paragraph. If your action has been
+ * abborted you can return Action::failure, which indicates to the history mechanism that this
+ * action should not be stored.
+ *
+ * If your Action needs any kind of information to undo its execution, you need to store this
+ * information in the state that is returned by the performCall() method. Since no assumptions
+ * can be made on the type or amount of information the ActionState base class is left empty.
+ * To use this class you need to derive a YourActionState class from the ActionState base class
+ * adding your data fields and accessor functions. Upon undo the ActionState object produced
+ * by the corresponding performCall() is then passed to the performUndo() method which should
+ * typecast the ActionState to the appropriate sub class, undo all the changes and produce
+ * a State object that can be used to redo the action if neccessary. This new state object is
+ * then used if the redo mechanism is invoked and passed to the performRedo() function, which
+ * again produces a State that can be used for performUndo().
+ *
+ * <H3> Outline of the implementation of Actions </H3>
+ *
+ * To sum up the actions necessary to build actions here is a brief outline of things methioned
+ * in the last paragraphs:
+ *
+ * <H4> Basics </H4>
+ *
+ * <ul>
+ *  <li/> derive YourAction from Action
+ *  <li/> pass name and flag for registry to the base constructor
+ *  <li/> implement performCall(), performUndo(), performRedo()
+ *  <li/> implement the functions that return the flags for the undo mechanism
+ *  <li/> Derive YourActionState from ActionState as necessary
+ * </ul>
+ *
+ * <H4> Implementing performX() methods </H4>
+ *
+ * <ul>
+ *  <li/> performCall():
+ *  <ul>
+ *   <li/> do whatever is needed to make the action work
+ *   <li/> if the action was abborted return Action::failure
+ *   <li/> if the action needs to save a state return a custom state object
+ *   <li/> otherwise return Action::success
+ *  </ul>
+ *  <li/> performUndo():
+ *  <ul>
+ *   <li/> typecast the ActionState pointer to a Pointer to YourActionState if necessary
+ *   <li/> undo the action using the information from the state
+ *   <li/> produce a new state that can be used for redoing and return it
+ *  </ul>
+ *  <li/> performRedo():
+ *  <ul>
+ *   <li/> take the ActionState produced by performUndo and typecast it to a pointer to YourActionState if necessary
+ *   <li/> redo the undone action using the information from the state
+ *   <li/> produce a new state that can be used by performUndo() and return it
+ *  </ul>
+ * </ul>
+ *
+ * <H2> Advanced techniques </H2>
+ *
+ * <H3> Predefined Actions </H3>
+ *
+ * To make construction of actions easy there are some predefined actions. Namely these are
+ * the MethodAction and the ErrorAction.
+ *
+ * The method action can be used to turn any function with empty arguments and return type void
+ * into an action (also works for functors with those types). Simply pass the constructor for the
+ * MethodAction a name to use for this action, the function to call inside the performCall()
+ * method and a flag indicating if this action should be made retrievable inside the registry
+ * (default is true). MethodActions always report themselves as changing the state of the
+ * application but cannot be undone. i.e. calling MethodActions will always cause the ActionHistory
+ * to be cleared.
+ *
+ * ErrorActions can be used to produce a short message using the Log() << Verbose() mechanism of
+ * the molecuilder. Simply pass the constructor a name for the action, the message to show upon
+ * calling this action and the flag for the registry (default is again true). Error action
+ * report that they do not change the state of the application and are therefore not considered
+ * for undo.
+ *
+ * <H3> Sequences of Actions and MakroActions </H3>
+ *
+ * <H4> Building sequences of Actions </H4>
+ *
+ * Actions can be chained to sequences using the ActionSequence class. Once an ActionSequence is
+ * constructed it will be initially empty. Any Actions can then be added to the sequence using the
+ * addAction() method of the ActionSequence class. The last added action can be removed using the
+ * removeLastAction() method. If the construction of the sequence is done, you can use the
+ * callAll() method. Each action called this way will register itself with the History to allow
+ * separate undo of all actions in the sequence.
+ *
+ * <H4> Building larger Actions from simple ones </H4>
+ *
+ * Using the pre-defined class MakroAction it is possible to construct bigger actions from a sequence
+ * of smaller ones. For this you first have to build a sequence of the actions using the ActionSequence
+ * as described above. Then you can construct a MakroAction passing it a name, the sequence to use
+ * and as usual a flag for the registry. You can then simply call the complete action-sequence through
+ * this makro action using the normal interface. Other than with the direct use of the action sequence
+ * only the complete MakroAction is registered inside the history, i.e. the complete sequence can be
+ * undone at once. Also there are a few caveats you have to take care of when using the MakroAction:
+ * <ul>
+ *  <li/> All Actions as well as the sequence should exclusively belong to the MakroAction. This
+ *        especially means, that the destruction of these objects should be handled by the MakroAction.
+ *  <li/> none of the Actions inside the MakroAction should be registered with the registry, since the
+ *        registry also assumes sole ownership of the actions.
+ *  <li/> Do not remove or add actions from the sequence once the MakroAction has been constructed, since this
+ *        might brake important assumptions for the undo/redo mechanism
+ * </ul>
+ *
+ * <H3> Special kinds of Actions </H3>
+ *
+ * To make the usage of Actions more versatile there are two special kinds of actions defined,
+ * that contain special mechanisms. These are defined inside the class Process, for actions that
+ * take some time and indicate their own progress, and in the class Calculations for actions that
+ * have a retrievable result.
+ *
+ * <H4> Processes </H4>
+ *
+ * Processes are Actions that might take some time and therefore contain special mechanisms
+ * to indicate their progress to the user. If you want to implement a process you can follow the
+ * guidelines for implementing actions. In addition to the normal Action constructor parameters,
+ * you also need to define the number of steps the process takes to finish (use 0 if that number is
+ * not known upon construction). At the beginning of your process you then simply call start() to
+ * indicate that the process is taking up its work. You might also want to set the number of steps it
+ * needs to finish, if it has changed since the last invocation/construction. You can use the
+ * setMaxSteps() method for this. Then after each finished step of calulation simply call step(),
+ * to let the indicators know that it should update itself. If the number of steps is not known
+ * at the time of calculation, you should make sure the maxSteps field is set to 0, either through
+ * the constructor or by using setMaxSteps(0). Indicators are required to handle both processes that
+ * know the number of steps needed as well as processes that cannot predict when they will be finished.
+ * Once your calculation is done call stop() to let every indicator know that the process is done with
+ * the work and to let the user know.
+ *
+ * Indicators that want to know about processes need to implement the Observer class with all the
+ * methods defined there. They can then globally sign on to all processes using the static
+ * Process::AddObserver() method and remove themselves using the Process::RemoveObserver()
+ * methods. When a process starts it will take care that the notification for this process
+ * is invoked at the right time. Indicators should not try to observe a single process, but rather
+ * be ready to observe the status of any kind of process using the methods described here.
+ *
+ * <H4> Calculations </H4>
+ *
+ * Calculations are special Actions that also return a result when called. Calculations are
+ * always derived from Process, so that the progress of a calculation can be shown. Also
+ * Calculations should not contain side-effects and not consider the undo mechanism.
+ * When a Calculation is called using the Action mechanism this will cause it to calculate
+ * the result and make it available using the getResult() method. Another way to have a Calculation
+ * produce a result is by using the function-call operator. When this operator is used, the Calculation
+ * will try to return a previously calculated and cached result and only do any actuall calculations
+ * when no such result is available. You can delete the cached result using the reset() method.
+ */
+
+/**
+ * Base class for all actions.
+ *
+ * Actions describe something that has to be done.
+ * Actions can be passed around, stored, performed and undone (Command-Pattern).
+ */
+class Action
+{
+friend class ActionSequence;
+friend class ActionHistory;
+public:
+
+  /**
+   * This type is used to store pointers to ActionStates while allowing multiple ownership
+   */
+  typedef boost::shared_ptr<ActionState> state_ptr;
+
+  /**
+   * Standard constructor of Action Base class
+   *
+   * All Actions need to have a name. The second flag indicates, whether the action should
+   * be registered with the ActionRegistry. If the Action is registered the name of the
+   * Action needs to be unique for all Actions that are registered.
+   */
+  Action(std::string _name,bool _doRegister=true);
+  virtual ~Action();
+
+  /**
+   * This method is used to call an action. The basic operations for the Action
+   * are carried out and if necessary/possible the Action is added to the History
+   * to allow for undo of this action.
+   *
+   * If the call needs to undone you have to use the History, to avoid destroying
+   * invariants used by the History.
+   */
+  void call();
+
+  /**
+   * This method provides a flag that indicates if an undo mechanism is implemented
+   * for this Action. If this is true, and this action was called last, you can
+   * use the History to undo this action.
+   */
+  virtual bool canUndo()=0;
+
+  /**
+   * This method provides a flag, that indicates if the Action changes the state of
+   * the application in a way that needs to be undone for the History to work.
+   *
+   * If this is false the Action will not be added to the History upon calling. However
+   * Actions called before this one will still be available for undo.
+   */
+  virtual bool shouldUndo()=0;
+
+  /**
+   * Indicates whether the Action can do it's work at the moment. If this
+   * is false calling the action will result in a no-op.
+   */
+  virtual bool isActive();
+
+  /**
+   * Returns the name of the Action.
+   */
+  virtual const std::string getName();
+
+protected:
+  /**
+   * This method is called by the History, when an undo is performed. It is
+   * provided with the corresponding state produced by the performCall or
+   * performRedo method and needs to provide a state that can be used for redo.
+   */
+  state_ptr undo(state_ptr);
+
+  /**
+   * This method is called by the Histor, when a redo is performed. It is
+   * provided with the corresponding state produced by the undo method and
+   * needs to produce a State that can then be used for another undo.
+   */
+  state_ptr redo(state_ptr);
+
+  /**
+   * This special state can be used to indicate that the Action was successfull
+   * without providing a special state. Use this if your Action does not need
+   * a speciallized state.
+   */
+  static state_ptr success;
+
+  /**
+   * This special state can be returned, to indicate that the action could not do it's
+   * work, was abborted by the user etc. If you return this state make sure to transactionize
+   * your Actions and unroll the complete transaction before this is returned.
+   */
+  static state_ptr failure;
+
+private:
+  /**
+   * This is called internally when the call is being done. Implement this method to do the actuall
+   * work of the Action. Implement this in your Derived classes. Needs to return a state that can be
+   * used to undo the action.
+   */
+  virtual state_ptr performCall()=0;
+
+  /**
+   * This is called internally when the undo process is chosen. This Method should use the state
+   * produced by the performCall method to return the state of the application to the state
+   * it had before the Action.
+   */
+  virtual state_ptr performUndo(state_ptr)=0;
+
+  /**
+   * This is called internally when the redo process is chosen. This method shoudl use the state
+   * produced by the performUndo method to return the application to the state it should have after
+   * the action.
+   *
+   * Often this method can be implement to re-use the performCall method. However if user interaction
+   * or further parameters are needed, those should be taken from the state and not query the user
+   * again.
+   */
+  virtual state_ptr performRedo(state_ptr)=0;
+
+  std::string name;
+};
+
+/**
+ * This class can be used by actions to save the state.
+ *
+ * It is implementing a memento pattern. The base class is completely empty,
+ * since no general state internals can be given. The Action performing
+ * the Undo should downcast to the apropriate type.
+ */
+class ActionState{
+public:
+  ActionState(){}
+  virtual ~ActionState(){}
+};
+
+#endif /* ACTION_H_ */
Index: src/Actions/ActionHistory.cpp
===================================================================
--- src/Actions/ActionHistory.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/ActionHistory.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,135 @@
+/*
+ * ActionHistory.cpp
+ *
+ *  Created on: Mar 25, 2010
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "ActionHistory.hpp"
+
+#include <iostream>
+
+#include "Patterns/Singleton_impl.hpp"
+#include "Helpers/Assert.hpp"
+#include "Helpers/MemDebug.hpp"
+
+using namespace std;
+
+ActionHistory::ActionHistory()
+{}
+
+ActionHistory::~ActionHistory()
+{}
+
+void ActionHistory::undoLast(){
+  ASSERT(history.size(),"Undo performed when the undo-queue was empty");
+  HistoryElement elem = history.back();
+  history.pop_back();
+  Action::state_ptr newState = elem.action->undo(elem.state);
+  yrotsih.push_back(HistoryElement(elem.action,newState));
+}
+void ActionHistory::redoLast(){
+  ASSERT(yrotsih.size(),"Redo performed when the redo-queue was empty");
+  HistoryElement elem = yrotsih.back();
+  yrotsih.pop_back();
+  Action::state_ptr oldState = elem.action->redo(elem.state);
+  history.push_back(HistoryElement(elem.action,oldState));
+}
+
+bool ActionHistory::hasUndo(){
+  return history.size()>0;
+}
+
+bool ActionHistory::hasRedo(){
+  return yrotsih.size()>0;
+}
+
+void ActionHistory::addElement(Action* action,Action::state_ptr state){
+  yrotsih.clear();
+  history.push_back(HistoryElement(action,state));
+}
+
+void ActionHistory::clear(){
+  history.clear();
+  yrotsih.clear();
+}
+
+void ActionHistory::init(){
+  ActionHistory *hist = new ActionHistory();
+  setInstance(hist);
+  new UndoAction(hist);
+  new RedoAction(hist);
+}
+
+CONSTRUCT_SINGLETON(ActionHistory)
+
+/****************** Contained actions *******************/
+ActionHistory::UndoAction::UndoAction(ActionHistory *_hist) :
+  Action("Undo"),
+  hist(_hist)
+{}
+
+ActionHistory::UndoAction::~UndoAction(){}
+
+bool ActionHistory::UndoAction::canUndo(){
+  return false;
+}
+
+bool ActionHistory::UndoAction::shouldUndo(){
+  return false;
+}
+
+bool ActionHistory::UndoAction::isActive(){
+  return hist->hasUndo();
+}
+
+Action::state_ptr ActionHistory::UndoAction::performCall(){
+  hist->undoLast();
+  return Action::success;
+}
+
+Action::state_ptr ActionHistory::UndoAction::performUndo(Action::state_ptr){
+  ASSERT(0,"Cannot undo an undo (should use redo for this");
+  return Action::success;
+}
+
+Action::state_ptr ActionHistory::UndoAction::performRedo(Action::state_ptr){
+  ASSERT(0,"Cannot redo an undo");
+  return Action::success;
+}
+
+ActionHistory::RedoAction::RedoAction(ActionHistory *_hist) :
+    Action("Redo"),
+    hist(_hist)
+{}
+
+ActionHistory::RedoAction::~RedoAction(){}
+
+bool ActionHistory::RedoAction::canUndo(){
+  return false;
+}
+
+bool ActionHistory::RedoAction::shouldUndo(){
+  return false;
+}
+
+bool ActionHistory::RedoAction::isActive(){
+  return hist->hasRedo();
+}
+
+Action::state_ptr ActionHistory::RedoAction::performCall(){
+  hist->redoLast();
+  return Action::success;
+}
+
+Action::state_ptr ActionHistory::RedoAction::performUndo(Action::state_ptr){
+  ASSERT(0,"Cannot undo a redo (should use undo for this");
+  return Action::success;
+}
+
+Action::state_ptr ActionHistory::RedoAction::performRedo(Action::state_ptr){
+  ASSERT(0,"Cannot redo a redo");
+  return Action::success;
+}
Index: src/Actions/ActionHistory.hpp
===================================================================
--- src/Actions/ActionHistory.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/ActionHistory.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,92 @@
+/*
+ * ActionHistory.hpp
+ *
+ *  Created on: Mar 25, 2010
+ *      Author: crueger
+ */
+
+#ifndef ACTIONHISTORY_HPP_
+#define ACTIONHISTORY_HPP_
+
+#include "Patterns/Singleton.hpp"
+
+#include <deque>
+
+#include "Actions/Action.hpp"
+
+
+class ActionHistory : public Singleton<ActionHistory,false>
+{
+  friend class Singleton<ActionHistory,false>;
+
+  struct HistoryElement {
+    HistoryElement(Action *_action, Action::state_ptr _state) :
+      action(_action),
+      state(_state)
+    {}
+    Action *action;
+    Action::state_ptr state;
+  };
+
+  class UndoAction : public Action {
+  public:
+    UndoAction(ActionHistory*);
+    virtual ~UndoAction();
+
+    virtual bool canUndo();
+    virtual bool shouldUndo();
+
+    virtual bool isActive();
+
+  private:
+    virtual Action::state_ptr performCall();
+    virtual Action::state_ptr performUndo(Action::state_ptr);
+    virtual Action::state_ptr performRedo(Action::state_ptr);
+
+    ActionHistory *hist;
+  };
+
+  class RedoAction : public Action {
+  public:
+    RedoAction(ActionHistory*);
+    virtual ~RedoAction();
+
+    virtual bool canUndo();
+    virtual bool shouldUndo();
+
+    virtual bool isActive();
+
+  private:
+    virtual Action::state_ptr performCall();
+    virtual Action::state_ptr performUndo(Action::state_ptr);
+    virtual Action::state_ptr performRedo(Action::state_ptr);
+
+    ActionHistory *hist;
+  };
+
+public:
+
+  void undoLast();
+  void redoLast();
+
+  bool hasUndo();
+  bool hasRedo();
+
+  void addElement(Action*,Action::state_ptr);
+  void clear();
+protected:
+  ActionHistory();
+  virtual ~ActionHistory();
+private:
+  std::deque<HistoryElement> history;
+  std::deque<HistoryElement> yrotsih;
+
+public:
+  // when constructing the actions we need the Actionregistry Singleton
+  // Singletons need static variables to work, but we cannot access statics
+  // inside a static initialization, so we have this init function that
+  // needs to be called at a non-static point at the start of the program
+  static void init();
+};
+
+#endif /* ACTIONHISTORY_HPP_ */
Index: src/Actions/ActionRegistry.cpp
===================================================================
--- src/Actions/ActionRegistry.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/ActionRegistry.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,126 @@
+/*
+ * ActionRegistry.cpp
+ *
+ *  Created on: Jan 7, 2010
+ *      Author: crueger
+ */
+
+#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;
+
+/** Constructor for class ActionRegistry.
+ */
+ActionRegistry::ActionRegistry()
+{
+}
+
+/** Destructor for class ActionRegistry.
+ */
+ActionRegistry::~ActionRegistry()
+{
+  map<const string,Action*>::iterator iter;
+  for(iter=actionMap.begin();iter!=actionMap.end();++iter) {
+    delete iter->second;
+  }
+  actionMap.clear();
+}
+
+/** Returns pointer to an action named by \a name.
+ * \param name name of action
+ * \return pointer to Action
+ */
+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;
+}
+
+/** 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)
Index: src/Actions/ActionRegistry.hpp
===================================================================
--- src/Actions/ActionRegistry.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/ActionRegistry.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,43 @@
+/*
+ * ActionRegistry.hpp
+ *
+ *  Created on: Jan 7, 2010
+ *      Author: crueger
+ */
+
+#ifndef ACTIONREGISTRY_HPP_
+#define ACTIONREGISTRY_HPP_
+
+#include <iostream>
+#include <string>
+#include <map>
+
+#include "Patterns/Singleton.hpp"
+
+class Action;
+
+class ActionRegistry : public Singleton<ActionRegistry>
+{
+  friend class Singleton<ActionRegistry>;
+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;
+
+private:
+  ActionRegistry();
+  virtual ~ActionRegistry();
+};
+
+std::ostream& operator<<(std::ostream& ost, const ActionRegistry& m);
+
+#endif /* ACTIONREGISTRY_HPP_ */
Index: src/Actions/ActionSequence.cpp
===================================================================
--- src/Actions/ActionSequence.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/ActionSequence.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,117 @@
+/*
+ * ActionSequenze.cpp
+ *
+ *  Created on: Dec 17, 2009
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/ActionSequence.hpp"
+#include "Actions/Action.hpp"
+
+#include "Helpers/Assert.hpp"
+
+using namespace std;
+
+ActionSequence::ActionSequence()
+{}
+
+ActionSequence::~ActionSequence()
+{}
+
+
+void ActionSequence::addAction(Action* _action){
+  actions.push_back(_action);
+}
+
+Action* ActionSequence::removeLastAction(){
+  if(actions.empty()) {
+    return 0;
+  }
+  else {
+    Action* theAction;
+    theAction = actions.back();
+    actions.pop_back();
+    return theAction;
+  }
+}
+
+// this method is used outside the ActionModule
+// Each action registers itself with the history
+void ActionSequence::callAll(){
+  for(actionSet::iterator it=actions.begin(); it!=actions.end(); it++){
+    // we want to have a global bookkeeping for all actions in the sequence, so
+    // we bypass the normal call
+    (*it)->call();
+  }
+}
+
+// This method is used internally when MakroActions are constructed.
+// In this case only the makro Action should be registered and
+// handle the states
+ActionSequence::stateSet ActionSequence::callAll(bool){
+  stateSet states;
+  for(actionSet::iterator it=actions.begin(); it!=actions.end(); it++){
+    // we want to have a global bookkeeping for all actions in the sequence, so
+    // we bypass the normal call
+    Action::state_ptr state = (*it)->performCall();
+    states.push_back(state);
+  }
+  return states;
+}
+
+ActionSequence::stateSet ActionSequence::undoAll(stateSet states){
+  ASSERT(canUndo(),"Trying to undo a sequence that contains methods that can't be undone");
+  stateSet res;
+  actionSet::reverse_iterator actionRit = actions.rbegin();
+  stateSet::reverse_iterator stateRit = states.rbegin();
+  for(;actionRit!=actions.rend();++actionRit,++stateRit){
+    ASSERT(stateRit!=states.rend(),"End of states prematurely reached.");
+    if((*actionRit)->shouldUndo()){
+      Action::state_ptr newState = (*actionRit)->performUndo(*stateRit);
+      // The order of the states has to correspond to the order of the actions
+      // this is why we have to add at the beginning
+      res.push_front(newState);
+    }
+    else{
+      res.push_front(Action::success);
+    }
+  }
+  return res;
+}
+
+ActionSequence::stateSet ActionSequence::redoAll(stateSet states){
+  stateSet res;
+  actionSet::iterator actionIt = actions.begin();
+  stateSet::iterator stateIt = states.begin();
+  for(;actionIt!=actions.end();++actionIt,++stateIt){
+    ASSERT(stateIt!=states.end(),"End of states prematurely reached.");
+    if((*actionIt)->shouldUndo()){
+      Action::state_ptr newState =(*actionIt)->performRedo(*stateIt);
+      res.push_back(newState);
+    }
+    else{
+      res.push_back(Action::success);
+    }
+  }
+  return res;
+}
+
+bool ActionSequence::canUndo(){
+  bool canUndo=true;
+  for(deque<Action*>::iterator it=actions.begin(); it!=actions.end(); ++it){
+    if((*it)->shouldUndo()){
+      canUndo &= (*it)->canUndo();
+    }
+  }
+  return canUndo;
+}
+
+bool ActionSequence::shouldUndo(){
+  bool shouldUndo = false;
+  for(deque<Action*>::iterator it=actions.begin();it!=actions.end();++it){
+    shouldUndo |= (*it)->shouldUndo();
+  }
+  return shouldUndo;
+}
Index: src/Actions/ActionSequence.hpp
===================================================================
--- src/Actions/ActionSequence.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/ActionSequence.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,44 @@
+/*
+ * ActionSequenze.hpp
+ *
+ *  Created on: Dec 17, 2009
+ *      Author: crueger
+ */
+
+#ifndef ACTIONSEQUENZE_HPP_
+#define ACTIONSEQUENZE_HPP_
+
+#include "Actions/Action.hpp"
+
+#include <deque>
+
+/**
+ * Store Actions for later use.
+ */
+class ActionSequence
+{
+  friend class MakroAction;
+public:
+  typedef std::deque<Action*> actionSet;
+  typedef std::deque<Action::state_ptr> stateSet;
+
+  ActionSequence();
+  virtual ~ActionSequence();
+
+  void addAction(Action*);
+  Action* removeLastAction();
+
+  void callAll();
+
+  bool canUndo();
+  bool shouldUndo();
+
+protected:
+  stateSet callAll(bool); // Dummy parameter to allow overloading
+  stateSet undoAll(stateSet);
+  stateSet redoAll(stateSet);
+private:
+  actionSet actions;
+};
+
+#endif /* ACTIONSEQUENZE_HPP_ */
Index: src/Actions/AnalysisAction/MolecularVolumeAction.cpp
===================================================================
--- src/Actions/AnalysisAction/MolecularVolumeAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/AnalysisAction/MolecularVolumeAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,91 @@
+/*
+ * MolecularVolumeAction.cpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/AnalysisAction/MolecularVolumeAction.hpp"
+#include "boundary.hpp"
+#include "config.hpp"
+#include "molecule.hpp"
+#include "linkedcell.hpp"
+#include "log.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 AnalysisMolecularVolumeAction::NAME[] = "molecular-volume";
+
+AnalysisMolecularVolumeAction::AnalysisMolecularVolumeAction() :
+  Action(NAME)
+{}
+
+AnalysisMolecularVolumeAction::~AnalysisMolecularVolumeAction()
+{}
+
+Action::state_ptr AnalysisMolecularVolumeAction::performCall() {
+  Dialog *dialog = UIFactory::getInstance().makeDialog();
+  molecule *mol = NULL;
+
+  dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME));
+
+  if(dialog->display()) {
+    class Tesselation *TesselStruct = NULL;
+    const LinkedCell *LCList = NULL;
+    DoLog(0) && (Log() << Verbose(0) << "Evaluating volume of the convex envelope.");
+    LCList = new LinkedCell(mol, 10.);
+    config * const configuration = World::getInstance().getConfig();
+    Boundaries *BoundaryPoints = NULL;
+    //FindConvexBorder(mol, BoundaryPoints, TesselStruct, LCList, argv[argptr]);
+    FindNonConvexBorder(mol, TesselStruct, LCList, 5., NULL);
+    //RemoveAllBoundaryPoints(TesselStruct, mol, argv[argptr]);
+    double volumedifference = ConvexizeNonconvexEnvelope(TesselStruct, mol, NULL);
+    double clustervolume = VolumeOfConvexEnvelope(TesselStruct, configuration);
+    DoLog(0) && (Log() << Verbose(0) << "The tesselated volume area is " << clustervolume << " " << (configuration->GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl);
+    DoLog(0) && (Log() << Verbose(0) << "The non-convex tesselated volume area is " << clustervolume-volumedifference << " " << (configuration->GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl);
+    delete(TesselStruct);
+    delete(LCList);
+    delete dialog;
+    return Action::success;
+  } else {
+    delete dialog;
+    return Action::failure;
+  }
+}
+
+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));
+}
+
+Action::state_ptr AnalysisMolecularVolumeAction::performRedo(Action::state_ptr _state){
+  return Action::failure;
+}
+
+bool AnalysisMolecularVolumeAction::canUndo() {
+  return false;
+}
+
+bool AnalysisMolecularVolumeAction::shouldUndo() {
+  return false;
+}
+
+const string AnalysisMolecularVolumeAction::getName() {
+  return NAME;
+}
Index: src/Actions/AnalysisAction/MolecularVolumeAction.hpp
===================================================================
--- src/Actions/AnalysisAction/MolecularVolumeAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/AnalysisAction/MolecularVolumeAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+/*
+ * MolecularVolumeAction.hpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+#ifndef MOLECULARVOLUMEACTION_HPP_
+#define MOLECULARVOLUMEACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class AnalysisMolecularVolumeAction : public Action {
+public:
+  AnalysisMolecularVolumeAction();
+  virtual ~AnalysisMolecularVolumeAction();
+
+  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 /* MOLECULARVOLUMEACTION_HPP_ */
Index: src/Actions/AnalysisAction/PairCorrelationAction.cpp
===================================================================
--- src/Actions/AnalysisAction/PairCorrelationAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/AnalysisAction/PairCorrelationAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,192 @@
+/*
+ * PairCorrelationAction.cpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/AnalysisAction/PairCorrelationAction.hpp"
+#include "analysis_correlation.hpp"
+#include "boundary.hpp"
+#include "linkedcell.hpp"
+#include "log.hpp"
+#include "element.hpp"
+#include "molecule.hpp"
+#include "periodentafel.hpp"
+#include "vector.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 AnalysisPairCorrelationAction::NAME[] = "pair-correlation";
+
+AnalysisPairCorrelationAction::AnalysisPairCorrelationAction() :
+  Action(NAME)
+{}
+
+AnalysisPairCorrelationAction::~AnalysisPairCorrelationAction()
+{}
+
+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;
+  bool periodic;
+  ofstream output;
+  ofstream binoutput;
+  std::vector< 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;
+  }
+
+  // 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;
+  }
+}
+
+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));
+}
+
+Action::state_ptr AnalysisPairCorrelationAction::performRedo(Action::state_ptr _state){
+  return Action::failure;
+}
+
+bool AnalysisPairCorrelationAction::canUndo() {
+  return false;
+}
+
+bool AnalysisPairCorrelationAction::shouldUndo() {
+  return false;
+}
+
+const string AnalysisPairCorrelationAction::getName() {
+  return NAME;
+}
Index: src/Actions/AnalysisAction/PairCorrelationAction.hpp
===================================================================
--- src/Actions/AnalysisAction/PairCorrelationAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/AnalysisAction/PairCorrelationAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+/*
+ * PairCorrelationAction.hpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+#ifndef PAIRCORRELATIONACTION_HPP_
+#define PAIRCORRELATIONACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class AnalysisPairCorrelationAction : public Action {
+public:
+  AnalysisPairCorrelationAction();
+  virtual ~AnalysisPairCorrelationAction();
+
+  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 /* PAIRCORRELATIONACTION_HPP_ */
Index: src/Actions/AnalysisAction/PrincipalAxisSystemAction.cpp
===================================================================
--- src/Actions/AnalysisAction/PrincipalAxisSystemAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/AnalysisAction/PrincipalAxisSystemAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,74 @@
+/*
+ * PrincipalAxisSystemAction.cpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/AnalysisAction/PrincipalAxisSystemAction.hpp"
+#include "molecule.hpp"
+#include "log.hpp"
+#include "verbose.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/MapOfActions.hpp"
+
+const char AnalysisPrincipalAxisSystemAction::NAME[] = "principal-axis-system";
+
+AnalysisPrincipalAxisSystemAction::AnalysisPrincipalAxisSystemAction() :
+  Action(NAME)
+{}
+
+AnalysisPrincipalAxisSystemAction::~AnalysisPrincipalAxisSystemAction()
+{}
+
+Action::state_ptr AnalysisPrincipalAxisSystemAction::performCall() {
+  Dialog *dialog = UIFactory::getInstance().makeDialog();
+  molecule *mol = NULL;
+
+  dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME));
+
+  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;
+  }
+}
+
+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));
+}
+
+Action::state_ptr AnalysisPrincipalAxisSystemAction::performRedo(Action::state_ptr _state){
+  return Action::failure;
+}
+
+bool AnalysisPrincipalAxisSystemAction::canUndo() {
+  return false;
+}
+
+bool AnalysisPrincipalAxisSystemAction::shouldUndo() {
+  return false;
+}
+
+const string AnalysisPrincipalAxisSystemAction::getName() {
+  return NAME;
+}
Index: src/Actions/AnalysisAction/PrincipalAxisSystemAction.hpp
===================================================================
--- src/Actions/AnalysisAction/PrincipalAxisSystemAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/AnalysisAction/PrincipalAxisSystemAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+/*
+ * PrincipalAxisSystemAction.hpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+#ifndef PRINCIPALAXISSYSTEMACTION_HPP_
+#define PRINCIPALAXISSYSTEMACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class AnalysisPrincipalAxisSystemAction : public Action {
+public:
+  AnalysisPrincipalAxisSystemAction();
+  virtual ~AnalysisPrincipalAxisSystemAction();
+
+  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 /* PRINCIPALAXISSYSTEMACTION_HPP_ */
Index: src/Actions/AtomAction/AddAction.cpp
===================================================================
--- src/Actions/AtomAction/AddAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/AtomAction/AddAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,96 @@
+/*
+ * AddAction.cpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/AtomAction/AddAction.hpp"
+#include "atom.hpp"
+#include "element.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 AtomAddAction::NAME[] = "add-atom";
+
+AtomAddAction::AtomAddAction() :
+  Action(NAME)
+{}
+
+AtomAddAction::~AtomAddAction()
+{}
+
+Action::state_ptr AtomAddAction::performCall() {
+  Dialog *dialog = UIFactory::getInstance().makeDialog();
+  std::vector<element *> elements;
+  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;
+
+  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;
+  }
+
+}
+
+Action::state_ptr AtomAddAction::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 AtomAddAction::performRedo(Action::state_ptr _state){
+  return Action::failure;
+}
+
+bool AtomAddAction::canUndo() {
+  return false;
+}
+
+bool AtomAddAction::shouldUndo() {
+  return false;
+}
+
+const string AtomAddAction::getName() {
+  return NAME;
+}
Index: src/Actions/AtomAction/AddAction.hpp
===================================================================
--- src/Actions/AtomAction/AddAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/AtomAction/AddAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+/*
+ * AddAction.hpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+#ifndef ADDACTION_HPP_
+#define ADDACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class AtomAddAction : public Action {
+public:
+  AtomAddAction();
+  virtual ~AtomAddAction();
+
+  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 /* ADDACTION_HPP_ */
Index: src/Actions/AtomAction/ChangeElementAction.cpp
===================================================================
--- src/Actions/AtomAction/ChangeElementAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/AtomAction/ChangeElementAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,84 @@
+/*
+ * ChangeElementAction.cpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/AtomAction/ChangeElementAction.hpp"
+#include "atom.hpp"
+#include "log.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 AtomChangeElementAction::NAME[] = "change-element";
+
+AtomChangeElementAction::AtomChangeElementAction() :
+  Action(NAME)
+{}
+
+AtomChangeElementAction::~AtomChangeElementAction()
+{}
+
+Action::state_ptr AtomChangeElementAction::performCall() {
+  Dialog *dialog = UIFactory::getInstance().makeDialog();
+  atom *first = NULL;
+  std::vector<element *> elements;
+
+  dialog->queryElement(NAME, &elements, MapOfActions::getInstance().getDescription(NAME));
+  dialog->queryAtom("atom-by-id", &first, MapOfActions::getInstance().getDescription("atom-by-id"));
+
+  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;
+  }
+
+}
+
+Action::state_ptr AtomChangeElementAction::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 AtomChangeElementAction::performRedo(Action::state_ptr _state){
+  return Action::failure;
+}
+
+bool AtomChangeElementAction::canUndo() {
+  return false;
+}
+
+bool AtomChangeElementAction::shouldUndo() {
+  return false;
+}
+
+const string AtomChangeElementAction::getName() {
+  return NAME;
+}
Index: src/Actions/AtomAction/ChangeElementAction.hpp
===================================================================
--- src/Actions/AtomAction/ChangeElementAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/AtomAction/ChangeElementAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+/*
+ * ChangeElementAction.hpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+#ifndef CHANGELEMENTACTION_HPP_
+#define CHANGELEMENTACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class AtomChangeElementAction : public Action {
+public:
+  AtomChangeElementAction();
+  virtual ~AtomChangeElementAction();
+
+  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 /* CHANGELEMENTACTION_HPP_ */
Index: src/Actions/AtomAction/RemoveAction.cpp
===================================================================
--- src/Actions/AtomAction/RemoveAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/AtomAction/RemoveAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,84 @@
+/*
+ * RemoveAction.cpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/AtomAction/RemoveAction.hpp"
+#include "atom.hpp"
+#include "Descriptors/AtomDescriptor.hpp"
+#include "log.hpp"
+#include "molecule.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 AtomRemoveAction::NAME[] = "remove-atom";
+
+AtomRemoveAction::AtomRemoveAction() :
+  Action(NAME)
+{}
+
+AtomRemoveAction::~AtomRemoveAction()
+{}
+
+Action::state_ptr AtomRemoveAction::performCall() {
+  Dialog *dialog = UIFactory::getInstance().makeDialog();
+  atom *first = NULL;
+
+  dialog->queryAtom(NAME, &first, MapOfActions::getInstance().getDescription(NAME));
+
+  if(dialog->display()) {
+    delete dialog;
+    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);
+    }
+    World::getInstance().destroyAtom(first);
+    return Action::success;
+  } else {
+    delete dialog;
+    return Action::failure;
+  }
+
+}
+
+Action::state_ptr AtomRemoveAction::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 AtomRemoveAction::performRedo(Action::state_ptr _state){
+  return Action::failure;
+}
+
+bool AtomRemoveAction::canUndo() {
+  return false;
+}
+
+bool AtomRemoveAction::shouldUndo() {
+  return false;
+}
+
+const string AtomRemoveAction::getName() {
+  return NAME;
+}
Index: src/Actions/AtomAction/RemoveAction.hpp
===================================================================
--- src/Actions/AtomAction/RemoveAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/AtomAction/RemoveAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+/*
+ * RemoveAction.hpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+#ifndef REMOVEACTION_HPP_
+#define REMOVEACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class AtomRemoveAction : public Action {
+public:
+  AtomRemoveAction();
+  virtual ~AtomRemoveAction();
+
+  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 /* REMOVEACTION_HPP_ */
Index: src/Actions/AtomsCalculation.hpp
===================================================================
--- src/Actions/AtomsCalculation.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/AtomsCalculation.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,28 @@
+/*
+ * AtomsCalculation.hpp
+ *
+ *  Created on: Feb 19, 2010
+ *      Author: crueger
+ */
+
+#ifndef ATOMSCALCULATION_HPP_
+#define ATOMSCALCULATION_HPP_
+
+#include "Actions/Calculation.hpp"
+
+template<typename T>
+class AtomsCalculation : public Calculation<std::vector<T> >
+{
+public:
+  AtomsCalculation(boost::function<T(atom*)> op,std::string name,AtomDescriptor descr);
+  virtual ~AtomsCalculation();
+
+protected:
+  virtual std::vector<T>* doCalc();
+
+private:
+  AtomDescriptor descr;
+  boost::function<T(atom*)> op;
+};
+
+#endif /* ATOMSCALCULATION_HPP_ */
Index: src/Actions/AtomsCalculation_impl.hpp
===================================================================
--- src/Actions/AtomsCalculation_impl.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/AtomsCalculation_impl.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,46 @@
+/*
+ * AtomsCalculation_impl.hpp
+ *
+ *  Created on: Feb 19, 2010
+ *      Author: crueger
+ */
+
+#ifndef ATOMSCALCULATION_IMPL_HPP_
+#define ATOMSCALCULATION_IMPL_HPP_
+
+#include "Actions/AtomsCalculation.hpp"
+#include "Actions/Calculation_impl.hpp"
+
+#include <iostream>
+
+using namespace std;
+
+template<typename T>
+AtomsCalculation<T>::AtomsCalculation(boost::function<T(atom*)> _op,std::string name,AtomDescriptor _descr) :
+  Calculation<std::vector<T> >(0,name,false),
+  descr(_descr),
+  op(_op)
+{}
+
+template<typename T>
+AtomsCalculation<T>::~AtomsCalculation(){
+}
+
+template<typename T>
+std::vector<T>* AtomsCalculation<T>::doCalc(){
+  World* world = World::getPointer();
+  int steps = world->numAtoms();
+  std::vector<T> *res = new std::vector<T>();
+  res->reserve(steps);
+  Process::setMaxSteps(steps);
+  Process::start();
+  for(World::AtomIterator iter=world->getAtomIter(descr);iter!=world->atomEnd();++iter){
+    Process::setCurrStep(iter.getCount());
+    res->push_back(op(*iter));
+  }
+  Process::stop();
+  return res;
+}
+
+
+#endif /* ATOMSCALCULATION_IMPL_HPP_ */
Index: src/Actions/Calculation.hpp
===================================================================
--- src/Actions/Calculation.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/Calculation.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,73 @@
+/*
+ * Calculation.hpp
+ *
+ *  Created on: Feb 19, 2010
+ *      Author: crueger
+ */
+
+#ifndef CALCULATION_HPP_
+#define CALCULATION_HPP_
+
+#include "Actions/Process.hpp"
+
+/**
+ * A calculation is a Process that has some kind of result.
+ *
+ * This class can be used in the same way as any other Action or Process, but has some special methods
+ * for inspecting the result of the calculation.
+ */
+template<typename T>
+class Calculation : public Process
+{
+public:
+  Calculation(int _maxSteps, std::string _name, bool _doRegister=true);
+  virtual ~Calculation();
+
+  /**
+   * Reimplemented call method for Action Base class.
+   * Resets the result and then redoes the calculation. Can be used to retrigger calculations
+   * from menu Items or other places.
+   */
+  virtual bool canUndo();
+
+  virtual bool shouldUndo();
+
+  /**
+   * Does the actual calculation and returns the result.
+   * When the calculation has been done before it is not redone, but the previous cached result is returned.
+   * Call reset to delete the cached value.
+   */
+  virtual T operator()();
+
+  /**
+   * Check if a cached result is available.
+   */
+  virtual bool hasResult();
+
+  /**
+   * Get the cached result.
+   * Fails if there is no cached result.
+   */
+  virtual T getResult();
+
+  /**
+   * Delete a previously calculated result from the cache.
+   */
+  virtual void reset();
+
+protected:
+  T* result;
+
+  /**
+   * Pure virtual method for implementation of the actual calculation procedure.
+   */
+  virtual T* doCalc()=0;
+private:
+  virtual Action::state_ptr performCall();
+  virtual Action::state_ptr performUndo(Action::state_ptr);
+  virtual Action::state_ptr performRedo(Action::state_ptr);
+
+  bool done;
+};
+
+#endif /* CALCULATION_HPP_ */
Index: src/Actions/Calculation_impl.hpp
===================================================================
--- src/Actions/Calculation_impl.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/Calculation_impl.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,89 @@
+/*
+ * Calculation_impl.hpp
+ *
+ *  Created on: Feb 19, 2010
+ *      Author: crueger
+ */
+
+#ifndef CALCULATION_IMPL_HPP_
+#define CALCULATION_IMPL_HPP_
+
+#include "Actions/Calculation.hpp"
+
+#include <cassert>
+
+template<typename T>
+Calculation<T>::Calculation(int _maxSteps, std::string _name, bool _doRegister) :
+  Process(_maxSteps,_name,_doRegister),
+  result(0),
+  done(false)
+{}
+
+template<typename T>
+Calculation<T>::~Calculation()
+{
+  delete result;
+}
+
+// methods inherited from Action
+
+template<typename T>
+Action::state_ptr Calculation<T>::performCall(){
+  reset();
+  (*this)();
+  return Action::success;
+}
+
+template<typename T>
+Action::state_ptr Calculation<T>::performUndo(Action::state_ptr){
+  ASSERT(0,"Cannot undo a calculation");
+  return Action::success;
+}
+template<typename T>
+Action::state_ptr Calculation<T>::performRedo(Action::state_ptr){
+  ASSERT(0,"Cannot redo a calculation");
+  return Action::success;
+}
+
+template<typename T>
+bool Calculation<T>::canUndo()
+{
+  return false;
+}
+
+template<typename T>
+bool Calculation<T>::shouldUndo()
+{
+  return false;
+}
+
+// methods for calculation infrastructure
+
+template<typename T>
+T Calculation<T>::operator()(){
+  if(!done){
+    result = doCalc();
+    done = true;
+  }
+  return *result;
+}
+
+template<typename T>
+bool Calculation<T>::hasResult(){
+  return done;
+}
+
+template<typename T>
+T Calculation<T>::getResult(){
+  assert(done && "No result calculated");
+  return *result;
+}
+
+template<typename T>
+void Calculation<T>::reset(){
+  done = false;
+  delete result;
+  result = 0;
+}
+
+#endif /* CALCULATION_IMPL_HPP_ */
Index: src/Actions/CmdAction/BondLengthTableAction.cpp
===================================================================
--- src/Actions/CmdAction/BondLengthTableAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/CmdAction/BondLengthTableAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,90 @@
+/*
+ * BondLengthTableAction.cpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/CmdAction/BondLengthTableAction.hpp"
+#include "bondgraph.hpp"
+#include "config.hpp"
+#include "log.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 CommandLineBondLengthTableAction::NAME[] = "bond-table";
+
+CommandLineBondLengthTableAction::CommandLineBondLengthTableAction() :
+  Action(NAME)
+{}
+
+CommandLineBondLengthTableAction::~CommandLineBondLengthTableAction()
+{}
+
+Action::state_ptr CommandLineBondLengthTableAction::performCall() {
+  ostringstream usage;
+  string BondGraphFileName;
+  Dialog *dialog = UIFactory::getInstance().makeDialog();
+
+  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());
+    if ((!BondGraphFileName.empty()) && (configuration->BG->LoadBondLengthTable(BondGraphFileName))) {
+      DoLog(0) && (Log() << Verbose(0) << "Bond length table loaded successfully." << endl);
+      return Action::success;
+    } else {
+      DoeLog(1) && (eLog()<< Verbose(1) << "Bond length table loading failed." << endl);
+      return Action::failure;
+    }
+  } else {
+    DoLog(0) && (Log() << Verbose(0) << "Bond length table already present." << endl);
+    return Action::failure;
+  }
+}
+
+Action::state_ptr CommandLineBondLengthTableAction::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 CommandLineBondLengthTableAction::performRedo(Action::state_ptr _state){
+  return Action::failure;
+}
+
+bool CommandLineBondLengthTableAction::canUndo() {
+  return false;
+}
+
+bool CommandLineBondLengthTableAction::shouldUndo() {
+  return false;
+}
+
+const string CommandLineBondLengthTableAction::getName() {
+  return NAME;
+}
Index: src/Actions/CmdAction/BondLengthTableAction.hpp
===================================================================
--- src/Actions/CmdAction/BondLengthTableAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/CmdAction/BondLengthTableAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+/*
+ * BondLengthTableAction.hpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+#ifndef BONDLENGTHTABLEACTION_HPP_
+#define BONDLENGTHTABLEACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class CommandLineBondLengthTableAction : public Action {
+public:
+  CommandLineBondLengthTableAction();
+  virtual ~CommandLineBondLengthTableAction();
+
+  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 /* BONDLENGTHTABLEACTION_HPP_ */
Index: src/Actions/CmdAction/ElementDbAction.cpp
===================================================================
--- src/Actions/CmdAction/ElementDbAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/CmdAction/ElementDbAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,90 @@
+/*
+ * ElementDbAction.cpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/CmdAction/ElementDbAction.hpp"
+#include "config.hpp"
+#include "log.hpp"
+#include "periodentafel.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 CommandLineElementDbAction::NAME[] = "element-db";
+
+CommandLineElementDbAction::CommandLineElementDbAction() :
+  Action(NAME)
+{}
+
+CommandLineElementDbAction::~CommandLineElementDbAction()
+{}
+
+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;
+  }
+
+  // load table
+  periodentafel *periode = World::getInstance().getPeriode();
+  if (periode->LoadPeriodentafel(configuration->databasepath)) {
+    DoLog(0) && (Log() << Verbose(0) << "Element list loaded successfully." << endl);
+    //periode->Output();
+    return Action::success;
+  } else {
+    DoLog(0) && (Log() << Verbose(0) << "Element list loading failed." << endl);
+    return Action::failure;
+  }
+
+}
+
+Action::state_ptr CommandLineElementDbAction::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 CommandLineElementDbAction::performRedo(Action::state_ptr _state){
+  return Action::failure;
+}
+
+bool CommandLineElementDbAction::canUndo() {
+  return false;
+}
+
+bool CommandLineElementDbAction::shouldUndo() {
+  return false;
+}
+
+const string CommandLineElementDbAction::getName() {
+  return NAME;
+}
Index: src/Actions/CmdAction/ElementDbAction.hpp
===================================================================
--- src/Actions/CmdAction/ElementDbAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/CmdAction/ElementDbAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+/*
+ * ElementDbAction.hpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+#ifndef ELEMENTDBACTION_HPP_
+#define ELEMENTDBACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class CommandLineElementDbAction : public Action {
+public:
+  CommandLineElementDbAction();
+  virtual ~CommandLineElementDbAction();
+
+  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 /* ELEMENTDBACTION_HPP_ */
Index: src/Actions/CmdAction/FastParsingAction.cpp
===================================================================
--- src/Actions/CmdAction/FastParsingAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/CmdAction/FastParsingAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,77 @@
+/*
+ * FastParsingAction.cpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/CmdAction/FastParsingAction.hpp"
+#include "config.hpp"
+#include "log.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 CommandLineFastParsingAction::NAME[] = "fastparsing";
+
+CommandLineFastParsingAction::CommandLineFastParsingAction() :
+  Action(NAME)
+{}
+
+CommandLineFastParsingAction::~CommandLineFastParsingAction()
+{}
+
+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;
+  }
+}
+
+Action::state_ptr CommandLineFastParsingAction::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 CommandLineFastParsingAction::performRedo(Action::state_ptr _state){
+  return Action::failure;
+}
+
+bool CommandLineFastParsingAction::canUndo() {
+  return false;
+}
+
+bool CommandLineFastParsingAction::shouldUndo() {
+  return false;
+}
+
+const string CommandLineFastParsingAction::getName() {
+  return NAME;
+}
Index: src/Actions/CmdAction/FastParsingAction.hpp
===================================================================
--- src/Actions/CmdAction/FastParsingAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/CmdAction/FastParsingAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+/*
+ * FastParsingAction.hpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+#ifndef FASTPARSINGACTION_HPP_
+#define FASTPARSINGACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class CommandLineFastParsingAction : public Action {
+public:
+  CommandLineFastParsingAction();
+  virtual ~CommandLineFastParsingAction();
+
+  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 /* FASTPARSINGACTION_HPP_ */
Index: src/Actions/CmdAction/HelpAction.cpp
===================================================================
--- src/Actions/CmdAction/HelpAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/CmdAction/HelpAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,71 @@
+/*
+ * HelpAction.cpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/CmdAction/HelpAction.hpp"
+#include "CommandLineParser.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/MapOfActions.hpp"
+
+const char CommandLineHelpAction::NAME[] = "help";
+
+CommandLineHelpAction::CommandLineHelpAction() :
+  Action(NAME)
+{}
+
+CommandLineHelpAction::~CommandLineHelpAction()
+{}
+
+Action::state_ptr CommandLineHelpAction::performCall() {
+  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;
+  }
+}
+
+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));
+}
+
+Action::state_ptr CommandLineHelpAction::performRedo(Action::state_ptr _state){
+  return Action::failure;
+}
+
+bool CommandLineHelpAction::canUndo() {
+  return false;
+}
+
+bool CommandLineHelpAction::shouldUndo() {
+  return false;
+}
+
+const string CommandLineHelpAction::getName() {
+  return NAME;
+}
Index: src/Actions/CmdAction/HelpAction.hpp
===================================================================
--- src/Actions/CmdAction/HelpAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/CmdAction/HelpAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+/*
+ * HelpAction.hpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#ifndef HELPACTION_HPP_
+#define HELPACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class CommandLineHelpAction : public Action {
+public:
+  CommandLineHelpAction();
+  virtual ~CommandLineHelpAction();
+
+  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 /* HELPACTION_HPP_ */
Index: src/Actions/CmdAction/VerboseAction.cpp
===================================================================
--- src/Actions/CmdAction/VerboseAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/CmdAction/VerboseAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,73 @@
+/*
+ * VerboseAction.cpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/CmdAction/VerboseAction.hpp"
+#include "log.hpp"
+#include "verbose.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/MapOfActions.hpp"
+
+const char CommandLineVerboseAction::NAME[] = "verbose";
+
+CommandLineVerboseAction::CommandLineVerboseAction() :
+  Action(NAME)
+{}
+
+CommandLineVerboseAction::~CommandLineVerboseAction()
+{}
+
+Action::state_ptr CommandLineVerboseAction::performCall() {
+  Dialog *dialog = UIFactory::getInstance().makeDialog();
+  int verbosity = 2;
+
+  dialog->queryInt(NAME, &verbosity, MapOfActions::getInstance().getDescription(NAME));
+
+  if(dialog->display()) {
+    setVerbosity(verbosity);
+    DoLog(0) && (Log() << Verbose(0) << "Setting verbosity to " << verbosity << "." << endl);
+    delete dialog;
+    return Action::success;
+  } else {
+    delete dialog;
+    return Action::failure;
+  }
+}
+
+Action::state_ptr CommandLineVerboseAction::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 CommandLineVerboseAction::performRedo(Action::state_ptr _state){
+  return Action::failure;
+}
+
+bool CommandLineVerboseAction::canUndo() {
+  return false;
+}
+
+bool CommandLineVerboseAction::shouldUndo() {
+  return false;
+}
+
+const string CommandLineVerboseAction::getName() {
+  return NAME;
+}
Index: src/Actions/CmdAction/VerboseAction.hpp
===================================================================
--- src/Actions/CmdAction/VerboseAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/CmdAction/VerboseAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+/*
+ * VerboseAction.hpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+#ifndef VERBOSEACTION_HPP_
+#define VERBOSEACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class CommandLineVerboseAction : public Action {
+public:
+  CommandLineVerboseAction();
+  virtual ~CommandLineVerboseAction();
+
+  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 /* VERBOSEACTION_HPP_ */
Index: src/Actions/CmdAction/VersionAction.cpp
===================================================================
--- src/Actions/CmdAction/VersionAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/CmdAction/VersionAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,68 @@
+/*
+ * VersionAction.cpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/CmdAction/VersionAction.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/MapOfActions.hpp"
+
+const char CommandLineVersionAction::NAME[] = "version";
+
+CommandLineVersionAction::CommandLineVersionAction() :
+  Action(NAME)
+{}
+
+CommandLineVersionAction::~CommandLineVersionAction()
+{}
+
+Action::state_ptr CommandLineVersionAction::performCall() {
+  Dialog *dialog = UIFactory::getInstance().makeDialog();
+
+  dialog->queryEmpty(NAME, ESPACKVersion);
+
+  if(dialog->display()) {
+    delete dialog;
+    return Action::success;
+  } else {
+    delete dialog;
+    return Action::failure;
+  }
+}
+
+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));
+}
+
+Action::state_ptr CommandLineVersionAction::performRedo(Action::state_ptr _state){
+  return Action::failure;
+}
+
+bool CommandLineVersionAction::canUndo() {
+  return false;
+}
+
+bool CommandLineVersionAction::shouldUndo() {
+  return false;
+}
+
+const string CommandLineVersionAction::getName() {
+  return NAME;
+}
Index: src/Actions/CmdAction/VersionAction.hpp
===================================================================
--- src/Actions/CmdAction/VersionAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/CmdAction/VersionAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,31 @@
+/*
+ * VersionAction.hpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#ifndef VERSIONACTION_HPP_
+#define VERSIONACTION_HPP_
+
+#include "Actions/Action.hpp"
+#include "version.h"
+
+class CommandLineVersionAction : public Action {
+public:
+  CommandLineVersionAction();
+  virtual ~CommandLineVersionAction();
+
+  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 /* VERSIONACTION_HPP_ */
Index: src/Actions/ErrorAction.cpp
===================================================================
--- src/Actions/ErrorAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/ErrorAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,49 @@
+/*
+ * ErrorAction.cpp
+ *
+ *  Created on: Jan 5, 2010
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include <iostream>
+
+#include "Actions/ErrorAction.hpp"
+#include "log.hpp"
+#include "verbose.hpp"
+#include "Helpers/Assert.hpp"
+
+using namespace std;
+
+ErrorAction::ErrorAction(string _name,const char * _errorMsg,bool _doRegister) :
+Action(_name,_doRegister),
+errorMsg(_errorMsg)
+{
+}
+
+ErrorAction::~ErrorAction()
+{
+}
+
+Action::state_ptr ErrorAction::performCall() {
+  Log() << Verbose(0) << errorMsg << endl;
+  return Action::success;
+}
+Action::state_ptr ErrorAction::performUndo(Action::state_ptr) {
+  ASSERT(0,"Undo called for an ErrorAction");
+  return Action::success;
+}
+
+Action::state_ptr ErrorAction::performRedo(Action::state_ptr) {
+  ASSERT(0,"Redo called for an ErrorAction");
+  return Action::success;
+}
+
+bool ErrorAction::canUndo(){
+  return false;
+}
+
+bool ErrorAction::shouldUndo(){
+  return false;
+}
Index: src/Actions/ErrorAction.hpp
===================================================================
--- src/Actions/ErrorAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/ErrorAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,32 @@
+/*
+ * ErrorAction.hpp
+ *
+ *  Created on: Jan 5, 2010
+ *      Author: crueger
+ */
+
+#ifndef ERRORACTION_HPP_
+#define ERRORACTION_HPP_
+
+#include <string>
+#include "Actions/Action.hpp"
+
+class ErrorAction : public Action
+{
+public:
+  ErrorAction(std::string _name,const char * _errorMsg,bool _doRegister=true);
+  virtual ~ErrorAction();
+
+  virtual bool canUndo();
+  virtual bool shouldUndo();
+
+private:
+
+  virtual Action::state_ptr performCall();
+  virtual Action::state_ptr performUndo(Action::state_ptr);
+  virtual Action::state_ptr performRedo(Action::state_ptr);
+
+  std::string errorMsg;
+};
+
+#endif /* ERRORACTION_HPP_ */
Index: src/Actions/FragmentationAction/DepthFirstSearchAction.cpp
===================================================================
--- src/Actions/FragmentationAction/DepthFirstSearchAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/FragmentationAction/DepthFirstSearchAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,106 @@
+/*
+ * DepthFirstSearchAction.cpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/FragmentationAction/DepthFirstSearchAction.hpp"
+#include "atom.hpp"
+#include "bondgraph.hpp"
+#include "config.hpp"
+#include "log.hpp"
+#include "molecule.hpp"
+#include "Descriptors/MoleculeDescriptor.hpp"
+#include "Descriptors/MoleculeIdDescriptor.hpp"
+#include "stackclass.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 FragmentationDepthFirstSearchAction::NAME[] = "depth-first-search";
+
+FragmentationDepthFirstSearchAction::FragmentationDepthFirstSearchAction() :
+  Action(NAME)
+{}
+
+FragmentationDepthFirstSearchAction::~FragmentationDepthFirstSearchAction()
+{}
+
+Action::state_ptr FragmentationDepthFirstSearchAction::performCall() {
+  Dialog *dialog = UIFactory::getInstance().makeDialog();
+  double distance;
+
+  dialog->queryDouble(NAME, &distance, MapOfActions::getInstance().getDescription(NAME));
+
+  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);
+    }
+    delete(BackEdgeStack);
+    delete[](MinimumRingSize);
+    delete dialog;
+    return Action::success;
+  } else {
+    delete dialog;
+    return Action::failure;
+  }
+}
+
+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));
+}
+
+Action::state_ptr FragmentationDepthFirstSearchAction::performRedo(Action::state_ptr _state){
+  return Action::failure;
+}
+
+bool FragmentationDepthFirstSearchAction::canUndo() {
+  return false;
+}
+
+bool FragmentationDepthFirstSearchAction::shouldUndo() {
+  return false;
+}
+
+const string FragmentationDepthFirstSearchAction::getName() {
+  return NAME;
+}
Index: src/Actions/FragmentationAction/DepthFirstSearchAction.hpp
===================================================================
--- src/Actions/FragmentationAction/DepthFirstSearchAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/FragmentationAction/DepthFirstSearchAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+/*
+ * DepthFirstSearchAction.hpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+#ifndef DEPTHFIRSTSEARCHACTION_HPP_
+#define DEPTHFIRSTSEARCHACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class FragmentationDepthFirstSearchAction : public Action {
+public:
+  FragmentationDepthFirstSearchAction();
+  virtual ~FragmentationDepthFirstSearchAction();
+
+  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 /* DEPTHFIRSTSEARCHACTION_HPP_ */
Index: src/Actions/FragmentationAction/FragmentationAction.cpp
===================================================================
--- src/Actions/FragmentationAction/FragmentationAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/FragmentationAction/FragmentationAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,100 @@
+/*
+ * FragmentationAction.cpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/FragmentationAction/FragmentationAction.hpp"
+#include "atom.hpp"
+#include "bondgraph.hpp"
+#include "config.hpp"
+#include "log.hpp"
+#include "molecule.hpp"
+#include "Descriptors/MoleculeDescriptor.hpp"
+#include "stackclass.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 FragmentationFragmentationAction::NAME[] = "fragment-mol";
+
+FragmentationFragmentationAction::FragmentationFragmentationAction() :
+  Action(NAME)
+{}
+
+FragmentationFragmentationAction::~FragmentationFragmentationAction()
+{}
+
+Action::state_ptr FragmentationFragmentationAction::performCall() {
+  Dialog *dialog = UIFactory::getInstance().makeDialog();
+  clock_t start,end;
+  molecule *mol = NULL;
+  double distance = -1.;
+  int order = 0;
+  std::string path;
+  config *configuration = World::getInstance().getConfig();
+  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"));
+
+  if(dialog->display()) {
+    cout << "POST-dialog"<< endl;
+    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);
+    DoLog(0) && (Log() << Verbose(0) << "Creating connection matrix..." << endl);
+    start = clock();
+    mol->CreateAdjacencyList(distance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
+    DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl);
+    if (mol->hasBondStructure()) {
+      ExitFlag = mol->FragmentMolecule(order, path);
+    }
+    World::getInstance().setExitFlag(ExitFlag);
+    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;
+  }
+}
+
+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));
+}
+
+Action::state_ptr FragmentationFragmentationAction::performRedo(Action::state_ptr _state){
+  return Action::failure;
+}
+
+bool FragmentationFragmentationAction::canUndo() {
+  return false;
+}
+
+bool FragmentationFragmentationAction::shouldUndo() {
+  return false;
+}
+
+const string FragmentationFragmentationAction::getName() {
+  return NAME;
+}
Index: src/Actions/FragmentationAction/FragmentationAction.hpp
===================================================================
--- src/Actions/FragmentationAction/FragmentationAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/FragmentationAction/FragmentationAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+/*
+ * FragmentationAction.hpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+#ifndef FRAGMENTATIONACTION_HPP_
+#define FRAGMENTATIONACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class FragmentationFragmentationAction : public Action {
+public:
+  FragmentationFragmentationAction();
+  virtual ~FragmentationFragmentationAction();
+
+  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 /* FRAGMENTATIONACTION_HPP_ */
Index: src/Actions/FragmentationAction/SubgraphDissectionAction.cpp
===================================================================
--- src/Actions/FragmentationAction/SubgraphDissectionAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/FragmentationAction/SubgraphDissectionAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,79 @@
+/*
+ * SubgraphDissectionAction.cpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/FragmentationAction/SubgraphDissectionAction.hpp"
+#include "atom.hpp"
+#include "config.hpp"
+#include "log.hpp"
+#include "molecule.hpp"
+#include "Descriptors/MoleculeDescriptor.hpp"
+#include "stackclass.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 FragmentationSubgraphDissectionAction::NAME[] = "subgraph-dissect";
+
+FragmentationSubgraphDissectionAction::FragmentationSubgraphDissectionAction() :
+  Action(NAME)
+{}
+
+FragmentationSubgraphDissectionAction::~FragmentationSubgraphDissectionAction()
+{}
+
+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
+    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));
+}
+
+Action::state_ptr FragmentationSubgraphDissectionAction::performRedo(Action::state_ptr _state){
+  return Action::failure;
+}
+
+bool FragmentationSubgraphDissectionAction::canUndo() {
+  return false;
+}
+
+bool FragmentationSubgraphDissectionAction::shouldUndo() {
+  return false;
+}
+
+const string FragmentationSubgraphDissectionAction::getName() {
+  return NAME;
+}
Index: src/Actions/FragmentationAction/SubgraphDissectionAction.hpp
===================================================================
--- src/Actions/FragmentationAction/SubgraphDissectionAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/FragmentationAction/SubgraphDissectionAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+/*
+ * SubgraphDissectionAction.hpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+#ifndef SUBGRAPHDISSECTIONACTION_HPP_
+#define SUBGRAPHDISSECTIONACTION_HPP_f
+
+#include "Actions/Action.hpp"
+
+class FragmentationSubgraphDissectionAction : public Action {
+public:
+  FragmentationSubgraphDissectionAction();
+  virtual ~FragmentationSubgraphDissectionAction();
+
+  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 /* SUBGRAPHDISSECTIONACTION_HPP_ */
Index: src/Actions/Makefile.am
===================================================================
--- src/Actions/Makefile.am	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/Makefile.am	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,144 @@
+# 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)
+
+noinst_LIBRARIES = libMolecuilderActions.a
+libMolecuilderActions_a_SOURCES = ${ACTIONSSOURCE} ${ACTIONSHEADER}
+
+ACTIONSSOURCE = \
+  ${ANALYSISACTIONSOURCE} \
+  ${ATOMACTIONSOURCE} \
+  ${CMDACTIONSOURCE} \
+  ${FRAGMENTATIONACTIONSOURCE} \
+  ${MOLECULEACTIONSOURCE} \
+  ${PARSERACTIONSOURCE} \
+  ${TESSELATIONACTIONSOURCE} \
+  ${WORLDACTIONSOURCE} \
+  MapOfActions.cpp
+
+ACTIONSHEADER = \
+  ${ANALYSISACTIONHEADER} \
+  ${ATOMACTIONHEADER} \
+  ${CMDACTIONHEADER} \
+  ${FRAGMENTATIONACTIONHEADER} \
+  ${MOLECULEACTIONHEADER} \
+  ${PARSERACTIONHEADER} \
+  ${TESSELATIONACTIONHEADER} \
+  ${WORLDACTIONHEADER} \
+  MapOfActions.hpp \
+  Values.hpp
+  
+ANALYSISACTIONSOURCE = \
+  AnalysisAction/MolecularVolumeAction.cpp \
+  AnalysisAction/PairCorrelationAction.cpp \
+  AnalysisAction/PrincipalAxisSystemAction.cpp
+ANALYSISACTIONHEADER = \
+  AnalysisAction/MolecularVolumeAction.hpp \
+  AnalysisAction/PairCorrelationAction.hpp \
+  AnalysisAction/PrincipalAxisSystemAction.hpp
+
+ATOMACTIONSOURCE = \
+  AtomAction/AddAction.cpp \
+  AtomAction/ChangeElementAction.cpp \
+  AtomAction/RemoveAction.cpp
+ATOMACTIONHEADER = \
+  AtomAction/AddAction.hpp \
+  AtomAction/ChangeElementAction.hpp \
+  AtomAction/RemoveAction.cpp
+
+CMDACTIONSOURCE = \
+  CmdAction/BondLengthTableAction.cpp \
+  CmdAction/ElementDbAction.cpp \
+  CmdAction/FastParsingAction.cpp \
+  CmdAction/HelpAction.cpp \
+  CmdAction/VerboseAction.cpp \
+  CmdAction/VersionAction.cpp
+CMDACTIONHEADER = \
+  CmdAction/BondLengthTableAction.hpp \
+  CmdAction/ElementDbAction.hpp \
+  CmdAction/FastParsingAction.hpp \
+  CmdAction/HelpAction.hpp \
+  CmdAction/VerboseAction.hpp \
+  CmdAction/VersionAction.hpp
+
+FRAGMENTATIONACTIONSOURCE = \
+  FragmentationAction/DepthFirstSearchAction.cpp \
+  FragmentationAction/FragmentationAction.cpp \
+  FragmentationAction/SubgraphDissectionAction.cpp               
+FRAGMENTATIONACTIONHEADER = \
+  FragmentationAction/DepthFirstSearchAction.hpp \
+  FragmentationAction/FragmentationAction.hpp \
+  FragmentationAction/SubgraphDissectionAction.hpp
+
+MOLECULEACTIONSOURCE = \
+  MoleculeAction/BondFileAction.cpp \
+  MoleculeAction/ChangeNameAction.cpp \
+  MoleculeAction/FillWithMoleculeAction.cpp \
+  MoleculeAction/LinearInterpolationofTrajectoriesAction.cpp \
+  MoleculeAction/RotateToPrincipalAxisSystemAction.cpp \
+  MoleculeAction/SaveAdjacencyAction.cpp \
+  MoleculeAction/SaveBondsAction.cpp \
+  MoleculeAction/SaveTemperatureAction.cpp \
+  MoleculeAction/SuspendInWaterAction.cpp \
+  MoleculeAction/TranslateAction.cpp \
+  MoleculeAction/VerletIntegrationAction.cpp
+MOLECULEACTIONHEADER = \
+  MoleculeAction/BondFileAction.hpp \
+  MoleculeAction/ChangeNameAction.hpp \
+  MoleculeAction/FillWithMoleculeAction.hpp \
+  MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp \
+  MoleculeAction/RotateToPrincipalAxisSystemAction.hpp \
+  MoleculeAction/SaveAdjacencyAction.hpp \
+  MoleculeAction/SaveBondsAction.hpp \
+  MoleculeAction/SaveTemperatureAction.hpp \
+  MoleculeAction/SuspendInWaterAction.hpp \
+  MoleculeAction/TranslateAction.hpp \
+  MoleculeAction/VerletIntegrationAction.hpp
+                 
+PARSERACTIONSOURCE = \
+  ParserAction/LoadXyzAction.cpp \
+  ParserAction/SaveXyzAction.cpp       
+PARSERACTIONHEADER = \
+  ParserAction/LoadXyzAction.hpp \
+  ParserAction/SaveXyzAction.hpp
+
+TESSELATIONACTIONSOURCE = \
+  TesselationAction/ConvexEnvelopeAction.cpp \
+  TesselationAction/NonConvexEnvelopeAction.cpp               
+TESSELATIONACTIONHEADER = \
+  TesselationAction/ConvexEnvelopeAction.hpp \
+  TesselationAction/NonConvexEnvelopeAction.hpp
+
+WORLDACTIONSOURCE = \
+  WorldAction/AddEmptyBoundaryAction.cpp \
+  WorldAction/BoundInBoxAction.cpp \
+  WorldAction/CenterInBoxAction.cpp \
+  WorldAction/CenterOnEdgeAction.cpp \
+  WorldAction/ChangeBoxAction.cpp \
+  WorldAction/InputAction.cpp \
+  WorldAction/OutputAction.cpp \
+  WorldAction/RemoveSphereOfAtomsAction.cpp \
+  WorldAction/RepeatBoxAction.cpp \
+  WorldAction/ScaleBoxAction.cpp \
+  WorldAction/SetDefaultNameAction.cpp \
+  WorldAction/SetGaussianBasisAction.cpp \
+  WorldAction/SetOutputFormatsAction.cpp
+WORLDACTIONHEADER = \
+  WorldAction/AddEmptyBoundaryAction.hpp \
+  WorldAction/BoundInBoxAction.hpp \
+  WorldAction/CenterInBoxAction.hpp \
+  WorldAction/CenterOnEdgeAction.hpp \
+  WorldAction/ChangeBoxAction.hpp \
+  WorldAction/InputAction.hpp \
+  WorldAction/OutputAction.hpp \
+  WorldAction/RemoveSphereOfAtomsAction.hpp \
+  WorldAction/RepeatBoxAction.hpp \
+  WorldAction/ScaleBoxAction.hpp \
+  WorldAction/SetDefaultNameAction.hpp \
+  WorldAction/SetGaussianBasisAction.hpp \
+  WorldAction/SetOutputFormatsAction.hpp               
+
Index: src/Actions/MakroAction.cpp
===================================================================
--- src/Actions/MakroAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/MakroAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,72 @@
+/*
+ * MakroAction.cpp
+ *
+ *  Created on: Dec 17, 2009
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include <string>
+
+#include "Actions/MakroAction.hpp"
+#include "Actions/Action.hpp"
+#include "Actions/ActionSequence.hpp"
+#include "Helpers/Assert.hpp"
+
+using namespace std;
+
+class MakroActionState : public ActionState{
+public:
+  MakroActionState(ActionSequence::stateSet _states) :
+    states(_states)
+  {}
+  virtual ~MakroActionState(){
+    // All contained states are destroyed by the shared ptrs
+  }
+
+  ActionSequence::stateSet states;
+};
+
+MakroAction::MakroAction(string _name,ActionSequence* _actions,bool _doRegister) :
+Action(_name,_doRegister),
+actions(_actions)
+{
+}
+
+MakroAction::~MakroAction()
+{
+  Action* action;
+  while((action=actions->removeLastAction())){
+    delete action;
+  }
+  delete actions;
+}
+
+
+Action::state_ptr MakroAction::performCall(){
+  ActionSequence::stateSet states = actions->callAll(true);
+  return Action::state_ptr(new MakroActionState(states));
+}
+
+Action::state_ptr MakroAction::performUndo(Action::state_ptr _state) {
+  MakroActionState *state = dynamic_cast<MakroActionState*>(_state.get());
+  ASSERT(state,"Type mismatch for the state of the MakroAction");
+  ActionSequence::stateSet states = actions->undoAll(state->states);
+  return Action::state_ptr(new MakroActionState(states));
+}
+
+Action::state_ptr MakroAction::performRedo(Action::state_ptr _state){
+  MakroActionState *state = dynamic_cast<MakroActionState*>(_state.get());
+  ASSERT(state,"Type mismatch for the state of the MakroAction");
+  ActionSequence::stateSet states = actions->redoAll(state->states);
+  return Action::state_ptr(new MakroActionState(states));
+}
+
+bool MakroAction::canUndo() {
+  return actions->canUndo();
+}
+
+bool MakroAction::shouldUndo() {
+  return actions->shouldUndo();
+}
Index: src/Actions/MakroAction.hpp
===================================================================
--- src/Actions/MakroAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/MakroAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,39 @@
+/*
+ * MakroAction.hpp
+ *
+ *  Created on: Dec 17, 2009
+ *      Author: crueger
+ */
+
+#ifndef MAKROACTION_HPP_
+#define MAKROACTION_HPP_
+
+#include <string>
+
+#include "Actions/Action.hpp"
+
+class ActionSequence;
+
+/**
+ * Action to allow producing bigger Actions from sequences of small actions.
+ *
+ * Destruction of the Actions and the sequence is handled by this class.
+ */
+class MakroAction : public Action
+{
+public:
+  MakroAction(std::string _name,ActionSequence* _actions,bool _doRegister=true);
+  virtual ~MakroAction();
+
+  bool canUndo();
+  bool shouldUndo();
+
+private:
+  virtual Action::state_ptr performCall();
+  virtual Action::state_ptr performUndo(Action::state_ptr);
+  virtual Action::state_ptr performRedo(Action::state_ptr);
+
+  ActionSequence *actions;
+};
+
+#endif /* MAKROACTION_HPP_ */
Index: src/Actions/ManipulateAtomsProcess.cpp
===================================================================
--- src/Actions/ManipulateAtomsProcess.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/ManipulateAtomsProcess.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,60 @@
+/*
+ * ManipulateAtomsProcess.cpp
+ *
+ *  Created on: Feb 18, 2010
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "ManipulateAtomsProcess.hpp"
+
+#include <iostream>
+
+#include "World.hpp"
+#include "Helpers/Assert.hpp"
+
+using namespace std;
+
+ManipulateAtomsProcess::ManipulateAtomsProcess(boost::function<void(atom*)> _operation, AtomDescriptor _descr,
+                                               std::string _name,bool _doRegister) :
+  Process(0,_name,_doRegister),
+  descr(_descr),
+  operation(_operation)
+{}
+
+ManipulateAtomsProcess::~ManipulateAtomsProcess()
+{}
+
+Action::state_ptr ManipulateAtomsProcess::performCall(){
+  World::getInstance().doManipulate(this);
+  return Action::success;
+}
+
+Action::state_ptr ManipulateAtomsProcess::performUndo(Action::state_ptr){
+  ASSERT(0,"Undo called for a ManipulateAtomsProcess");
+  return Action::success;
+}
+
+Action::state_ptr ManipulateAtomsProcess::performRedo(Action::state_ptr){
+  ASSERT(0,"Redo called for a ManipulateAtomsProcess");
+  return Action::success;
+}
+
+bool ManipulateAtomsProcess::canUndo(){
+  return false;
+}
+
+bool ManipulateAtomsProcess::shouldUndo(){
+  return true;
+}
+
+void ManipulateAtomsProcess::doManipulate(World *world){
+  setMaxSteps(world->numAtoms());
+  start();
+  for(World::AtomIterator iter=world->getAtomIter(descr);iter!=world->atomEnd();++iter){
+    setCurrStep(iter.getCount());
+    operation(*iter);
+  }
+  stop();
+}
Index: src/Actions/ManipulateAtomsProcess.hpp
===================================================================
--- src/Actions/ManipulateAtomsProcess.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/ManipulateAtomsProcess.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,39 @@
+/*
+ * ManipulateAtomsProcess.hpp
+ *
+ *  Created on: Feb 18, 2010
+ *      Author: crueger
+ */
+
+#ifndef MANIPULATEATOMSPROCESS_HPP_
+#define MANIPULATEATOMSPROCESS_HPP_
+
+#include "Actions/Process.hpp"
+
+#include<boost/function.hpp>
+
+#include "Descriptors/AtomDescriptor.hpp"
+
+class World;
+
+class ManipulateAtomsProcess : public Process
+{
+public:
+  ManipulateAtomsProcess(boost::function<void(atom*)> _operation, AtomDescriptor descr,std::string _name,bool _doRegister=true);
+  virtual ~ManipulateAtomsProcess();
+
+  virtual bool canUndo();
+  virtual bool shouldUndo();
+
+  virtual void doManipulate(World *);
+private:
+
+  virtual Action::state_ptr performCall();
+  virtual Action::state_ptr performUndo(Action::state_ptr);
+  virtual Action::state_ptr performRedo(Action::state_ptr);
+
+  AtomDescriptor descr;
+  boost::function<void(atom*)> operation;
+};
+
+#endif /* MANIPULATEATOMSPROCESS_HPP_ */
Index: src/Actions/MapOfActions.cpp
===================================================================
--- src/Actions/MapOfActions.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/MapOfActions.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,794 @@
+/*
+ * MapOfActions.cpp
+ *
+ *  Created on: 10.05.2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+using namespace std;
+
+#include "Patterns/Singleton_impl.hpp"
+#include "Actions/MapOfActions.hpp"
+#include "Helpers/Assert.hpp"
+
+#include <boost/lexical_cast.hpp>
+#include <boost/optional.hpp>
+#include <boost/program_options.hpp>
+
+#include "CommandLineParser.hpp"
+#include "log.hpp"
+#include "verbose.hpp"
+
+#include "Actions/ActionRegistry.hpp"
+#include "Actions/AnalysisAction/MolecularVolumeAction.hpp"
+#include "Actions/AnalysisAction/PairCorrelationAction.hpp"
+#include "Actions/AnalysisAction/PrincipalAxisSystemAction.hpp"
+#include "Actions/AtomAction/AddAction.hpp"
+#include "Actions/AtomAction/ChangeElementAction.hpp"
+#include "Actions/AtomAction/RemoveAction.hpp"
+#include "Actions/CmdAction/BondLengthTableAction.hpp"
+#include "Actions/CmdAction/ElementDbAction.hpp"
+#include "Actions/CmdAction/FastParsingAction.hpp"
+#include "Actions/CmdAction/HelpAction.hpp"
+#include "Actions/CmdAction/VerboseAction.hpp"
+#include "Actions/CmdAction/VersionAction.hpp"
+#include "Actions/FragmentationAction/DepthFirstSearchAction.hpp"
+#include "Actions/FragmentationAction/SubgraphDissectionAction.hpp"
+#include "Actions/FragmentationAction/FragmentationAction.hpp"
+#include "Actions/MoleculeAction/BondFileAction.hpp"
+#include "Actions/MoleculeAction/ChangeNameAction.hpp"
+#include "Actions/MoleculeAction/FillWithMoleculeAction.hpp"
+#include "Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp"
+#include "Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp"
+#include "Actions/MoleculeAction/SaveAdjacencyAction.hpp"
+#include "Actions/MoleculeAction/SaveBondsAction.hpp"
+#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/TesselationAction/ConvexEnvelopeAction.hpp"
+#include "Actions/TesselationAction/NonConvexEnvelopeAction.hpp"
+#include "Actions/WorldAction/AddEmptyBoundaryAction.hpp"
+#include "Actions/WorldAction/BoundInBoxAction.hpp"
+#include "Actions/WorldAction/CenterInBoxAction.hpp"
+#include "Actions/WorldAction/CenterOnEdgeAction.hpp"
+#include "Actions/WorldAction/ChangeBoxAction.hpp"
+#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"
+#include "Actions/WorldAction/SetDefaultNameAction.hpp"
+#include "Actions/WorldAction/SetGaussianBasisAction.hpp"
+#include "Actions/WorldAction/SetOutputFormatsAction.hpp"
+#include "Actions/Values.hpp"
+
+void validate(boost::any& v, const std::vector<std::string>& values, VectorValue *, int)
+{
+  VectorValue VV;
+  std::vector<std::string> components;
+
+  // split comma-separated values
+  if (values.size() != 1) {
+    cerr <<  "Not one vector but " << components.size() << " given " << endl;
+    throw boost::program_options::validation_error("Unequal to one vector given");
+  }
+  std::string argument(values.at(0));
+  std::string::iterator Aiter = argument.begin();
+  std::string::iterator Biter = argument.begin();
+  for (; Aiter != argument.end(); ++Aiter) {
+    if (*Aiter == ',') {
+      components.push_back(string(Biter,Aiter));
+      do {
+        Aiter++;
+      } while (*Aiter == ' ' || *Aiter == '\t');
+      Biter = Aiter;
+    }
+  }
+  components.push_back(string(Biter,argument.end()));
+
+  if (components.size() != 3) {
+    cerr <<  "Specified vector does not have three components but " << components.size() << endl;
+    throw boost::program_options::validation_error("Specified vector does not have three components");
+  }
+  VV.x = boost::lexical_cast<double>(components.at(0));
+  VV.y = boost::lexical_cast<double>(components.at(1));
+  VV.z = boost::lexical_cast<double>(components.at(2));
+  v = boost::any(VectorValue(VV));
+}
+
+void validate(boost::any& v, const std::vector<std::string>& values, BoxValue *, int)
+{
+  BoxValue BV;
+  std::vector<std::string> components;
+
+  // split comma-separated values
+  if (values.size() != 1) {
+    cerr <<  "Not one vector but " << components.size() << " given " << endl;
+    throw boost::program_options::validation_error("Unequal to one vector given");
+  }
+  std::string argument(values.at(0));
+  std::string::iterator Aiter = argument.begin();
+  std::string::iterator Biter = argument.begin();
+  for (; Aiter != argument.end(); ++Aiter) {
+    if (*Aiter == ',') {
+      components.push_back(string(Biter,Aiter));
+      do {
+        Aiter++;
+      } while (*Aiter == ' ' || *Aiter == '\t');
+      Biter = Aiter;
+    }
+  }
+  components.push_back(string(Biter,argument.end()));
+
+  if (components.size() != 6) {
+    cerr <<  "Specified vector does not have three components but " << components.size() << endl;
+    throw boost::program_options::validation_error("Specified symmetric box matrix does not have six components");
+  }
+  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.zz = boost::lexical_cast<double>(components.at(5));
+  v = boost::any(BoxValue(BV));
+}
+
+/** Constructor of class MapOfActions.
+ *
+ */
+MapOfActions::MapOfActions()
+{
+  // initialise lookup map
+  CmdParserLookup[&generic] = &(CommandLineParser::getInstance().generic);
+  CmdParserLookup[&config] = &(CommandLineParser::getInstance().config);
+  CmdParserLookup[&hidden] = &(CommandLineParser::getInstance().hidden);
+  CmdParserLookup[&visible] = &(CommandLineParser::getInstance().visible);
+
+  // keys for actions
+  DescriptionMap["add-atom"] = "add atom of specified element";
+  DescriptionMap["bond-table"] = "setting name of the bond length table file";
+  DescriptionMap["bond-file"] = "name of the bond file";
+  DescriptionMap["boundary"] = "change box to add an empty boundary around all atoms";
+  DescriptionMap["bound-in-box"] = "bound all atoms in the domain";
+  DescriptionMap["center-edge"] = "center edge of all atoms on (0,0,0)";
+  DescriptionMap["center-in-box"] = "center all atoms in the domain";
+  DescriptionMap["change-box"] = "change the symmetrc matrix of the simulation domain";
+  DescriptionMap["change-element"] = "change the element of an atom";
+  DescriptionMap["change-molname"] = "change the name of a molecule";
+  DescriptionMap["convex-envelope"] = "create the convex envelope for a molecule";
+  DescriptionMap["default-molname"] = "set the default name of new molecules";
+  DescriptionMap["depth-first-search"] = "Depth-First Search analysis of the molecular system";
+  DescriptionMap["element-db"] = "setting the path where the element databases can be found";
+  DescriptionMap["fastparsing"] = "setting whether trajectories shall be parsed completely (n) or just first step (y)";
+  DescriptionMap["fill-molecule"] = "fill empty space of box with a filler molecule";
+  DescriptionMap["fragment-mol"] = "create for a given molecule into fragments up to given order";
+  DescriptionMap["help"] = "Give this help screen";
+  DescriptionMap["input"] = "specify input files";
+  DescriptionMap["linear-interpolate"] = "linear interpolation in discrete steps between start and end position of a molecule";
+  DescriptionMap["molecular-volume"] = "calculate the volume of a given molecule";
+  DescriptionMap["nonconvex-envelope"] = "create the non-convex envelope for a molecule";
+  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["parse-xyz"] = "parse xyz file into World";
+  DescriptionMap["principal-axis-system"] = "calculate the principal axis system of the specified molecule";
+  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-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";
+  DescriptionMap["save-bonds"] = "name of the bonds file to write to";
+  DescriptionMap["save-temperature"] = "name of the temperature file to write to";
+  DescriptionMap["SaveXyz"] = "save world as xyz file";
+  DescriptionMap["scale-box"] = "scale box and atomic positions inside";
+  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["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["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["bin-output-file"] = "name of the bin output file";
+  DescriptionMap["bin-end"] = "start of the last bin";
+  DescriptionMap["bin-start"] = "start of the first bin";
+  DescriptionMap["bin-width"] = "width of the bins";
+  DescriptionMap["convex-file"] = "filename of the non-convex envelope";
+  DescriptionMap["distance"] = "distance in space";
+  DescriptionMap["distances"] = "list of three of distances in space, one for each axis direction";
+  DescriptionMap["DoRotate"] = "whether to rotate or just report angles";
+  DescriptionMap["element"] = "single element";
+  DescriptionMap["elements"] = "set of elements";
+  DescriptionMap["end-step"] = "last or end step";
+  DescriptionMap["id-mapping"] = "whether the identity shall be used in mapping atoms onto atoms or some closest distance measure shall be used";
+  DescriptionMap["input"] = "name of input file";
+  DescriptionMap["length"] = "length in space";
+  DescriptionMap["lengths"] = "list of three of lengths in space, one for each axis direction";
+  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, ...";
+  DescriptionMap["output-file"] = "name of the output file";
+  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";
+
+  // short forms for the actions
+  ShortFormMap["add-atom"] = "a";
+  ShortFormMap["bond-table"] = "g";
+  ShortFormMap["bond-file"] = "A";
+  ShortFormMap["boundary"] = "c";
+  ShortFormMap["change-box"] = "B";
+  ShortFormMap["center-edge"] = "O";
+  ShortFormMap["center-in-box"] = "b";
+  ShortFormMap["change-element"] = "E";
+//  ShortFormMap["convex-envelope"] = "x";
+  ShortFormMap["default-molname"] = "X";
+  ShortFormMap["depth-first-search"] = "D";
+  ShortFormMap["element-db"] = "e";
+  ShortFormMap["fastparsing"] = "n";
+  ShortFormMap["fill-molecule"] = "F";
+  ShortFormMap["fragment-mol"] = "f";
+  ShortFormMap["help"] = "h";
+  ShortFormMap["input"] = "i";
+  ShortFormMap["linear-interpolate"] = "L";
+  ShortFormMap["nonconvex-envelope"] = "N";
+//  ShortFormMap["output"] = "o";
+  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";
+  ShortFormMap["save-adjacency"] = "J";
+  ShortFormMap["save-bonds"] = "j";
+  ShortFormMap["save-temperature"] = "S";
+  ShortFormMap["scale-box"] = "s";
+  ShortFormMap["set-basis"] = "M";
+  ShortFormMap["set-output"] = "o";
+  ShortFormMap["subgraph-dissect"] = "I";
+  ShortFormMap["suspend-in-water"] = "u";
+  ShortFormMap["translate-mol"] = "t";
+  ShortFormMap["verbose"] = "v";
+  ShortFormMap["verlet-integrate"] = "P";
+  ShortFormMap["version"] = "V";
+
+  // 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;
+
+  // 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;
+
+  // 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";
+
+  // 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["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");
+
+  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", "principal-axis-system") );
+
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("atom", "add-atom") );
+  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> ("command", "bond-table") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "element-db") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "fastparsing") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "verbose") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "version") );
+
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("fragmentation", "depth-first-search") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("fragmentation", "fragment-mol") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("fragmentation", "subgraph-dissect") );
+
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "bond-file") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "change-molname") );
+  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-to-pas") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "save-adjacency") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "save-bonds") );
+  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> ("tesselation", "convex-envelope") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("tesselation", "nonconvex-envelope") );
+
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "boundary") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "bound-in-box") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "center-in-box") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "center-edge") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "change-box") );
+  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") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "default-molname") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "set-basis") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "set-output") );
+
+  // put actions into command line category
+	generic.insert("add-atom");
+  generic.insert("bond-file");
+	generic.insert("bond-table");
+  generic.insert("boundary");
+//  generic.insert("bound-in-box");
+  generic.insert("center-edge");
+  generic.insert("center-in-box");
+	generic.insert("change-box");
+//  generic.insert("change-molname");
+	generic.insert("change-element");
+  generic.insert("convex-envelope");
+	generic.insert("default-molname");
+	generic.insert("depth-first-search");
+	generic.insert("element-db");
+	generic.insert("fastparsing");
+  generic.insert("fill-molecule");
+  generic.insert("fragment-mol");
+  generic.insert("help");
+  generic.insert("input");
+  generic.insert("linear-interpolate");
+//  generic.insert("molecular-volume");
+  generic.insert("nonconvex-envelope");
+  generic.insert("output");
+	generic.insert("pair-correlation");
+	generic.insert("parse-xyz");
+//  generic.insert("principal-axis-system");
+  generic.insert("remove-atom");
+  generic.insert("remove-sphere");
+  generic.insert("repeat-box");
+  generic.insert("rotate-to-pas");
+	generic.insert("save-adjacency");
+  generic.insert("save-bonds");
+  generic.insert("save-temperature");
+  generic.insert("scale-box");
+  generic.insert("set-basis");
+  generic.insert("set-output");
+	generic.insert("subgraph-dissect");
+  generic.insert("suspend-in-water");
+  generic.insert("translate-mol");
+	generic.insert("verbose");
+  generic.insert("verlet-integrate");
+	generic.insert("version");
+
+    // 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");
+}
+
+/** Destructor of class MapOfActions.
+ *
+ */
+MapOfActions::~MapOfActions()
+{
+  DescriptionMap.clear();
+}
+
+
+void MapOfActions::populateActions()
+{
+  new AnalysisMolecularVolumeAction();
+  new AnalysisPairCorrelationAction();
+  new AnalysisPrincipalAxisSystemAction();
+
+  new AtomAddAction();
+  new AtomChangeElementAction();
+  new AtomRemoveAction();
+
+  new CommandLineBondLengthTableAction();
+  new CommandLineElementDbAction();
+  new CommandLineFastParsingAction();
+  new CommandLineHelpAction();
+  new CommandLineVerboseAction();
+  new CommandLineVersionAction();
+
+  new FragmentationDepthFirstSearchAction();
+  new FragmentationFragmentationAction();
+  new FragmentationSubgraphDissectionAction();
+
+  new MoleculeBondFileAction();
+  new MoleculeChangeNameAction();
+  new MoleculeFillWithMoleculeAction();
+  new MoleculeLinearInterpolationofTrajectoriesAction();
+  new MoleculeRotateToPrincipalAxisSystemAction();
+  new MoleculeSaveAdjacencyAction();
+  new MoleculeSaveBondsAction();
+  new MoleculeSaveTemperatureAction();
+  new MoleculeSuspendInWaterAction();
+  new MoleculeTranslateAction();
+  new MoleculeVerletIntegrationAction();
+
+  new ParserLoadXyzAction();
+  new ParserSaveXyzAction();
+
+  new TesselationConvexEnvelopeAction();
+  new TesselationNonConvexEnvelopeAction();
+
+  new WorldAddEmptyBoundaryAction();
+  new WorldBoundInBoxAction();
+  new WorldCenterInBoxAction();
+  new WorldCenterOnEdgeAction();
+  new WorldChangeBoxAction();
+  new WorldInputAction();
+  new WorldOutputAction();
+  new WorldRemoveSphereOfAtomsAction();
+  new WorldRepeatBoxAction();
+  new WorldScaleBoxAction();
+  new WorldSetDefaultNameAction();
+  new WorldSetGaussianBasisAction();
+  new WorldSetOutputFormatsAction();
+}
+
+
+/** Adds all options to the CommandLineParser.
+ *
+ */
+void MapOfActions::AddOptionsToParser()
+{
+  // add other options
+  for (map< set<string>*, po::options_description* >::iterator ListRunner = CmdParserLookup.begin(); ListRunner != CmdParserLookup.end(); ++ListRunner) {
+    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]) {
+          default:
+          case None:
+            ListRunner->second->add_options()
+              (getKeyAndShortForm(*OptionRunner).c_str(), getDescription(*OptionRunner).c_str())
+              ;
+            break;
+          case Boolean:
+            ListRunner->second->add_options()
+              (getKeyAndShortForm(*OptionRunner).c_str(),
+                  DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
+                        po::value< bool >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
+                        po::value< bool >(),
+                  getDescription(*OptionRunner).c_str())
+              ;
+            break;
+          case Box:
+            ListRunner->second->add_options()
+              (getKeyAndShortForm(*OptionRunner).c_str(),
+                  po::value<BoxValue>()->multitoken(),
+                  getDescription(*OptionRunner).c_str())
+              ;
+            break;
+          case Integer:
+            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 ListOfInts:
+            ListRunner->second->add_options()
+              (getKeyAndShortForm(*OptionRunner).c_str(),
+                  po::value< vector<int> >()->multitoken(),
+                  getDescription(*OptionRunner).c_str())
+              ;
+            break;
+          case Double:
+            ListRunner->second->add_options()
+              (getKeyAndShortForm(*OptionRunner).c_str(),
+                  DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
+                        po::value< double >()->default_value(atof(DefaultValue[*OptionRunner].c_str())) :
+                        po::value< double >(),
+                  getDescription(*OptionRunner).c_str())
+              ;
+            break;
+          case ListOfDoubles:
+            ListRunner->second->add_options()
+              (getKeyAndShortForm(*OptionRunner).c_str(),
+                  po::value< vector<double> >()->multitoken(),
+                  getDescription(*OptionRunner).c_str())
+              ;
+            break;
+          case String:
+            ListRunner->second->add_options()
+              (getKeyAndShortForm(*OptionRunner).c_str(),
+                  DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
+                        po::value< std::string >()->default_value(DefaultValue[*OptionRunner]) :
+                        po::value< std::string >(),
+                  getDescription(*OptionRunner).c_str())
+              ;
+            break;
+          case ListOfString:
+            ListRunner->second->add_options()
+              (getKeyAndShortForm(*OptionRunner).c_str(),
+                  po::value< vector<std::string> >()->multitoken(),
+                  getDescription(*OptionRunner).c_str())
+              ;
+            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())) :
+                        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())) :
+                        po::value< int >(),
+                  getDescription(*OptionRunner).c_str())
+              ;
+            break;
+          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(),
+                  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> >(),
+                  getDescription(*OptionRunner).c_str())
+              ;
+            break;
+          case ListOfElements:
+            ListRunner->second->add_options()
+              (getKeyAndShortForm(*OptionRunner).c_str(),
+                  po::value< vector<int> >()->multitoken(),
+                  getDescription(*OptionRunner).c_str())
+              ;
+            break;
+        }
+      } else {
+        DoLog(0) && (Log() << Verbose(0) << "Adding option " << *OptionRunner << " to CommandLineParser." << endl);
+        ListRunner->second->add_options()
+          (getKeyAndShortForm(*OptionRunner).c_str(), getDescription(*OptionRunner).c_str())
+          ;
+      }
+    }
+  }
+  // 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;
+}
+
+/** Getter for MapOfActions:DescriptionMap.
+ * Note that we assert when action does not exist in CommandLineParser::DescriptionMap.
+ * \param actionname name of the action to lookup
+ * \return Description of the action
+ */
+std::string MapOfActions::getDescription(string actionname)
+{
+  ASSERT(DescriptionMap.find(actionname) != DescriptionMap.end(), "Unknown action name passed to MapOfActions::getDescription");
+  return DescriptionMap[actionname];
+}
+
+/** Specific Getter for a MapOfActions:ShortFormMap.
+ * If action has a short for, then combination is as "actionname,ShortForm" (this is
+ * the desired format for boost::program_options). If no short form exists in the map,
+ * just actionname will be returned
+ * Note that we assert when action does not exist in CommandLineParser::DescriptionMap.
+ * \param actionname name of the action to lookup
+ * \return actionname,ShortForm or Description of the action
+ */
+std::string MapOfActions::getKeyAndShortForm(string actionname)
+{
+  stringstream output;
+  ASSERT(DescriptionMap.find(actionname) != DescriptionMap.end(), "Unknown action name passed to MapOfActions::getDescriptionAndShortForm");
+  output << actionname;
+  if (ShortFormMap.find(actionname) != DescriptionMap.end())
+    output << "," << ShortFormMap[actionname];
+  return output.str();
+}
+
+/** Getter for MapOfActions:ShortFormMap.
+ * Note that we assert when action does not exist CommandLineParser::ShortFormMap.
+ * \param actionname name of the action to lookup
+ * \return ShortForm of the action
+ */
+std::string MapOfActions::getShortForm(string actionname)
+{
+  ASSERT(ShortFormMap.find(actionname) != ShortFormMap.end(), "Unknown action name passed to MapOfActions::getShortForm");
+  return ShortFormMap[actionname];
+}
+
+/** Returns whether the given action needs a value or not.
+ * \param actionname name of the action to look up
+ * \return true - value is needed, false - no value is stored in MapOfActions::TypeMap
+ */
+bool MapOfActions::hasValue(string actionname)
+{
+  return (TypeMap.find(actionname) != TypeMap.end());
+}
+
+/** Getter for MapOfActions::TypeMap.
+ * \param actionname name of the action to look up
+ * \return type of the action
+ */
+enum MapOfActions::OptionTypes MapOfActions::getValueType(string actionname)
+{
+  return TypeMap[actionname];
+}
+
+/** Searches whether action is registered with CommandLineParser.
+ * Note that this method is only meant transitionally for ParseCommandLineOptions' removal.
+ * I.e. All actions that are already handled by the new CommandLineUIFactory can be checked
+ * by this function.
+ * \param shortform command short form to look for
+ * \return true - action has been registered, false - action has not been registered.
+ */
+bool MapOfActions::isShortFormPresent(string shortform)
+{
+  bool result = false;
+  string actionname;
+  for (map<std::string, std::string>::iterator ShortFormRunner = ShortFormMap.begin(); ShortFormRunner != ShortFormMap.end(); ++ShortFormRunner)
+    if (ShortFormRunner->second == shortform) {
+      actionname = ShortFormRunner->first;
+      break;
+    }
+  result = result || (generic.find(actionname) != generic.end());
+  result = result || (config.find(actionname) != config.end());
+  result = result || (hidden.find(actionname) != hidden.end());
+  result = result || (visible.find(actionname) != visible.end());
+  result = result || (inputfile.find(actionname) != inputfile.end());
+  return result;
+}
+
+/** Returns the inverse to MapOfActions::ShortFormMap, i.e. lookup actionname for its short form.
+ * \return map from short form of action to name of action
+ */
+map <std::string, std::string> MapOfActions::getShortFormToActionMap()
+{
+  map <std::string, std::string> result;
+
+  for (map<std::string, std::string>::iterator iter = ShortFormMap.begin(); iter != ShortFormMap.end();  ++iter)
+    result[iter->second] = iter->first;
+
+  return result;
+}
+
+
+CONSTRUCT_SINGLETON(MapOfActions)
Index: src/Actions/MapOfActions.hpp
===================================================================
--- src/Actions/MapOfActions.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/MapOfActions.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,168 @@
+/*
+ * MapOfActions.hpp
+ *
+ *  Created on: 10.05.2010
+ *      Author: heber
+ */
+
+#ifndef MAPOFACTIONS_HPP_
+#define MAPOFACTIONS_HPP_
+
+#include "Helpers/Assert.hpp"
+#include <boost/program_options.hpp>
+
+#include <map>
+#include <set>
+
+class MapOfActionsTest;
+
+#include "Patterns/Singleton.hpp"
+
+namespace po = boost::program_options;
+
+/** Central class for adding functionality to the code.
+ *
+ * In Molecuilder everything that can be done - such as adding atoms,
+ * translating molecules, saving bind information - is an Action.
+ *
+ * In order to reference Action's with what the user sees, this class is the
+ * mediator.
+ *
+ * An Action is described to the user by:
+ * -# a name (this is the most important information)
+ * -# a description
+ * -# a shortform (single letter for use on the command line)
+ * -# a text menu it resides in
+ * -# the type of its argument
+ * -# the command line category
+ *
+ * The Action::NAME is the most important information because every Action
+ * registers itself automatically with the ActionRegistry and can be retrieved
+ * therefrom and from this MapOfActions simply by knowing its name alone.
+ *
+ * In the constructor of MapOfActions all this is set.
+ *
+ * Note that Action will require input from the user. This is done via class
+ * Query.
+ *
+ * And note also that MapOfActions actually contains more than just all
+ * Actions: There are a number of names that actually are just arguments to
+ * actions (e.g. "output-file").
+ *
+ * <h1> Howto add an Action</h1>
+ *
+ * Let us assume your new action (class) is called SuperDuperAction, consisting
+ * of two files SuperDuperAction.cpp and SuperDuperAction.hpp.
+ *
+ * Furthermore, let's say you Action needs two values: a double value as a
+ * upper threshold and a string which is the name of the output file.
+ *
+ * <h2> Command Line preliminaries </h2>
+ *
+ * You have to decide whether (for the command line) it makes sense to have an
+ * extra argument requesting the arguments, or one should be the argument of
+ * your action. I.e. your action name is "super-duper", then the use may
+ * call your action like this:
+ *
+ * ./molecuilder --super-duper 4 --output-file test.dat
+ *
+ * Here, we have picked the threshold as the value for your action and the
+ * name of the output file is given by an additional argument. Of course,
+ * it can be the other way round or by two arguments such as here:
+ *
+ * ./molecuilder --super-duper --threshold 4 --output-file test.dat
+ *
+ * It depends on what possible arguments are already there (don't make up
+ * new ones if present ones actually make sense for your action) and which
+ * argument is more natural or closer to what your action does.
+ *
+ * <h2> Menu preliminaries </h2>
+ *
+ * Whatever you decide, your action will need some Query dialogs to request
+ * the necessary information from the user, either via a command line
+ * argument (--output-file) via a text dialog (referenced by "output-file")
+ * or via a graphical dialog (same reference). And therein, the names
+ * of the arguments have to re-appear.
+ *
+ * Then, the following steps have to be done to incorporate your Action:
+ * -# create a unique name for your action (no capital letters) to reference
+ *    it, this name has to appear in the file SuperDuperAction.cpp, e.g.
+ *    "super-duper"
+ * -# pick names the other required arguments, best if they are already
+ *    present in the MapOfActions. They have to appear in Query's in the
+ *    code of your Action.
+ * -# With this name create entries in the following maps for the action
+ *    name and for each names of a desired addtional argument if not present:
+ *   -# DescriptionMap, a catchy description of what your action does
+ *   -# TypeMap, see MapOfActions::OptionTypes for possible types of the single
+ *      argument it takes.
+ *   -# MenuContainsActionMap, in which menu should your action appear
+ *   -# ShortFormMap (optional), single letter for command line call
+ *   -# DefaultValueMap (optional), the default value (always a string)
+ * -# add to one of the command line sets by the following categories
+ *   -# generic - generic options (i.e. not one of the others)
+ *   -# config - action/argument only considers internal bevahior, user
+ *      does not have to see it while still having full functionality
+ *   -# hidden - this should be hidden from the user
+ *   -# visible - this should be visible to the user
+ *   -# inputfile - this should only be parsed from an input file, not
+ *      from command line
+ * -# add to a menu, i.e. make an entry in MenuContainsActionMap.
+ * -# add header file SuperDuperAction.hpp to MapOfActions.cpp and instantiate
+ *    your action in populateMenu() (mind the sorting: 1. menu,
+ *    2. alphabetical)
+ *
+ *  And that's.
+ *
+ *  Now, your action can be called from the command line, within the text
+ *  menu and the graphical user interface.
+ *
+ */
+class MapOfActions : public Singleton<MapOfActions> {
+  friend class Singleton<MapOfActions>;
+  friend class MapOfActionsTest;
+public:
+  enum OptionTypes { None, Boolean, Integer, ListOfInts, Double, ListOfDoubles, String, ListOfString, Axis, Vector, Box, Molecule, ListOfMolecules, Atom, ListOfAtoms, Element, ListOfElements };
+
+  // getter for the action descriptions and short forms
+  std::string getDescription(std::string actionname);
+  std::string getKeyAndShortForm(std::string actionname);
+  std::string getShortForm(std::string actionname);
+  std::map <std::string, std::string> getShortFormToActionMap();
+
+  void AddOptionsToParser();
+
+  // check presence and getter for action type
+  bool hasValue(std::string actionname);
+  bool isShortFormPresent(std::string shortform);
+  enum OptionTypes getValueType(std::string actionname);
+
+  std::set<std::string> generic;
+  std::set<std::string> config;
+  std::set<std::string> hidden;
+  std::set<std::string> visible;
+  std::set<std::string> inputfile;
+
+  std::multimap <std::string, std::string> MenuContainsActionMap;
+  std::map <std::string, std::pair<std::string,std::string> > MenuDescription;
+
+  // instantiates and puts all known actions into the ActionRegistry
+  void populateActions();
+
+private:
+  // private constructor and destructor
+  MapOfActions();
+  virtual ~MapOfActions();
+
+  // lookup list from our configs to the ones of CommandLineParser
+  std::map< std::set<std::string> *, po::options_description *> CmdParserLookup;
+
+  // map of the action names and their description
+  std::map<std::string, std::string> DefaultValue;
+  std::map<std::string, std::string> DescriptionMap;
+  std::map<std::string, std::string> ShortFormMap;
+  std::map<std::string, enum OptionTypes > TypeMap;
+};
+
+
+#endif /* MAPOFACTIONS_HPP_ */
Index: src/Actions/MethodAction.cpp
===================================================================
--- src/Actions/MethodAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/MethodAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,51 @@
+/*
+ * MethodAction.cpp
+ *
+ *  Created on: Dec 11, 2009
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include <iostream>
+#include <boost/function.hpp>
+#include <string>
+
+#include "Actions/MethodAction.hpp"
+#include "Helpers/Assert.hpp"
+
+using namespace std;
+
+MethodAction::MethodAction(string _name,boost::function<void()> _executeMethod,bool _doRegister) :
+   Action(_name,_doRegister),
+executeMethod(_executeMethod)
+{
+}
+
+MethodAction::~MethodAction()
+{}
+
+
+Action::state_ptr MethodAction::performCall() {
+  executeMethod();
+  // we don't have a state to save so we return Action::success
+  return Action::success;
+}
+
+Action::state_ptr MethodAction::performUndo(Action::state_ptr) {
+  ASSERT(0,"Cannot undo a MethodAction");
+  return Action::success;
+}
+
+Action::state_ptr MethodAction::performRedo(Action::state_ptr){
+  ASSERT(0,"Cannot redo a MethodAction");
+  return Action::success;
+}
+
+bool MethodAction::canUndo() {
+  return false;
+}
+
+bool MethodAction::shouldUndo(){
+  return true;
+}
Index: src/Actions/MethodAction.hpp
===================================================================
--- src/Actions/MethodAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/MethodAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,36 @@
+/*
+ * MethodAction.h
+ *
+ *  Created on: Dec 11, 2009
+ *      Author: crueger
+ */
+
+#ifndef METHODACTION_H_
+#define METHODACTION_H_
+
+#include <boost/function.hpp>
+#include <string>
+
+#include "Actions/Action.hpp"
+
+/**
+ * Wrapper class that allows the construction of Actions from any kind of Method
+ */
+class MethodAction : public Action
+{
+public:
+  MethodAction(std::string _name,boost::function<void()> _executeMethod,bool _doRegister=true);
+  virtual ~MethodAction();
+  virtual bool canUndo();
+  virtual bool shouldUndo();
+
+private:
+  virtual Action::state_ptr performCall();
+  virtual Action::state_ptr performUndo(Action::state_ptr);
+  virtual Action::state_ptr performRedo(Action::state_ptr);
+
+
+  boost::function<void()> executeMethod; //!< this stores the method to be called
+};
+
+#endif /* METHODACTION_H_ */
Index: src/Actions/MoleculeAction/BondFileAction.cpp
===================================================================
--- src/Actions/MoleculeAction/BondFileAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/MoleculeAction/BondFileAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,98 @@
+/*
+ * BondFileAction.cpp
+ *
+ *  Created on: May 10, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/MoleculeAction/BondFileAction.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 "bondgraph.hpp"
+#include "config.hpp"
+#include "defs.hpp"
+#include "log.hpp"
+#include "molecule.hpp"
+#include "vector.hpp"
+#include "World.hpp"
+
+/****** MoleculeBondFileAction *****/
+
+// memento to remember the state when undoing
+
+//class MoleculeBondFileState : public ActionState {
+//public:
+//  MoleculeBondFileState(molecule* _mol,std::string _lastName) :
+//    mol(_mol),
+//    lastName(_lastName)
+//  {}
+//  molecule* mol;
+//  std::string lastName;
+//};
+
+const char MoleculeBondFileAction::NAME[] = "bond-file";
+
+MoleculeBondFileAction::MoleculeBondFileAction() :
+  Action(NAME)
+{}
+
+MoleculeBondFileAction::~MoleculeBondFileAction()
+{}
+
+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"));
+
+  if(dialog->display()) {
+    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;
+}
+
+Action::state_ptr MoleculeBondFileAction::performUndo(Action::state_ptr _state) {
+//  MoleculeBondFileState *state = assert_cast<MoleculeBondFileState*>(_state.get());
+
+//  string newName = state->mol->getName();
+//  state->mol->setName(state->lastName);
+
+  return Action::failure;
+}
+
+Action::state_ptr MoleculeBondFileAction::performRedo(Action::state_ptr _state){
+  // Undo and redo have to do the same for this action
+  return performUndo(_state);
+}
+
+bool MoleculeBondFileAction::canUndo() {
+  return false;
+}
+
+bool MoleculeBondFileAction::shouldUndo() {
+  return false;
+}
+
+const string MoleculeBondFileAction::getName() {
+  return NAME;
+}
Index: src/Actions/MoleculeAction/BondFileAction.hpp
===================================================================
--- src/Actions/MoleculeAction/BondFileAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/MoleculeAction/BondFileAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,34 @@
+/*
+ * BondFileAction.hpp
+ *
+ *  Created on: May 10, 2010
+ *      Author: heber
+ */
+
+#ifndef BONDFILEACTION_HPP
+#define BONDFILEACTION_HPP
+
+#include "Actions/Action.hpp"
+#include "Actions/Process.hpp"
+
+class MoleculeListClass;
+
+class MoleculeBondFileAction : public Action {
+public:
+  MoleculeBondFileAction();
+  virtual ~MoleculeBondFileAction();
+
+  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 // BONDFILEACTION_HPP
Index: src/Actions/MoleculeAction/ChangeNameAction.cpp
===================================================================
--- src/Actions/MoleculeAction/ChangeNameAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/MoleculeAction/ChangeNameAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,89 @@
+/*
+ * ChangeNameAction.cpp
+ *
+ *  Created on: Jan 15, 2010
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/MoleculeAction/ChangeNameAction.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/MapOfActions.hpp"
+
+#include "atom.hpp"
+#include "molecule.hpp"
+
+/****** MoleculeChangeNameAction *****/
+
+// memento to remember the state when undoing
+
+class MoleculeChangeNameState : public ActionState {
+public:
+  MoleculeChangeNameState(molecule* _mol,std::string _lastName) :
+    mol(_mol),
+    lastName(_lastName)
+  {}
+  molecule* mol;
+  std::string lastName;
+};
+
+const char MoleculeChangeNameAction::NAME[] = "change-molname";
+
+MoleculeChangeNameAction::MoleculeChangeNameAction() :
+  Action(NAME)
+{}
+
+MoleculeChangeNameAction::~MoleculeChangeNameAction()
+{}
+
+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);
+
+  if(dialog->display()) {
+    string oldName = mol->getName();
+    mol->setName(filename);
+    delete dialog;
+    return Action::state_ptr(new MoleculeChangeNameState(mol,oldName));
+  }
+  delete dialog;
+  return Action::failure;
+}
+
+Action::state_ptr MoleculeChangeNameAction::performUndo(Action::state_ptr _state) {
+  MoleculeChangeNameState *state = assert_cast<MoleculeChangeNameState*>(_state.get());
+
+  string newName = state->mol->getName();
+  state->mol->setName(state->lastName);
+
+  return Action::state_ptr(new MoleculeChangeNameState(state->mol,newName));
+}
+
+Action::state_ptr MoleculeChangeNameAction::performRedo(Action::state_ptr _state){
+  // Undo and redo have to do the same for this action
+  return performUndo(_state);
+}
+
+bool MoleculeChangeNameAction::canUndo() {
+  return true;
+}
+
+bool MoleculeChangeNameAction::shouldUndo() {
+  return true;
+}
+
+const string MoleculeChangeNameAction::getName() {
+  return NAME;
+}
Index: src/Actions/MoleculeAction/ChangeNameAction.hpp
===================================================================
--- src/Actions/MoleculeAction/ChangeNameAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/MoleculeAction/ChangeNameAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,35 @@
+/*
+ * ChangeNameAction.hpp
+ *
+ *  Created on: Jan 15, 2010
+ *      Author: crueger
+ */
+
+#ifndef CHANGENAMEACTION_HPP
+#define CHANGENAMEACTION_HPP
+
+#include "Actions/Action.hpp"
+#include "Actions/Process.hpp"
+
+class MoleculeListClass;
+
+class MoleculeChangeNameAction : public Action {
+public:
+  MoleculeChangeNameAction();
+  virtual ~MoleculeChangeNameAction();
+
+  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);
+
+  MoleculeListClass *molecules;
+  static const char NAME[];
+};
+
+
+#endif // CHANGENAMEACTION_HPP
Index: src/Actions/MoleculeAction/FillWithMoleculeAction.cpp
===================================================================
--- src/Actions/MoleculeAction/FillWithMoleculeAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/MoleculeAction/FillWithMoleculeAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,142 @@
+/*
+ * FillWithMoleculeAction.cpp
+ *
+ *  Created on: May 10, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/MoleculeAction/FillWithMoleculeAction.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#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"
+
+/****** MoleculeFillWithMoleculeAction *****/
+
+// memento to remember the state when undoing
+
+//class MoleculeFillWithMoleculeState : public ActionState {
+//public:
+//  MoleculeFillWithMoleculeState(molecule* _mol,std::string _lastName) :
+//    mol(_mol),
+//    lastName(_lastName)
+//  {}
+//  molecule* mol;
+//  std::string lastName;
+//};
+
+const char MoleculeFillWithMoleculeAction::NAME[] = "fill-molecule";
+
+MoleculeFillWithMoleculeAction::MoleculeFillWithMoleculeAction() :
+  Action(NAME)
+{}
+
+MoleculeFillWithMoleculeAction::~MoleculeFillWithMoleculeAction()
+{}
+
+Action::state_ptr MoleculeFillWithMoleculeAction::performCall() {
+  string filename;
+  Dialog *dialog = UIFactory::getInstance().makeDialog();
+  Vector distances;
+  Vector lengths;
+  double MaxDistance = -1.;
+  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"));
+
+  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;
+//    atom *first = NULL, *second = NULL, *third = NULL;
+//    first = World::getInstance().createAtom();
+//    first->type = World::getInstance().getPeriode()->FindElement(1);
+//    first->x = Vector(0.441, -0.143, 0.);
+//    filler->AddAtom(first);
+//    second = World::getInstance().createAtom();
+//    second->type = World::getInstance().getPeriode()->FindElement(1);
+//    second->x = Vector(-0.464, 1.137, 0.0);
+//    filler->AddAtom(second);
+//    third = World::getInstance().createAtom();
+//    third->type = World::getInstance().getPeriode()->FindElement(8);
+//    third->x = Vector(-0.464, 0.177, 0.);
+//    filler->AddAtom(third);
+//    filler->AddBond(first, third, 1);
+//    filler->AddBond(second, third, 1);
+    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);
+
+    delete dialog;
+    return Action::success;
+  }
+  delete dialog;
+  return Action::failure;
+}
+
+Action::state_ptr MoleculeFillWithMoleculeAction::performUndo(Action::state_ptr _state) {
+//  MoleculeFillWithMoleculeState *state = assert_cast<MoleculeFillWithMoleculeState*>(_state.get());
+
+//  string newName = state->mol->getName();
+//  state->mol->setName(state->lastName);
+
+  return Action::failure;
+}
+
+Action::state_ptr MoleculeFillWithMoleculeAction::performRedo(Action::state_ptr _state){
+  // Undo and redo have to do the same for this action
+  return performUndo(_state);
+}
+
+bool MoleculeFillWithMoleculeAction::canUndo() {
+  return false;
+}
+
+bool MoleculeFillWithMoleculeAction::shouldUndo() {
+  return false;
+}
+
+const string MoleculeFillWithMoleculeAction::getName() {
+  return NAME;
+}
Index: src/Actions/MoleculeAction/FillWithMoleculeAction.hpp
===================================================================
--- src/Actions/MoleculeAction/FillWithMoleculeAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/MoleculeAction/FillWithMoleculeAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,34 @@
+/*
+ * FillWithMoleculeAction.hpp
+ *
+ *  Created on: May 10, 2010
+ *      Author: heber
+ */
+
+#ifndef FILLWITHMOLECULEACTION_HPP
+#define FILLWITHMOLECULEACTION_HPP
+
+#include "Actions/Action.hpp"
+#include "Actions/Process.hpp"
+
+class MoleculeListClass;
+
+class MoleculeFillWithMoleculeAction : public Action {
+public:
+  MoleculeFillWithMoleculeAction();
+  virtual ~MoleculeFillWithMoleculeAction();
+
+  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 // FILLWITHMOLECULEACTION_HPP
Index: src/Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.cpp
===================================================================
--- src/Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,106 @@
+/*
+ * LinearInterpolationofTrajectoriesAction.cpp
+ *
+ *  Created on: May 10, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.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 "defs.hpp"
+#include "log.hpp"
+#include "molecule.hpp"
+#include "verbose.hpp"
+#include "World.hpp"
+
+/****** MoleculeLinearInterpolationofTrajectoriesAction *****/
+
+// memento to remember the state when undoing
+
+//class MoleculeLinearInterpolationofTrajectoriesState : public ActionState {
+//public:
+//  MoleculeLinearInterpolationofTrajectoriesState(molecule* _mol,std::string _lastName) :
+//    mol(_mol),
+//    lastName(_lastName)
+//  {}
+//  molecule* mol;
+//  std::string lastName;
+//};
+
+const char MoleculeLinearInterpolationofTrajectoriesAction::NAME[] = "linear-interpolate";
+
+MoleculeLinearInterpolationofTrajectoriesAction::MoleculeLinearInterpolationofTrajectoriesAction() :
+  Action(NAME)
+{}
+
+MoleculeLinearInterpolationofTrajectoriesAction::~MoleculeLinearInterpolationofTrajectoriesAction()
+{}
+
+Action::state_ptr MoleculeLinearInterpolationofTrajectoriesAction::performCall() {
+  string filename;
+  Dialog *dialog = UIFactory::getInstance().makeDialog();
+  molecule *mol = NULL;
+  int start = -1;
+  int end = -1;
+  bool IdMapping = true;
+
+
+  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()) {
+    DoLog(1) && (Log() << Verbose(1) << "Linear interpolation between configuration " << start << " and " << end << "." << endl);
+    if (IdMapping)
+      DoLog(1) && (Log() << Verbose(1) << "Using Identity for the permutation map." << endl);
+    if (!mol->LinearInterpolationBetweenConfiguration(start, end, filename, *(World::getInstance().getConfig()), IdMapping))
+      DoLog(2) && (Log() << Verbose(2) << "Could not store " << filename << " files." << endl);
+    else
+      DoLog(2) && (Log() << Verbose(2) << "Steps created and " << filename << " files stored." << endl);
+    delete dialog;
+    return Action::success;
+  }
+  delete dialog;
+  return Action::failure;
+}
+
+Action::state_ptr MoleculeLinearInterpolationofTrajectoriesAction::performUndo(Action::state_ptr _state) {
+//  MoleculeLinearInterpolationofTrajectoriesState *state = assert_cast<MoleculeLinearInterpolationofTrajectoriesState*>(_state.get());
+
+//  string newName = state->mol->getName();
+//  state->mol->setName(state->lastName);
+
+  return Action::failure;
+}
+
+Action::state_ptr MoleculeLinearInterpolationofTrajectoriesAction::performRedo(Action::state_ptr _state){
+  // Undo and redo have to do the same for this action
+  return performUndo(_state);
+}
+
+bool MoleculeLinearInterpolationofTrajectoriesAction::canUndo() {
+  return false;
+}
+
+bool MoleculeLinearInterpolationofTrajectoriesAction::shouldUndo() {
+  return false;
+}
+
+const string MoleculeLinearInterpolationofTrajectoriesAction::getName() {
+  return NAME;
+}
Index: src/Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp
===================================================================
--- src/Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,34 @@
+/*
+ * LinearInterpolationofTrajectoriesAction.hpp
+ *
+ *  Created on: May 10, 2010
+ *      Author: heber
+ */
+
+#ifndef LINEARINTERPOLATIONOFTRAJECTORIES_HPP
+#define LINEARINTERPOLATIONOFTRAJECTORIES_HPP
+
+#include "Actions/Action.hpp"
+#include "Actions/Process.hpp"
+
+class MoleculeListClass;
+
+class MoleculeLinearInterpolationofTrajectoriesAction : public Action {
+public:
+  MoleculeLinearInterpolationofTrajectoriesAction();
+  virtual ~MoleculeLinearInterpolationofTrajectoriesAction();
+
+  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 // LINEARINTERPOLATIONOFTRAJECTORIES_HPP
Index: src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.cpp
===================================================================
--- src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,89 @@
+/*
+ * RotateToPrincipalAxisSystemAction.cpp
+ *
+ *  Created on: May 10, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp"
+
+#include <iostream>
+#include <fstream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/MapOfActions.hpp"
+
+#include "log.hpp"
+#include "molecule.hpp"
+#include "verbose.hpp"
+
+/****** MoleculeRotateToPrincipalAxisSystemAction *****/
+
+// memento to remember the state when undoing
+
+//class MoleculeRotateToPrincipalAxisSystemState : public ActionState {
+//public:
+//  MoleculeRotateToPrincipalAxisSystemState(molecule* _mol,std::string _lastName) :
+//    mol(_mol),
+//    lastName(_lastName)
+//  {}
+//  molecule* mol;
+//  std::string lastName;
+//};
+
+const char MoleculeRotateToPrincipalAxisSystemAction::NAME[] = "rotate-to-pas";
+
+MoleculeRotateToPrincipalAxisSystemAction::MoleculeRotateToPrincipalAxisSystemAction() :
+  Action(NAME)
+{}
+
+MoleculeRotateToPrincipalAxisSystemAction::~MoleculeRotateToPrincipalAxisSystemAction()
+{}
+
+Action::state_ptr MoleculeRotateToPrincipalAxisSystemAction::performCall() {
+  Dialog *dialog = UIFactory::getInstance().makeDialog();
+  molecule *mol = NULL;
+
+  dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME));
+
+  if(dialog->display()) {
+    DoLog(0) && (Log() << Verbose(0) << "Converting to prinicipal axis system." << endl);
+    mol->PrincipalAxisSystem(true);
+    delete dialog;
+    return Action::success;
+  }
+  delete dialog;
+  return Action::failure;
+}
+
+Action::state_ptr MoleculeRotateToPrincipalAxisSystemAction::performUndo(Action::state_ptr _state) {
+//  MoleculeRotateToPrincipalAxisSystemState *state = assert_cast<MoleculeRotateToPrincipalAxisSystemState*>(_state.get());
+
+//  string newName = state->mol->getName();
+//  state->mol->setName(state->lastName);
+
+  return Action::failure;
+}
+
+Action::state_ptr MoleculeRotateToPrincipalAxisSystemAction::performRedo(Action::state_ptr _state){
+  // Undo and redo have to do the same for this action
+  return performUndo(_state);
+}
+
+bool MoleculeRotateToPrincipalAxisSystemAction::canUndo() {
+  return false;
+}
+
+bool MoleculeRotateToPrincipalAxisSystemAction::shouldUndo() {
+  return false;
+}
+
+const string MoleculeRotateToPrincipalAxisSystemAction::getName() {
+  return NAME;
+}
Index: src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp
===================================================================
--- src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,34 @@
+/*
+ * RotateToPrincipalAxisSystemAction.hpp
+ *
+ *  Created on: May 10, 2010
+ *      Author: heber
+ */
+
+#ifndef ROTATETOPRINCIPALAXISSYSTEMACTION_HPP
+#define ROTATETOPRINCIPALAXISSYSTEMACTION_HPP
+
+#include "Actions/Action.hpp"
+#include "Actions/Process.hpp"
+
+class MoleculeListClass;
+
+class MoleculeRotateToPrincipalAxisSystemAction : public Action {
+public:
+  MoleculeRotateToPrincipalAxisSystemAction();
+  virtual ~MoleculeRotateToPrincipalAxisSystemAction();
+
+  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 // ROTATETOPRINCIPALAXISSYSTEMACTION_HPP
Index: src/Actions/MoleculeAction/SaveAdjacencyAction.cpp
===================================================================
--- src/Actions/MoleculeAction/SaveAdjacencyAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/MoleculeAction/SaveAdjacencyAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,99 @@
+/*
+ * SaveAdjacencyAction.cpp
+ *
+ *  Created on: May 10, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/MoleculeAction/SaveAdjacencyAction.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 "bondgraph.hpp"
+#include "config.hpp"
+#include "defs.hpp"
+#include "log.hpp"
+#include "molecule.hpp"
+#include "vector.hpp"
+#include "verbose.hpp"
+#include "World.hpp"
+
+/****** MoleculeSaveAdjacencyAction *****/
+
+// memento to remember the state when undoing
+
+//class MoleculeSaveAdjacencyState : public ActionState {
+//public:
+//  MoleculeSaveAdjacencyState(molecule* _mol,std::string _lastName) :
+//    mol(_mol),
+//    lastName(_lastName)
+//  {}
+//  molecule* mol;
+//  std::string lastName;
+//};
+
+const char MoleculeSaveAdjacencyAction::NAME[] = "save-adjacency";
+
+MoleculeSaveAdjacencyAction::MoleculeSaveAdjacencyAction() :
+  Action(NAME)
+{}
+
+MoleculeSaveAdjacencyAction::~MoleculeSaveAdjacencyAction()
+{}
+
+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"));
+
+  if(dialog->display()) {
+    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;
+}
+
+Action::state_ptr MoleculeSaveAdjacencyAction::performUndo(Action::state_ptr _state) {
+//  MoleculeSaveAdjacencyState *state = assert_cast<MoleculeSaveAdjacencyState*>(_state.get());
+
+//  string newName = state->mol->getName();
+//  state->mol->setName(state->lastName);
+
+  return Action::failure;
+}
+
+Action::state_ptr MoleculeSaveAdjacencyAction::performRedo(Action::state_ptr _state){
+  // Undo and redo have to do the same for this action
+  return performUndo(_state);
+}
+
+bool MoleculeSaveAdjacencyAction::canUndo() {
+  return false;
+}
+
+bool MoleculeSaveAdjacencyAction::shouldUndo() {
+  return false;
+}
+
+const string MoleculeSaveAdjacencyAction::getName() {
+  return NAME;
+}
Index: src/Actions/MoleculeAction/SaveAdjacencyAction.hpp
===================================================================
--- src/Actions/MoleculeAction/SaveAdjacencyAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/MoleculeAction/SaveAdjacencyAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,34 @@
+/*
+ * SaveAdjacencyAction.hpp
+ *
+ *  Created on: May 10, 2010
+ *      Author: heber
+ */
+
+#ifndef SAVEADJACENCYACTION_HPP
+#define SAVEADJACENCYACTION_HPP
+
+#include "Actions/Action.hpp"
+#include "Actions/Process.hpp"
+
+class MoleculeListClass;
+
+class MoleculeSaveAdjacencyAction : public Action {
+public:
+  MoleculeSaveAdjacencyAction();
+  virtual ~MoleculeSaveAdjacencyAction();
+
+  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 // SAVEADJACENCYACTION_HPP
Index: src/Actions/MoleculeAction/SaveBondsAction.cpp
===================================================================
--- src/Actions/MoleculeAction/SaveBondsAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/MoleculeAction/SaveBondsAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,99 @@
+/*
+ * SaveBondsAction.cpp
+ *
+ *  Created on: May 10, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/MoleculeAction/SaveBondsAction.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 "bondgraph.hpp"
+#include "config.hpp"
+#include "defs.hpp"
+#include "log.hpp"
+#include "molecule.hpp"
+#include "vector.hpp"
+#include "verbose.hpp"
+#include "World.hpp"
+
+/****** MoleculeSaveBondsAction *****/
+
+// memento to remember the state when undoing
+
+//class MoleculeSaveBondsState : public ActionState {
+//public:
+//  MoleculeSaveBondsState(molecule* _mol,std::string _lastName) :
+//    mol(_mol),
+//    lastName(_lastName)
+//  {}
+//  molecule* mol;
+//  std::string lastName;
+//};
+
+const char MoleculeSaveBondsAction::NAME[] = "save-bonds";
+
+MoleculeSaveBondsAction::MoleculeSaveBondsAction() :
+  Action(NAME)
+{}
+
+MoleculeSaveBondsAction::~MoleculeSaveBondsAction()
+{}
+
+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"));
+
+  if(dialog->display()) {
+    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;
+}
+
+Action::state_ptr MoleculeSaveBondsAction::performUndo(Action::state_ptr _state) {
+//  MoleculeSaveBondsState *state = assert_cast<MoleculeSaveBondsState*>(_state.get());
+
+//  string newName = state->mol->getName();
+//  state->mol->setName(state->lastName);
+
+  return Action::failure;
+}
+
+Action::state_ptr MoleculeSaveBondsAction::performRedo(Action::state_ptr _state){
+  // Undo and redo have to do the same for this action
+  return performUndo(_state);
+}
+
+bool MoleculeSaveBondsAction::canUndo() {
+  return false;
+}
+
+bool MoleculeSaveBondsAction::shouldUndo() {
+  return false;
+}
+
+const string MoleculeSaveBondsAction::getName() {
+  return NAME;
+}
Index: src/Actions/MoleculeAction/SaveBondsAction.hpp
===================================================================
--- src/Actions/MoleculeAction/SaveBondsAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/MoleculeAction/SaveBondsAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,34 @@
+/*
+ * SaveBondsAction.hpp
+ *
+ *  Created on: May 10, 2010
+ *      Author: heber
+ */
+
+#ifndef SAVEBONDSACTION_HPP
+#define SAVEBONDSACTION_HPP
+
+#include "Actions/Action.hpp"
+#include "Actions/Process.hpp"
+
+class MoleculeListClass;
+
+class MoleculeSaveBondsAction : public Action {
+public:
+  MoleculeSaveBondsAction();
+  virtual ~MoleculeSaveBondsAction();
+
+  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 // SAVEBONDSACTION_HPP
Index: src/Actions/MoleculeAction/SaveTemperatureAction.cpp
===================================================================
--- src/Actions/MoleculeAction/SaveTemperatureAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/MoleculeAction/SaveTemperatureAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,99 @@
+/*
+ * SaveTemperatureAction.cpp
+ *
+ *  Created on: May 10, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/MoleculeAction/SaveTemperatureAction.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"
+
+/****** MoleculeSaveTemperatureAction *****/
+
+// memento to remember the state when undoing
+
+//class MoleculeSaveTemperatureState : public ActionState {
+//public:
+//  MoleculeSaveTemperatureState(molecule* _mol,std::string _lastName) :
+//    mol(_mol),
+//    lastName(_lastName)
+//  {}
+//  molecule* mol;
+//  std::string lastName;
+//};
+
+const char MoleculeSaveTemperatureAction::NAME[] = "save-temperature";
+
+MoleculeSaveTemperatureAction::MoleculeSaveTemperatureAction() :
+  Action(NAME)
+{}
+
+MoleculeSaveTemperatureAction::~MoleculeSaveTemperatureAction()
+{}
+
+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"));
+
+  if(dialog->display()) {
+    DoLog(1) && (Log() << Verbose(1) << "Storing temperatures in " << filename << "." << endl);
+    ofstream output;
+    output.open(filename.c_str(), ios::trunc);
+    if (output.fail() || !mol->OutputTemperatureFromTrajectories((ofstream * const) &output, 0, mol->MDSteps))
+      DoLog(2) && (Log() << Verbose(2) << "File could not be written." << endl);
+    else
+      DoLog(2) && (Log() << Verbose(2) << "File stored." << endl);
+    output.close();
+    delete dialog;
+    return Action::success;
+  }
+  delete dialog;
+  return Action::failure;
+}
+
+Action::state_ptr MoleculeSaveTemperatureAction::performUndo(Action::state_ptr _state) {
+//  MoleculeSaveTemperatureState *state = assert_cast<MoleculeSaveTemperatureState*>(_state.get());
+
+//  string newName = state->mol->getName();
+//  state->mol->setName(state->lastName);
+
+  return Action::failure;
+}
+
+Action::state_ptr MoleculeSaveTemperatureAction::performRedo(Action::state_ptr _state){
+  // Undo and redo have to do the same for this action
+  return performUndo(_state);
+}
+
+bool MoleculeSaveTemperatureAction::canUndo() {
+  return false;
+}
+
+bool MoleculeSaveTemperatureAction::shouldUndo() {
+  return false;
+}
+
+const string MoleculeSaveTemperatureAction::getName() {
+  return NAME;
+}
Index: src/Actions/MoleculeAction/SaveTemperatureAction.hpp
===================================================================
--- src/Actions/MoleculeAction/SaveTemperatureAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/MoleculeAction/SaveTemperatureAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,34 @@
+/*
+ * SaveTemperatureAction.hpp
+ *
+ *  Created on: May 10, 2010
+ *      Author: heber
+ */
+
+#ifndef SAVETEMPERATUREACTION_HPP
+#define SAVETEMPERATUREACTION_HPP
+
+#include "Actions/Action.hpp"
+#include "Actions/Process.hpp"
+
+class MoleculeListClass;
+
+class MoleculeSaveTemperatureAction : public Action {
+public:
+  MoleculeSaveTemperatureAction();
+  virtual ~MoleculeSaveTemperatureAction();
+
+  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 // SAVETEMPERATUREACTION_HPP
Index: src/Actions/MoleculeAction/SuspendInWaterAction.cpp
===================================================================
--- src/Actions/MoleculeAction/SuspendInWaterAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/MoleculeAction/SuspendInWaterAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,98 @@
+/*
+ * SuspendInWaterAction.cpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/MoleculeAction/SuspendInWaterAction.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#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"
+
+/****** MoleculeSuspendInWaterAction *****/
+
+// memento to remember the state when undoing
+
+//class MoleculeSuspendInWaterState : public ActionState {
+//public:
+//  MoleculeSuspendInWaterState(molecule* _mol,std::string _lastName) :
+//    mol(_mol),
+//    lastName(_lastName)
+//  {}
+//  molecule* mol;
+//  std::string lastName;
+//};
+
+const char MoleculeSuspendInWaterAction::NAME[] = "suspend-in-water";
+
+MoleculeSuspendInWaterAction::MoleculeSuspendInWaterAction() :
+  Action(NAME)
+{}
+
+MoleculeSuspendInWaterAction::~MoleculeSuspendInWaterAction()
+{}
+
+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"));
+
+  if(dialog->display()) {
+    DoLog(0) && (Log() << Verbose(0) << "Evaluating necessary cell volume for a cluster suspended in water.");
+    if (density < 1.0) {
+      DoeLog(1) && (eLog()<< Verbose(1) << "Density must be greater than 1.0g/cm^3!" << endl);
+    } 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;
+}
+
+Action::state_ptr MoleculeSuspendInWaterAction::performUndo(Action::state_ptr _state) {
+//  MoleculeSuspendInWaterState *state = assert_cast<MoleculeSuspendInWaterState*>(_state.get());
+
+//  string newName = state->mol->getName();
+//  state->mol->setName(state->lastName);
+
+  return Action::failure;
+}
+
+Action::state_ptr MoleculeSuspendInWaterAction::performRedo(Action::state_ptr _state){
+  // Undo and redo have to do the same for this action
+  return performUndo(_state);
+}
+
+bool MoleculeSuspendInWaterAction::canUndo() {
+  return false;
+}
+
+bool MoleculeSuspendInWaterAction::shouldUndo() {
+  return false;
+}
+
+const string MoleculeSuspendInWaterAction::getName() {
+  return NAME;
+}
Index: src/Actions/MoleculeAction/SuspendInWaterAction.hpp
===================================================================
--- src/Actions/MoleculeAction/SuspendInWaterAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/MoleculeAction/SuspendInWaterAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,34 @@
+/*
+ * SuspendInWaterAction.hpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+#ifndef SUSPENDINWATERACTION_HPP
+#define SUSPENDINWATERACTION_HPP
+
+#include "Actions/Action.hpp"
+#include "Actions/Process.hpp"
+
+class MoleculeListClass;
+
+class MoleculeSuspendInWaterAction : public Action {
+public:
+  MoleculeSuspendInWaterAction();
+  virtual ~MoleculeSuspendInWaterAction();
+
+  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 // SUSPENDINWATERACTION_HPP
Index: src/Actions/MoleculeAction/TranslateAction.cpp
===================================================================
--- src/Actions/MoleculeAction/TranslateAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/MoleculeAction/TranslateAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,100 @@
+/*
+ * 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: src/Actions/MoleculeAction/TranslateAction.hpp
===================================================================
--- src/Actions/MoleculeAction/TranslateAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/MoleculeAction/TranslateAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,34 @@
+/*
+ * 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 ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/MoleculeAction/VerletIntegrationAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,100 @@
+/*
+ * VerletIntegrationAction.cpp
+ *
+ *  Created on: May 10, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/MoleculeAction/VerletIntegrationAction.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"
+
+/****** MoleculeVerletIntegrationAction *****/
+
+// memento to remember the state when undoing
+
+//class MoleculeVerletIntegrationState : public ActionState {
+//public:
+//  MoleculeVerletIntegrationState(molecule* _mol,std::string _lastName) :
+//    mol(_mol),
+//    lastName(_lastName)
+//  {}
+//  molecule* mol;
+//  std::string lastName;
+//};
+
+const char MoleculeVerletIntegrationAction::NAME[] = "verlet-integrate";
+
+MoleculeVerletIntegrationAction::MoleculeVerletIntegrationAction() :
+  Action(NAME)
+{}
+
+MoleculeVerletIntegrationAction::~MoleculeVerletIntegrationAction()
+{}
+
+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"));
+
+  if(dialog->display()) {
+    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
+    char outputname[MAXSTRINGSIZE];
+    strcpy(outputname, filename.c_str());
+    if (!mol->VerletForceIntegration(outputname, *(World::getInstance().getConfig()), 0))
+      DoLog(2) && (Log() << Verbose(2) << "File not found." << endl);
+    else
+      DoLog(2) && (Log() << Verbose(2) << "File found and parsed." << endl);
+
+    delete dialog;
+    return Action::success;
+  }
+  delete dialog;
+  return Action::failure;
+}
+
+Action::state_ptr MoleculeVerletIntegrationAction::performUndo(Action::state_ptr _state) {
+//  MoleculeVerletIntegrationState *state = assert_cast<MoleculeVerletIntegrationState*>(_state.get());
+
+//  string newName = state->mol->getName();
+//  state->mol->setName(state->lastName);
+
+  return Action::failure;
+}
+
+Action::state_ptr MoleculeVerletIntegrationAction::performRedo(Action::state_ptr _state){
+  // Undo and redo have to do the same for this action
+  return performUndo(_state);
+}
+
+bool MoleculeVerletIntegrationAction::canUndo() {
+  return false;
+}
+
+bool MoleculeVerletIntegrationAction::shouldUndo() {
+  return false;
+}
+
+const string MoleculeVerletIntegrationAction::getName() {
+  return NAME;
+}
Index: src/Actions/MoleculeAction/VerletIntegrationAction.hpp
===================================================================
--- src/Actions/MoleculeAction/VerletIntegrationAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/MoleculeAction/VerletIntegrationAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,34 @@
+/*
+ * VerletIntegrationAction.hpp
+ *
+ *  Created on: May 10, 2010
+ *      Author: heber
+ */
+
+#ifndef VERLETINTEGRATIONACTION_HPP
+#define VERLETINTEGRATIONACTION_HPP
+
+#include "Actions/Action.hpp"
+#include "Actions/Process.hpp"
+
+class MoleculeListClass;
+
+class MoleculeVerletIntegrationAction : public Action {
+public:
+  MoleculeVerletIntegrationAction();
+  virtual ~MoleculeVerletIntegrationAction();
+
+  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 // VERLETINTEGRATIONACTION_HPP
Index: src/Actions/ParserAction/LoadXyzAction.cpp
===================================================================
--- src/Actions/ParserAction/LoadXyzAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/ParserAction/LoadXyzAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,127 @@
+/*
+ * LoadXyzAction.cpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+using namespace std;
+
+#include "Actions/ParserAction/LoadXyzAction.hpp"
+#include "Parser/XyzParser.hpp"
+
+#include <iostream>
+#include <set>
+#include <string>
+#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"
+
+/****** ParserLoadXyzAction *****/
+
+//// memento to remember the state when undoing
+//
+//class ParserLoadXyzState : public ActionState {
+//public:
+//  ParserLoadXyzState(molecule* _mol,std::string _lastName) :
+//    mol(_mol),
+//    lastName(_lastName)
+//  {}
+//  molecule* mol;
+//  std::string lastName;
+//};
+
+const char ParserLoadXyzAction::NAME[] = "parse-xyz";
+
+ParserLoadXyzAction::ParserLoadXyzAction() :
+  Action(NAME)
+{}
+
+ParserLoadXyzAction::~ParserLoadXyzAction()
+{}
+
+Action::state_ptr ParserLoadXyzAction::performCall() {
+  string filename;
+  Dialog *dialog = UIFactory::getInstance().makeDialog();
+
+  dialog->queryString(NAME,&filename, NAME);
+
+  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();
+  }
+  delete dialog;
+  return Action::failure;
+}
+
+Action::state_ptr ParserLoadXyzAction::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 ParserLoadXyzAction::performRedo(Action::state_ptr _state){
+  return Action::failure;
+}
+
+bool ParserLoadXyzAction::canUndo() {
+  return false;
+}
+
+bool ParserLoadXyzAction::shouldUndo() {
+  return false;
+}
+
+const string ParserLoadXyzAction::getName() {
+  return NAME;
+}
Index: src/Actions/ParserAction/LoadXyzAction.hpp
===================================================================
--- src/Actions/ParserAction/LoadXyzAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/ParserAction/LoadXyzAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,31 @@
+/*
+ * LoadXyzAction.hpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#ifndef LOADXYZACTION_HPP_
+#define LOADXYZACTION_HPP_
+
+#include "Actions/Action.hpp"
+#include "Actions/Process.hpp"
+
+class ParserLoadXyzAction : public Action {
+public:
+  ParserLoadXyzAction();
+  virtual ~ParserLoadXyzAction();
+
+  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 /* LOADXYZACTION_HPP_ */
Index: src/Actions/ParserAction/SaveXyzAction.cpp
===================================================================
--- src/Actions/ParserAction/SaveXyzAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/ParserAction/SaveXyzAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,93 @@
+/*
+ * SaveXyzAction.cpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/ParserAction/SaveXyzAction.hpp"
+#include "Parser/XyzParser.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/MapOfActions.hpp"
+
+#include "atom.hpp"
+#include "molecule.hpp"
+
+/****** ParserSaveXyzAction *****/
+
+//// memento to remember the state when undoing
+//
+//class ParserSaveXyzState : public ActionState {
+//public:
+//  ParserSaveXyzState(molecule* _mol,std::string _lastName) :
+//    mol(_mol),
+//    lastName(_lastName)
+//  {}
+//  molecule* mol;
+//  std::string lastName;
+//};
+
+const char ParserSaveXyzAction::NAME[] = "SaveXyz";
+
+ParserSaveXyzAction::ParserSaveXyzAction() :
+  Action(NAME)
+{}
+
+ParserSaveXyzAction::~ParserSaveXyzAction()
+{}
+
+Action::state_ptr ParserSaveXyzAction::performCall() {
+  string filename;
+  XyzParser parser;
+  Dialog *dialog = UIFactory::getInstance().makeDialog();
+
+  dialog->queryString("filename",&filename, "Filename of the xyz file");
+
+  if(dialog->display()) {
+    // store xyz file
+    ofstream output;
+    output.open(filename.c_str());
+    if (!output.fail())
+      parser.save(&output);
+    output.close();
+  }
+  delete dialog;
+  return Action::failure;
+}
+
+Action::state_ptr ParserSaveXyzAction::performUndo(Action::state_ptr _state) {
+//  ParserSaveXyzState *state = assert_cast<ParserSaveXyzState*>(_state.get());
+
+  return Action::failure;
+//  string newName = state->mol->getName();
+//  state->mol->setName(state->lastName);
+//
+//  return Action::state_ptr(new ParserSaveXyzState(state->mol,newName));
+}
+
+Action::state_ptr ParserSaveXyzAction::performRedo(Action::state_ptr _state){
+  return Action::failure;
+//  // Undo and redo have to do the same for this action
+//  return performUndo(_state);
+}
+
+bool ParserSaveXyzAction::canUndo() {
+  return false;
+}
+
+bool ParserSaveXyzAction::shouldUndo() {
+  return false;
+}
+
+const string ParserSaveXyzAction::getName() {
+  return NAME;
+}
Index: src/Actions/ParserAction/SaveXyzAction.hpp
===================================================================
--- src/Actions/ParserAction/SaveXyzAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/ParserAction/SaveXyzAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,31 @@
+/*
+ * SaveXyzAction.hpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#ifndef SAVEXYZACTION_HPP_
+#define SAVEXYZACTION_HPP_
+
+#include "Actions/Action.hpp"
+#include "Actions/Process.hpp"
+
+class ParserSaveXyzAction : public Action {
+public:
+  ParserSaveXyzAction();
+  virtual ~ParserSaveXyzAction();
+
+  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 /* SAVEXYZACTION_HPP_ */
Index: src/Actions/Process.cpp
===================================================================
--- src/Actions/Process.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/Process.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,115 @@
+/*
+ * Process.cpp
+ *
+ *  Created on: Feb 17, 2010
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Process.hpp"
+
+using namespace std;
+
+Process::Process(int _maxSteps, std::string _name, bool _doRegister) :
+  Action(_name,_doRegister),
+  Observable("Process"),
+  maxSteps(_maxSteps),
+  active(false),
+  starts(false),
+  stops(false)
+{}
+
+Process::~Process()
+{
+  // make sure everybody knows we have stoped
+  stop();
+}
+
+
+bool Process::isRunning(){
+  return active;
+}
+
+bool Process::doesStart(){
+  return starts;
+}
+
+bool Process::doesStop(){
+  return stops;
+}
+
+int Process::getCurrStep(){
+  return currStep;
+}
+
+void Process::setCurrStep(int _currStep){
+  OBSERVE;
+  currStep = _currStep;
+}
+
+float Process::getDoneRatio() {
+  if(getMaxSteps())
+    return ((float)getCurrStep()/(float)getMaxSteps())*100.0;
+  else
+    return 0;
+}
+int Process::getMaxSteps(){
+  return maxSteps;
+}
+
+void Process::setMaxSteps(int _maxSteps){
+  maxSteps = _maxSteps;
+}
+
+void Process::start(){
+  starts = true;
+  {
+    // we forcibly sign on all observers
+    set<Observer*>::iterator iter;
+    for(iter=processObservers.begin();iter!=processObservers.end();++iter){
+      this->signOn((*iter));
+    }
+  }
+  // only this small part should be observed
+  {
+    OBSERVE;
+    currStep=0;
+  }
+  starts = false;
+  active = true;
+}
+
+void Process::step(){
+  OBSERVE;
+  currStep++;
+}
+
+void Process::stop(){
+  active=false;
+  stops = true;
+  {
+    OBSERVE;
+    currStep=0;
+  }
+  {
+    // when we are done we forcibly sign off all observers
+    set<Observer*>::iterator iter;
+    for(iter=processObservers.begin();iter!=processObservers.end();++iter){
+      this->signOff((*iter));
+    }
+  }
+  stops = false;
+}
+
+// static stuff
+
+set<Observer*> Process::processObservers;
+
+void Process::AddObserver(Observer *obs){
+  processObservers.insert(obs);
+}
+void Process::RemoveObserver(Observer *obs){
+  processObservers.erase(obs);
+}
+
Index: src/Actions/Process.hpp
===================================================================
--- src/Actions/Process.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/Process.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,74 @@
+/*
+ * Process.hpp
+ *
+ *  Created on: Feb 17, 2010
+ *      Author: crueger
+ */
+
+
+/**
+ * A Process is an action that might take some time and therfore contains methods
+ * that allows showing how much is done.
+ */
+#ifndef PROCESS_HPP_
+#define PROCESS_HPP_
+
+#include <set>
+
+#include "Patterns/Observer.hpp"
+#include "Actions/Action.hpp"
+
+/**
+ * A Process is an Action that might take some time and therefore has special
+ * methods to allow communication with progress indicators. Indicators
+ * can sign on at a global place and will be notified when any process is doing
+ * a calculation.
+ *
+ * A Process has four states:
+ *  - starting: It is in the process of setting itself up, and wants everybody to know that it will start
+ *              the calculation soon. Indicators should set up anything they need for displaying the progress
+ *              when they are notified by a process in this state.
+ *  - active:   The process is currently doing it's thing and wants any indicator to know it's status, i.e.
+ *              the percentage done.
+ *  - stopping: The process has fullfilled it's purpose and is shutting down. Indicators recieving this status
+ *              should also use it to shut down their indication mechanism and delete any objects allocated for
+ *              this Process
+ *  - inactive: This Process is currently sleeping. If a Process is sending out any signals in this state, there
+ *              is something seriously wrong.
+ */
+class Process : public Action, public Observable
+{
+public:
+  Process(int _maxSteps, std::string _name, bool _doRegister=true);
+  virtual ~Process();
+
+  bool  isRunning();
+  bool  doesStart();
+  bool  doesStop();
+  int   getCurrStep();
+  void  setCurrStep(int _currStep);
+  float getDoneRatio();
+  int   getMaxSteps();
+  void  setMaxSteps(int _maxSteps);
+
+protected:
+  void start();
+  void step();
+  void stop();
+
+private:
+  int currStep;
+  int maxSteps;
+  bool active;
+  bool starts;
+  bool stops;
+
+  // some global static stuff to allow general Observers that can show progresses
+public:
+  static void AddObserver(Observer *);
+  static void RemoveObserver(Observer *);
+private:
+  static std::set<Observer*> processObservers;
+};
+
+#endif /* PROCESS_HPP_ */
Index: src/Actions/TesselationAction/ConvexEnvelopeAction.cpp
===================================================================
--- src/Actions/TesselationAction/ConvexEnvelopeAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/TesselationAction/ConvexEnvelopeAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,117 @@
+/*
+ * ConvexEnvelopeAction.cpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/TesselationAction/ConvexEnvelopeAction.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#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"
+
+/****** TesselationConvexEnvelopeAction *****/
+
+// memento to remember the state when undoing
+
+//class TesselationConvexEnvelopeState : public ActionState {
+//public:
+//  TesselationConvexEnvelopeState(molecule* _mol,std::string _lastName) :
+//    mol(_mol),
+//    lastName(_lastName)
+//  {}
+//  molecule* mol;
+//  std::string lastName;
+//};
+
+const char TesselationConvexEnvelopeAction::NAME[] = "convex-envelope";
+
+TesselationConvexEnvelopeAction::TesselationConvexEnvelopeAction() :
+  Action(NAME)
+{}
+
+TesselationConvexEnvelopeAction::~TesselationConvexEnvelopeAction()
+{}
+
+Action::state_ptr TesselationConvexEnvelopeAction::performCall() {
+  string filenameConvex;
+  string filenameNonConvex;
+  Dialog *dialog = UIFactory::getInstance().makeDialog();
+  molecule * mol = NULL;
+  bool Success = false;
+  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"));
+
+  if(dialog->display()) {
+    class Tesselation *TesselStruct = NULL;
+    const LinkedCell *LCList = NULL;
+    DoLog(0) && (Log() << Verbose(0) << "Evaluating volume of the convex envelope.");
+    DoLog(1) && (Log() << Verbose(1) << "Storing tecplot convex data in " << filenameConvex << "." << endl);
+    DoLog(1) && (Log() << Verbose(1) << "Storing tecplot non-convex data in " << filenameNonConvex << "." << endl);
+    LCList = new LinkedCell(mol, 100.);
+    Boundaries *BoundaryPoints = NULL;
+    //FindConvexBorder(mol, BoundaryPoints, TesselStruct, LCList, argv[argptr]);
+    // TODO: Beide Funktionen sollten streams anstelle des Filenamen benutzen, besser fuer unit tests
+    FindNonConvexBorder(mol, TesselStruct, LCList, 50., filenameNonConvex.c_str());
+    //RemoveAllBoundaryPoints(TesselStruct, mol, argv[argptr]);
+    const double volumedifference = ConvexizeNonconvexEnvelope(TesselStruct, mol, filenameConvex.c_str());
+    const double clustervolume = VolumeOfConvexEnvelope(TesselStruct, configuration);
+    DoLog(0) && (Log() << Verbose(0) << "The tesselated volume area is " << clustervolume << " " << (configuration->GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl);
+    DoLog(0) && (Log() << Verbose(0) << "The non-convex tesselated volume area is " << clustervolume-volumedifference << " " << (configuration->GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl);
+    delete(TesselStruct);
+    delete(LCList);
+    delete dialog;
+    if (Success)
+      return Action::success;
+    else
+      return Action::failure;
+  }
+  delete dialog;
+  return Action::failure;
+}
+
+Action::state_ptr TesselationConvexEnvelopeAction::performUndo(Action::state_ptr _state) {
+//  TesselationConvexEnvelopeState *state = assert_cast<TesselationConvexEnvelopeState*>(_state.get());
+
+//  string newName = state->mol->getName();
+//  state->mol->setName(state->lastName);
+
+  return Action::failure;
+}
+
+Action::state_ptr TesselationConvexEnvelopeAction::performRedo(Action::state_ptr _state){
+  // Undo and redo have to do the same for this action
+  return performUndo(_state);
+}
+
+bool TesselationConvexEnvelopeAction::canUndo() {
+  return false;
+}
+
+bool TesselationConvexEnvelopeAction::shouldUndo() {
+  return false;
+}
+
+const string TesselationConvexEnvelopeAction::getName() {
+  return NAME;
+}
Index: src/Actions/TesselationAction/ConvexEnvelopeAction.hpp
===================================================================
--- src/Actions/TesselationAction/ConvexEnvelopeAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/TesselationAction/ConvexEnvelopeAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,33 @@
+/*
+ * ConvexEnvelopeAction.hpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+#ifndef CONVEXENVELOPEACTION_HPP
+#define CONVEXENVELOPEACTION_HPP
+
+#include "Actions/Action.hpp"
+#include "Actions/Process.hpp"
+
+class TesselationListClass;
+
+class TesselationConvexEnvelopeAction : public Action {
+public:
+  TesselationConvexEnvelopeAction();
+  virtual ~TesselationConvexEnvelopeAction();
+
+  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 // CONVEXENVELOPEACTION_HPP
Index: src/Actions/TesselationAction/NonConvexEnvelopeAction.cpp
===================================================================
--- src/Actions/TesselationAction/NonConvexEnvelopeAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/TesselationAction/NonConvexEnvelopeAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,112 @@
+/*
+ * NonConvexEnvelopeAction.cpp
+ *
+ *  Created on: May 10, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/TesselationAction/NonConvexEnvelopeAction.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#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"
+
+/****** TesselationNonConvexEnvelopeAction *****/
+
+// memento to remember the state when undoing
+
+//class TesselationNonConvexEnvelopeState : public ActionState {
+//public:
+//  TesselationNonConvexEnvelopeState(molecule* _mol,std::string _lastName) :
+//    mol(_mol),
+//    lastName(_lastName)
+//  {}
+//  molecule* mol;
+//  std::string lastName;
+//};
+
+const char TesselationNonConvexEnvelopeAction::NAME[] = "nonconvex-envelope";
+
+TesselationNonConvexEnvelopeAction::TesselationNonConvexEnvelopeAction() :
+  Action(NAME)
+{}
+
+TesselationNonConvexEnvelopeAction::~TesselationNonConvexEnvelopeAction()
+{}
+
+Action::state_ptr TesselationNonConvexEnvelopeAction::performCall() {
+  string filename;
+  Dialog *dialog = UIFactory::getInstance().makeDialog();
+  molecule * Boundary = NULL;
+  double SphereRadius = 0;
+  bool Success = false;
+  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"));
+
+  if(dialog->display()) {
+    class Tesselation *T = NULL;
+    const LinkedCell *LCList = NULL;
+    DoLog(0) && (Log() << Verbose(0) << "Evaluating non-convex envelope of molecule." << Boundary->getId() << endl);
+    DoLog(1) && (Log() << Verbose(1) << "Using rolling ball of radius " << SphereRadius << " and storing tecplot data in " << filename << "." << endl);
+    DoLog(1) && (Log() << Verbose(1) << "Specified molecule has " << Boundary->getAtomCount() << " atoms." << endl);
+    start = clock();
+    LCList = new LinkedCell(Boundary, SphereRadius*2.);
+    Success = FindNonConvexBorder(Boundary, T, LCList, SphereRadius, filename.c_str());
+    //FindDistributionOfEllipsoids(T, &LCList, N, number, filename.c_str());
+    end = clock();
+    DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl);
+    delete(LCList);
+    delete(T);
+    delete dialog;
+    if (Success)
+      return Action::success;
+    else
+      return Action::failure;
+  }
+  delete dialog;
+  return Action::failure;
+}
+
+Action::state_ptr TesselationNonConvexEnvelopeAction::performUndo(Action::state_ptr _state) {
+//  TesselationNonConvexEnvelopeState *state = assert_cast<TesselationNonConvexEnvelopeState*>(_state.get());
+
+//  string newName = state->mol->getName();
+//  state->mol->setName(state->lastName);
+
+  return Action::failure;
+}
+
+Action::state_ptr TesselationNonConvexEnvelopeAction::performRedo(Action::state_ptr _state){
+  // Undo and redo have to do the same for this action
+  return performUndo(_state);
+}
+
+bool TesselationNonConvexEnvelopeAction::canUndo() {
+  return false;
+}
+
+bool TesselationNonConvexEnvelopeAction::shouldUndo() {
+  return false;
+}
+
+const string TesselationNonConvexEnvelopeAction::getName() {
+  return NAME;
+}
Index: src/Actions/TesselationAction/NonConvexEnvelopeAction.hpp
===================================================================
--- src/Actions/TesselationAction/NonConvexEnvelopeAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/TesselationAction/NonConvexEnvelopeAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,34 @@
+/*
+ * NonConvexEnvelopeAction.hpp
+ *
+ *  Created on: May 10, 2010
+ *      Author: heber
+ */
+
+#ifndef NONCONVEXENVELOPEACTION_HPP
+#define NONCONVEXENVELOPEACTION_HPP
+
+#include "Actions/Action.hpp"
+#include "Actions/Process.hpp"
+
+class TesselationListClass;
+
+class TesselationNonConvexEnvelopeAction : public Action {
+public:
+  TesselationNonConvexEnvelopeAction();
+  virtual ~TesselationNonConvexEnvelopeAction();
+
+  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 // NONCONVEXENVELOPEACTION_HPP
Index: src/Actions/Values.hpp
===================================================================
--- src/Actions/Values.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/Values.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,29 @@
+/*
+ * Values.hpp
+ *
+ *  Created on: Jun 7, 2010
+ *      Author: heber
+ */
+
+#ifndef VALUES_HPP_
+#define VALUES_HPP_
+
+struct VectorValue
+{
+  double x;
+  double y;
+  double z;
+};
+
+struct BoxValue
+{
+  double xx;
+  double xy;
+  double xz;
+  double yy;
+  double yz;
+  double zz;
+};
+
+
+#endif /* VALUES_HPP_ */
Index: src/Actions/WorldAction/AddEmptyBoundaryAction.cpp
===================================================================
--- src/Actions/WorldAction/AddEmptyBoundaryAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/WorldAction/AddEmptyBoundaryAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,105 @@
+/*
+ * AddEmptyBoundaryAction.cpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/WorldAction/AddEmptyBoundaryAction.hpp"
+#include "atom.hpp"
+#include "log.hpp"
+#include "vector.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <string>
+#include <vector>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/MapOfActions.hpp"
+#include "Helpers/Assert.hpp"
+
+const char WorldAddEmptyBoundaryAction::NAME[] = "boundary";
+
+WorldAddEmptyBoundaryAction::WorldAddEmptyBoundaryAction() :
+  Action(NAME)
+{}
+
+WorldAddEmptyBoundaryAction::~WorldAddEmptyBoundaryAction()
+{}
+
+Action::state_ptr WorldAddEmptyBoundaryAction::performCall() {
+  Dialog *dialog = UIFactory::getInstance().makeDialog();
+  Vector boundary;
+  Vector Min;
+  Vector Max;
+  int j=0;
+
+  dialog->queryVector(NAME, &boundary, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription(NAME));
+
+  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];
+      }
+    }
+    // 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;
+  }
+}
+
+Action::state_ptr WorldAddEmptyBoundaryAction::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 WorldAddEmptyBoundaryAction::performRedo(Action::state_ptr _state){
+  return Action::failure;
+}
+
+bool WorldAddEmptyBoundaryAction::canUndo() {
+  return false;
+}
+
+bool WorldAddEmptyBoundaryAction::shouldUndo() {
+  return false;
+}
+
+const string WorldAddEmptyBoundaryAction::getName() {
+  return NAME;
+}
Index: src/Actions/WorldAction/AddEmptyBoundaryAction.hpp
===================================================================
--- src/Actions/WorldAction/AddEmptyBoundaryAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/WorldAction/AddEmptyBoundaryAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+/*
+ * AddEmptyBoundaryAction.hpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#ifndef ADDEMPTYBOUNDARYACTION_HPP_
+#define ADDEMPTYBOUNDARYACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class WorldAddEmptyBoundaryAction : public Action {
+public:
+  WorldAddEmptyBoundaryAction();
+  virtual ~WorldAddEmptyBoundaryAction();
+
+  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 /* ADDEMPTYBOUNDARYACTION_HPP_ */
Index: src/Actions/WorldAction/BoundInBoxAction.cpp
===================================================================
--- src/Actions/WorldAction/BoundInBoxAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/WorldAction/BoundInBoxAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,77 @@
+/*
+ * BoundInBoxAction.cpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/WorldAction/BoundInBoxAction.hpp"
+#include "log.hpp"
+#include "molecule.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <string>
+#include <vector>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/MapOfActions.hpp"
+
+const char WorldBoundInBoxAction::NAME[] = "bound-in-box";
+
+WorldBoundInBoxAction::WorldBoundInBoxAction() :
+  Action(NAME)
+{}
+
+WorldBoundInBoxAction::~WorldBoundInBoxAction()
+{}
+
+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;
+  }
+}
+
+Action::state_ptr WorldBoundInBoxAction::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 WorldBoundInBoxAction::performRedo(Action::state_ptr _state){
+  return Action::failure;
+}
+
+bool WorldBoundInBoxAction::canUndo() {
+  return false;
+}
+
+bool WorldBoundInBoxAction::shouldUndo() {
+  return false;
+}
+
+const string WorldBoundInBoxAction::getName() {
+  return NAME;
+}
Index: src/Actions/WorldAction/BoundInBoxAction.hpp
===================================================================
--- src/Actions/WorldAction/BoundInBoxAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/WorldAction/BoundInBoxAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+/*
+ * BoundInBoxAction.hpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#ifndef BOUNDINBOXACTION_HPP_
+#define BOUNDINBOXACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class WorldBoundInBoxAction : public Action {
+public:
+  WorldBoundInBoxAction();
+  virtual ~WorldBoundInBoxAction();
+
+  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 /* BOUNDINBOXACTION_HPP_ */
Index: src/Actions/WorldAction/CenterInBoxAction.cpp
===================================================================
--- src/Actions/WorldAction/CenterInBoxAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/WorldAction/CenterInBoxAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,78 @@
+/*
+ * CenterInBoxAction.cpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/WorldAction/CenterInBoxAction.hpp"
+#include "log.hpp"
+#include "molecule.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 WorldCenterInBoxAction::NAME[] = "center-in-box";
+
+WorldCenterInBoxAction::WorldCenterInBoxAction() :
+  Action(NAME)
+{}
+
+WorldCenterInBoxAction::~WorldCenterInBoxAction()
+{}
+
+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));
+
+  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;
+  }
+}
+
+Action::state_ptr WorldCenterInBoxAction::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 WorldCenterInBoxAction::performRedo(Action::state_ptr _state){
+  return Action::failure;
+}
+
+bool WorldCenterInBoxAction::canUndo() {
+  return false;
+}
+
+bool WorldCenterInBoxAction::shouldUndo() {
+  return false;
+}
+
+const string WorldCenterInBoxAction::getName() {
+  return NAME;
+}
Index: src/Actions/WorldAction/CenterInBoxAction.hpp
===================================================================
--- src/Actions/WorldAction/CenterInBoxAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/WorldAction/CenterInBoxAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+/*
+ * CenterInBoxAction.hpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#ifndef CENTERINBOXACTION_HPP_
+#define CENTERINBOXACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class WorldCenterInBoxAction : public Action {
+public:
+  WorldCenterInBoxAction();
+  virtual ~WorldCenterInBoxAction();
+
+  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 /* CENTERINBOXACTION_HPP_ */
Index: src/Actions/WorldAction/CenterOnEdgeAction.cpp
===================================================================
--- src/Actions/WorldAction/CenterOnEdgeAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/WorldAction/CenterOnEdgeAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,103 @@
+/*
+ * CenterOnEdgeAction.cpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/WorldAction/CenterOnEdgeAction.hpp"
+#include "atom.hpp"
+#include "log.hpp"
+#include "vector.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/MapOfActions.hpp"
+#include "Helpers/Assert.hpp"
+
+const char WorldCenterOnEdgeAction::NAME[] = "center-edge";
+
+WorldCenterOnEdgeAction::WorldCenterOnEdgeAction() :
+  Action(NAME)
+{}
+
+WorldCenterOnEdgeAction::~WorldCenterOnEdgeAction()
+{}
+
+Action::state_ptr WorldCenterOnEdgeAction::performCall() {
+  Dialog *dialog = UIFactory::getInstance().makeDialog();
+  Vector Min;
+  Vector Max;
+  int j=0;
+
+  dialog->queryEmpty(NAME, MapOfActions::getInstance().getDescription(NAME));
+
+  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;
+  }
+}
+
+Action::state_ptr WorldCenterOnEdgeAction::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 WorldCenterOnEdgeAction::performRedo(Action::state_ptr _state){
+  return Action::failure;
+}
+
+bool WorldCenterOnEdgeAction::canUndo() {
+  return false;
+}
+
+bool WorldCenterOnEdgeAction::shouldUndo() {
+  return false;
+}
+
+const string WorldCenterOnEdgeAction::getName() {
+  return NAME;
+}
Index: src/Actions/WorldAction/CenterOnEdgeAction.hpp
===================================================================
--- src/Actions/WorldAction/CenterOnEdgeAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/WorldAction/CenterOnEdgeAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+/*
+ * CenterOnEdgeAction.hpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#ifndef CENTERONEDGEACTION_HPP_
+#define CENTERONEDGEACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class WorldCenterOnEdgeAction : public Action {
+public:
+  WorldCenterOnEdgeAction();
+  virtual ~WorldCenterOnEdgeAction();
+
+  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 /* CENTERONEDGEACTION_HPP_ */
Index: src/Actions/WorldAction/ChangeBoxAction.cpp
===================================================================
--- src/Actions/WorldAction/ChangeBoxAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/WorldAction/ChangeBoxAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,74 @@
+/*
+ * ChangeBoxAction.cpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/WorldAction/ChangeBoxAction.hpp"
+#include "log.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 WorldChangeBoxAction::NAME[] = "change-box";
+
+WorldChangeBoxAction::WorldChangeBoxAction() :
+  Action(NAME)
+{}
+
+WorldChangeBoxAction::~WorldChangeBoxAction()
+{}
+
+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));
+
+  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;
+  }
+}
+
+Action::state_ptr WorldChangeBoxAction::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 WorldChangeBoxAction::performRedo(Action::state_ptr _state){
+  return Action::failure;
+}
+
+bool WorldChangeBoxAction::canUndo() {
+  return false;
+}
+
+bool WorldChangeBoxAction::shouldUndo() {
+  return false;
+}
+
+const string WorldChangeBoxAction::getName() {
+  return NAME;
+}
Index: src/Actions/WorldAction/ChangeBoxAction.hpp
===================================================================
--- src/Actions/WorldAction/ChangeBoxAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/WorldAction/ChangeBoxAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+/*
+ * ChangeBoxAction.hpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#ifndef CHANGEBOXACTION_HPP_
+#define CHANGEBOXACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class WorldChangeBoxAction : public Action {
+public:
+  WorldChangeBoxAction();
+  virtual ~WorldChangeBoxAction();
+
+  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 /* CHANGEBOXACTION_HPP_ */
Index: src/Actions/WorldAction/InputAction.cpp
===================================================================
--- src/Actions/WorldAction/InputAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/WorldAction/InputAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,109 @@
+/*
+ * InputAction.cpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/WorldAction/InputAction.hpp"
+#include "log.hpp"
+#include "molecule.hpp"
+#include "Parser/FormatParserStorage.hpp"
+#include "Parser/PcpParser.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 WorldInputAction::NAME[] = "input";
+
+WorldInputAction::WorldInputAction() :
+  Action(NAME)
+{}
+
+WorldInputAction::~WorldInputAction()
+{}
+
+Action::state_ptr WorldInputAction::performCall() {
+  Dialog *dialog = UIFactory::getInstance().makeDialog();
+  MoleculeListClass *molecules = World::getInstance().getMolecules();
+  molecule *mol = NULL;
+  std::string filename;
+  std::ifstream test;
+
+  dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME));
+
+  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());
+    } else {
+      DoeLog(1) && (eLog() << Verbose(1) << "Input file does not have a suffix, cannot recognize format." << endl);
+    }
+    delete dialog;
+    return Action::success;
+  } else {
+    delete dialog;
+    return Action::failure;
+  }
+}
+
+Action::state_ptr WorldInputAction::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 WorldInputAction::performRedo(Action::state_ptr _state){
+  return Action::failure;
+}
+
+bool WorldInputAction::canUndo() {
+  return false;
+}
+
+bool WorldInputAction::shouldUndo() {
+  return false;
+}
+
+const string WorldInputAction::getName() {
+  return NAME;
+}
Index: src/Actions/WorldAction/InputAction.hpp
===================================================================
--- src/Actions/WorldAction/InputAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/WorldAction/InputAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+/*
+ * InputAction.hpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#ifndef INPUTACTION_HPP_
+#define INPUTACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class WorldInputAction : public Action {
+public:
+  WorldInputAction();
+  virtual ~WorldInputAction();
+
+  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 /* INPUTACTION_HPP_ */
Index: src/Actions/WorldAction/OutputAction.cpp
===================================================================
--- src/Actions/WorldAction/OutputAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/WorldAction/OutputAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,74 @@
+/*
+ * OutputAction.cpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/WorldAction/OutputAction.hpp"
+#include "Parser/ChangeTracker.hpp"
+#include "log.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 WorldOutputAction::NAME[] = "output";
+
+WorldOutputAction::WorldOutputAction() :
+  Action(NAME)
+{}
+
+WorldOutputAction::~WorldOutputAction()
+{}
+
+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;
+  }
+}
+
+Action::state_ptr WorldOutputAction::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 WorldOutputAction::performRedo(Action::state_ptr _state){
+  return Action::failure;
+}
+
+bool WorldOutputAction::canUndo() {
+  return false;
+}
+
+bool WorldOutputAction::shouldUndo() {
+  return false;
+}
+
+const string WorldOutputAction::getName() {
+  return NAME;
+}
Index: src/Actions/WorldAction/OutputAction.hpp
===================================================================
--- src/Actions/WorldAction/OutputAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/WorldAction/OutputAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+/*
+ * OutputAction.hpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#ifndef OUTPUTACTION_HPP_
+#define OUTPUTACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class WorldOutputAction : public Action {
+public:
+  WorldOutputAction();
+  virtual ~WorldOutputAction();
+
+  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 /* OUTPUTACTION_HPP_ */
Index: src/Actions/WorldAction/RemoveSphereOfAtomsAction.cpp
===================================================================
--- src/Actions/WorldAction/RemoveSphereOfAtomsAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/WorldAction/RemoveSphereOfAtomsAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,90 @@
+/*
+ * 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: src/Actions/WorldAction/RemoveSphereOfAtomsAction.hpp
===================================================================
--- src/Actions/WorldAction/RemoveSphereOfAtomsAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/WorldAction/RemoveSphereOfAtomsAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+/*
+ * 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 ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/WorldAction/RepeatBoxAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,154 @@
+/*
+ * RepeatBoxAction.cpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/WorldAction/RepeatBoxAction.hpp"
+#include "atom.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"
+#include "Descriptors/MoleculeDescriptor.hpp"
+#include "Descriptors/MoleculePtrDescriptor.hpp"
+
+const char WorldRepeatBoxAction::NAME[] = "repeat-box";
+
+WorldRepeatBoxAction::WorldRepeatBoxAction() :
+  Action(NAME)
+{}
+
+WorldRepeatBoxAction::~WorldRepeatBoxAction()
+{}
+
+Action::state_ptr WorldRepeatBoxAction::performCall() {
+  Dialog *dialog = UIFactory::getInstance().makeDialog();
+  Vector Repeater;
+  int count;
+  const element ** Elements;
+  molecule *mol = NULL;
+  int j = 0;
+  atom *Walker = NULL;
+  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"));
+  vector<molecule *> AllMolecules;
+  if (mol != NULL) {
+    DoLog(0) && (Log() << Verbose(0) << "Using molecule " << mol->name << "." << endl);
+    AllMolecules = World::getInstance().getAllMolecules(MoleculeByPtr(mol));
+  } else {
+    DoLog(0) && (Log() << Verbose(0) << "Using all molecules." << endl);
+    AllMolecules = World::getInstance().getAllMolecules();
+  }
+
+  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];
+    }
+
+    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);
+            }
+          }
+        }
+      }
+    }
+    delete(M);
+    delete dialog;
+    return Action::success;
+  } else {
+    delete dialog;
+    return Action::failure;
+  }
+}
+
+Action::state_ptr WorldRepeatBoxAction::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 WorldRepeatBoxAction::performRedo(Action::state_ptr _state){
+  return Action::failure;
+}
+
+bool WorldRepeatBoxAction::canUndo() {
+  return false;
+}
+
+bool WorldRepeatBoxAction::shouldUndo() {
+  return false;
+}
+
+const string WorldRepeatBoxAction::getName() {
+  return NAME;
+}
Index: src/Actions/WorldAction/RepeatBoxAction.hpp
===================================================================
--- src/Actions/WorldAction/RepeatBoxAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/WorldAction/RepeatBoxAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+/*
+ * RepeatBoxAction.hpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+#ifndef REPEATBOXACTION_HPP_
+#define REPEATBOXACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class WorldRepeatBoxAction : public Action {
+public:
+  WorldRepeatBoxAction();
+  virtual ~WorldRepeatBoxAction();
+
+  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 /* REPEATBOXACTION_HPP_ */
Index: src/Actions/WorldAction/ScaleBoxAction.cpp
===================================================================
--- src/Actions/WorldAction/ScaleBoxAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/WorldAction/ScaleBoxAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,91 @@
+/*
+ * ScaleBoxAction.cpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/WorldAction/ScaleBoxAction.hpp"
+#include "atom.hpp"
+#include "log.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 WorldScaleBoxAction::NAME[] = "scale-box";
+
+WorldScaleBoxAction::WorldScaleBoxAction() :
+  Action(NAME)
+{}
+
+WorldScaleBoxAction::~WorldScaleBoxAction()
+{}
+
+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));
+
+  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);
+
+    delete dialog;
+    return Action::success;
+  } else {
+    delete dialog;
+    return Action::failure;
+  }
+}
+
+Action::state_ptr WorldScaleBoxAction::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 WorldScaleBoxAction::performRedo(Action::state_ptr _state){
+  return Action::failure;
+}
+
+bool WorldScaleBoxAction::canUndo() {
+  return false;
+}
+
+bool WorldScaleBoxAction::shouldUndo() {
+  return false;
+}
+
+const string WorldScaleBoxAction::getName() {
+  return NAME;
+}
Index: src/Actions/WorldAction/ScaleBoxAction.hpp
===================================================================
--- src/Actions/WorldAction/ScaleBoxAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/WorldAction/ScaleBoxAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+/*
+ * ScaleBoxAction.hpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#ifndef SCALEBOXACTION_HPP_
+#define SCALEBOXACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class WorldScaleBoxAction : public Action {
+public:
+  WorldScaleBoxAction();
+  virtual ~WorldScaleBoxAction();
+
+  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 /* SCALEBOXACTION_HPP_ */
Index: src/Actions/WorldAction/SetDefaultNameAction.cpp
===================================================================
--- src/Actions/WorldAction/SetDefaultNameAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/WorldAction/SetDefaultNameAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,75 @@
+/*
+ * SetDefaultNameAction.cpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/WorldAction/SetDefaultNameAction.hpp"
+#include "log.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 WorldSetDefaultNameAction::NAME[] = "default-molname";
+
+WorldSetDefaultNameAction::WorldSetDefaultNameAction() :
+  Action(NAME)
+{}
+
+WorldSetDefaultNameAction::~WorldSetDefaultNameAction()
+{}
+
+Action::state_ptr WorldSetDefaultNameAction::performCall() {
+  Dialog *dialog = UIFactory::getInstance().makeDialog();
+  string defaultname;
+
+  defaultname = World::getInstance().getDefaultName();
+  dialog->queryString(NAME, &defaultname, MapOfActions::getInstance().getDescription(NAME));
+
+  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;
+  }
+}
+
+Action::state_ptr WorldSetDefaultNameAction::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 WorldSetDefaultNameAction::performRedo(Action::state_ptr _state){
+  return Action::failure;
+}
+
+bool WorldSetDefaultNameAction::canUndo() {
+  return false;
+}
+
+bool WorldSetDefaultNameAction::shouldUndo() {
+  return false;
+}
+
+const string WorldSetDefaultNameAction::getName() {
+  return NAME;
+}
Index: src/Actions/WorldAction/SetDefaultNameAction.hpp
===================================================================
--- src/Actions/WorldAction/SetDefaultNameAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/WorldAction/SetDefaultNameAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+/*
+ * SetDefaultNameAction.hpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#ifndef SETDEFAULTNAMEACTION_HPP_
+#define SETDEFAULTNAMEACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class WorldSetDefaultNameAction : public Action {
+public:
+  WorldSetDefaultNameAction();
+  virtual ~WorldSetDefaultNameAction();
+
+  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 /* SETDEFAULTNAMEACTION_HPP_ */
Index: src/Actions/WorldAction/SetGaussianBasisAction.cpp
===================================================================
--- src/Actions/WorldAction/SetGaussianBasisAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/WorldAction/SetGaussianBasisAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,73 @@
+/*
+ * SetGaussianBasisAction.cpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/WorldAction/SetGaussianBasisAction.hpp"
+#include "config.hpp"
+#include "log.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 WorldSetGaussianBasisAction::NAME[] = "set-basis";
+
+WorldSetGaussianBasisAction::WorldSetGaussianBasisAction() :
+  Action(NAME)
+{}
+
+WorldSetGaussianBasisAction::~WorldSetGaussianBasisAction()
+{}
+
+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;
+  }
+}
+
+Action::state_ptr WorldSetGaussianBasisAction::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 WorldSetGaussianBasisAction::performRedo(Action::state_ptr _state){
+  return Action::failure;
+}
+
+bool WorldSetGaussianBasisAction::canUndo() {
+  return false;
+}
+
+bool WorldSetGaussianBasisAction::shouldUndo() {
+  return false;
+}
+
+const string WorldSetGaussianBasisAction::getName() {
+  return NAME;
+}
Index: src/Actions/WorldAction/SetGaussianBasisAction.hpp
===================================================================
--- src/Actions/WorldAction/SetGaussianBasisAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/WorldAction/SetGaussianBasisAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+/*
+ * SetGaussianBasisAction.hpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#ifndef SETGAUSSIANBASISACTION_HPP_
+#define SETGAUSSIANBASISACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class WorldSetGaussianBasisAction : public Action {
+public:
+  WorldSetGaussianBasisAction();
+  virtual ~WorldSetGaussianBasisAction();
+
+  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 /* SETGAUSSIANBASISACTION_HPP_ */
Index: src/Actions/WorldAction/SetOutputFormatsAction.cpp
===================================================================
--- src/Actions/WorldAction/SetOutputFormatsAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/WorldAction/SetOutputFormatsAction.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,92 @@
+/*
+ * SetOutputFormatsAction.cpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/WorldAction/SetOutputFormatsAction.hpp"
+#include "Parser/ChangeTracker.hpp"
+#include "Parser/FormatParserStorage.hpp"
+#include "log.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 WorldSetOutputFormatsAction::NAME[] = "set-output";
+
+WorldSetOutputFormatsAction::WorldSetOutputFormatsAction() :
+  Action(NAME)
+{}
+
+WorldSetOutputFormatsAction::~WorldSetOutputFormatsAction()
+{}
+
+Action::state_ptr WorldSetOutputFormatsAction::performCall() {
+  Dialog *dialog = UIFactory::getInstance().makeDialog();
+  vector<std::string> FormatList;
+
+  dialog->queryStrings(NAME, &FormatList, MapOfActions::getInstance().getDescription(NAME));
+
+  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);
+      }
+    }
+    ChangeTracker::getInstance().saveStatus();
+    delete dialog;
+    return Action::success;
+  } else {
+    delete dialog;
+    return Action::failure;
+  }
+}
+
+Action::state_ptr WorldSetOutputFormatsAction::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 WorldSetOutputFormatsAction::performRedo(Action::state_ptr _state){
+  return Action::failure;
+}
+
+bool WorldSetOutputFormatsAction::canUndo() {
+  return false;
+}
+
+bool WorldSetOutputFormatsAction::shouldUndo() {
+  return false;
+}
+
+const string WorldSetOutputFormatsAction::getName() {
+  return NAME;
+}
Index: src/Actions/WorldAction/SetOutputFormatsAction.hpp
===================================================================
--- src/Actions/WorldAction/SetOutputFormatsAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Actions/WorldAction/SetOutputFormatsAction.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+/*
+ * SetOutputFormatsAction.hpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#ifndef SETOUTPUTFORMATSACTION_HPP_
+#define SETOUTPUTFORMATSACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class WorldSetOutputFormatsAction : public Action {
+public:
+  WorldSetOutputFormatsAction();
+  virtual ~WorldSetOutputFormatsAction();
+
+  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 /* SETOUTPUTFORMATSACTION_HPP_ */
Index: src/CommandLineParser.cpp
===================================================================
--- src/CommandLineParser.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/CommandLineParser.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,110 @@
+/*
+ * CommandLineParser.cpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include <boost/program_options.hpp>
+#include <fstream>
+#include <iostream>
+#include <map>
+
+#include "Patterns/Singleton_impl.hpp"
+#include "CommandLineParser.hpp"
+#include "log.hpp"
+#include "verbose.hpp"
+
+using namespace std;
+
+/** Constructor of class CommandLineParser.
+ *
+ */
+CommandLineParser::CommandLineParser() :
+  generic("Generic options"),
+  config("Configuration"),
+  hidden("Hidden options"),
+  visible("Allowed options")
+{}
+
+/** Destructor of class CommandLineParser.
+ *
+ */
+CommandLineParser::~CommandLineParser()
+{}
+
+/** Parses the command line arguments.
+ * Calls program_options::store() and program_options::notify()
+ */
+void CommandLineParser::Parse()
+{
+  po::store(po::command_line_parser(argc,argv).options(cmdline_options).options(visible).run(), vm);
+  ifstream input;
+  input.open("example.cfg");
+  if (!input.fail())
+    po::store(po::parse_config_file(input, config_file_options), vm);
+  input.close();
+  po::notify(vm);
+}
+
+/** Scan the argument list for -a or --arguments and store their order for later use.
+ * \param &ShortFormToActionMap e.g. gives "help" for "h"
+ */
+void CommandLineParser::scanforSequenceOfArguments(map <std::string, std::string> &ShortFormToActionMap)
+{
+  // go through all arguments
+  for (int i=1;i<argc;i++) {
+    (cout << Verbose(1) << "Checking on " << argv[i] << endl);
+    // check whether they begin with - or -- and check that next letter is not numeric, if so insert
+    if (argv[i][0] == '-') {
+      (cout << Verbose(1) << "Possible argument: " << argv[i] << endl);
+      if (argv[i][1] == '-') {
+        (cout << Verbose(1) << "Putting " << argv[i] << " into the sequence." << endl);
+        SequenceOfActions.push_back(&(argv[i][2]));
+      } else if (((argv[i][1] < '0') || (argv[i][1] > '9')) && ((argv[i][1] != '.'))) {
+        map <std::string, std::string>::iterator iter = ShortFormToActionMap.find(&(argv[i][1]));
+        if (iter != ShortFormToActionMap.end()) {
+          (cout << Verbose(1) << "Putting " << iter->second << " for " << iter->first << " into the sequence." << endl);
+          SequenceOfActions.push_back(iter->second);
+        }
+      }
+    }
+  }
+}
+
+
+/** States whether there are command line arguments.
+ * \return true - there are none, false - there is at least one command line argument
+ */
+bool CommandLineParser::isEmpty()
+{
+  return vm.empty();
+}
+
+/** Sets the options.
+ * \param _argc arg count from main()
+ * \param **_argv argument array from main()
+ */
+void CommandLineParser::setOptions(int _argc, char **_argv)
+{
+  argc = _argc;
+  argv = _argv;
+  cmdline_options.add(generic).add(config).add(hidden);
+  config_file_options.add(config).add(hidden);
+  visible.add(generic).add(config);
+}
+
+/** Makes the Parser parse the command line options with current known options.
+ * \param _argc arg count from main()
+ * \param **_argv argument array from main()
+ */
+void CommandLineParser::Run(int _argc, char **_argv, map <std::string, std::string> &ShortFormToActionMap)
+{
+  setOptions(_argc,_argv);
+  Parse();
+  scanforSequenceOfArguments(ShortFormToActionMap);
+}
+
+CONSTRUCT_SINGLETON(CommandLineParser)
Index: src/CommandLineParser.hpp
===================================================================
--- src/CommandLineParser.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/CommandLineParser.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,142 @@
+/*
+ * CommandLineParser.hpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#ifndef COMMANDLINEPARSER_HPP_
+#define COMMANDLINEPARSER_HPP_
+
+#include <boost/program_options.hpp>
+
+namespace po = boost::program_options;
+
+#include "Patterns/Singleton.hpp"
+
+#include <list>
+
+/** This class is a wrapper for boost::program_options.
+ *
+ * <h1> CommandLine Howto </h1>
+ * <h2> Introduction </h2>
+ *
+ * The UIFactory is a base class for the User Interaction. There are three UI specializations:
+ * Text, GUI and CommandLine. Accessing functionality via the CommandLine UI is explained here.
+ *
+ * First, an Action has to be written for the specific functionality. This Action should
+ * be added in Actions/...Action in the respective subdirectory of the following types:
+ *  -# Analysis: Analysis actions like evaluating pair correlation, bonds, ...
+ *  -# Atom: adding, removing, manipulating atoms
+ *  -# Cmd: specifying data bases, verbosity, ...
+ *  -# Fragmentation: fragmenting a system, performing graph analysis, ...
+ *  -# Molecule: adding, removing, manipulating molecules
+ *  -# Parser: Parsing files (loading, saving)
+ *  -# Tesselation: obtaining (non)convex surface of a molecule, embedding, ...
+ *  -# World: Setting Box dimensions, default name of new molecules, ...
+ *
+ *  The CommandLineUIFactory is a specialization of the UIFactory for parsing command
+ *  line parameters, generating and executing actions there from.
+ *
+ *  The idea of the CommandLineFactory is explained elsewhere, here we would like to give a
+ *  receipe for creating new actions.
+ *
+ * <h3>Introducing new actions</h3>
+ *
+ * Let us now introduce what to do if a new action is to be implemented. Here, we use the
+ * CommandLineVersionAction as an example.
+ * This consists if basically three parts:
+ * 1. Create the files, write the classes and make them compilable
+ *   - Create new source and header files in one of the above subfolders in the Actions folder,
+ *     e.g. create VersionAction.cpp and VersionAction.hpp in Actions/Cmd/
+ *   - Give it a sensible class name, the convention is <type><what it does>Action,
+ *     where <type> is basically the naming (written out) of the subdirectory,
+ *     e.g. class CommandLineVersionAction.
+ *   - Add the source and header file to the respective variables in molecuilder/src/Makefile.am,
+ *     e.g. if you add a Cmd action the variables are CMDACTIONSOURCE and CMDACTIONHEADER,
+ *     such that they get compiled.
+ * 2. Add an instance to the CommandLineUIFactory, such that they are known to the UI.
+ *   - Add the header file as an include to UIElements/CommandLineWindow.cpp, e.g.
+ *     #include "Actions/Cmd/VersionAction.hpp"
+ *   - Add an instance of your class to the specific populater-function in
+ *     UIElements/CommandLineWindow.cpp, e.g. for the above Cmd action, add to populateCmdActions()
+ *     add new CommandLineVersionAction().
+ *     This will automatically register in the ActionRegistry.
+ * 3. Give them an option name, short hand an description, such that they can be referenced from
+ *    the command line.
+ *   - think of a new key name, e.g. "version", which is the long form of the command parameter,
+ *     i.e. --version).
+ *   - add this key to every map of MapofActions, i.e. to
+ *     - MapofActions::DescriptionMap: the description which appears as help and tooltip
+ *     - MapofActions::ShortFormMap: the short form of the command parameter (e.g. -v)
+ *     - MapofActions::ValueMap: the value the command parameter has (do not create if it does not need one)
+ *   - If your action requires additional parameters, these need to be added in the same manner as in
+ *     the list item above.
+ *
+ *  Don't forget to write the actual code. :)
+ *
+ * <h3>Writing an action</h3>
+ *
+ *  As you write a new action you may think in terms of the command line, i.e. you want to use this
+ *  new functionality you add by calling molecuilder as: ./molecuilder --super-action foobar.txt, where
+ *  the key of your new action would be "super-action". While this is fine, keep in mind, that your action
+ *  should be useable for the other UI specializations as well, i.e. from the menu and the GUI. Therefore,
+ *  -# Don't use cin to ask the user for input: Use Query...()!
+ *  -# Rather don't use cout/cerrs, but either give Log() or eLog() or use QueryEmpty() if you want to give
+ *     the user specific information what you ask of him.
+ *
+ */
+class CommandLineParser : public Singleton<CommandLineParser> {
+  friend class Singleton<CommandLineParser>;
+public:
+
+  // Parses the command line arguments in CommandLineParser::**argv with currently known options.
+  void Run(int _argc, char **_argv, std::map <std::string, std::string> &ShortFormToActionMap);
+
+  // Checks whether there have been any commands on the command line.
+  bool isEmpty();
+
+  /* boost's program_options are sorted into three categories:
+   * -# generic options: option available to both command line and config
+   * -# config options: only available in the config file
+   * -# hidden options: options which the user is not shown on "help"
+   */
+  po::options_description generic;
+  po::options_description config;
+  po::options_description hidden;
+  po::positional_options_description inputfile;
+
+  po::options_description visible;
+
+  po::variables_map vm;
+
+  // private sequence of actions as they appeared on the command line
+  std::list<std::string> SequenceOfActions;
+
+private:
+  // private constructor and destructor
+  CommandLineParser();
+  virtual ~CommandLineParser();
+
+  /* The following program_options options_decriptions are used to
+   * generate the various cases and call differently in Parse().
+   */
+  po::options_description cmdline_options;
+  po::options_description config_file_options;
+
+  // Sets the options from the three cases.
+  void setOptions(int _argc, char **_argv);
+
+  // Parses all options from command line and config file
+  void Parse();
+
+  // as boost's program_options does not care about of order of appearance but we do for actions,
+  // we have to have a list and a function to obtain it.
+  void scanforSequenceOfArguments(std::map <std::string, std::string> &ShortFormToActionMap);
+
+  // argument counter and array passed on from main()
+  int argc;
+  char **argv;
+};
+
+#endif /* COMMANDLINEPARSER_HPP_ */
Index: src/ConfigFileBuffer.cpp
===================================================================
--- src/ConfigFileBuffer.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/ConfigFileBuffer.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,182 @@
+/*
+ * ConfigFileBuffer.cpp
+ *
+ *  Created on: 12.06.2010
+ *      Author: heber
+ */
+
+#include "ConfigFileBuffer.hpp"
+#include "helpers.hpp"
+#include "lists.hpp"
+#include "log.hpp"
+#include "World.hpp"
+
+/******************************** Functions for class ConfigFileBuffer **********************/
+
+/** Structure containing compare function for Ion_Type sorting.
+ */
+struct IonTypeCompare {
+  bool operator()(const char* s1, const char *s2) const {
+    char number1[8];
+    char number2[8];
+    const char *dummy1, *dummy2;
+    //Log() << Verbose(0) << s1 << "  " << s2 << endl;
+    dummy1 = strchr(s1, '_')+sizeof(char)*5;  // go just after "Ion_Type"
+    dummy2 = strchr(dummy1, '_');
+    strncpy(number1, dummy1, dummy2-dummy1); // copy the number
+    number1[dummy2-dummy1]='\0';
+    dummy1 = strchr(s2, '_')+sizeof(char)*5;  // go just after "Ion_Type"
+    dummy2 = strchr(dummy1, '_');
+    strncpy(number2, dummy1, dummy2-dummy1); // copy the number
+    number2[dummy2-dummy1]='\0';
+    if (atoi(number1) != atoi(number2))
+      return (atoi(number1) < atoi(number2));
+    else {
+      dummy1 = strchr(s1, '_')+sizeof(char);
+      dummy1 = strchr(dummy1, '_')+sizeof(char);
+      dummy2 = strchr(dummy1, ' ') < strchr(dummy1, '\t') ? strchr(dummy1, ' ') : strchr(dummy1, '\t');
+      strncpy(number1, dummy1, dummy2-dummy1); // copy the number
+      number1[dummy2-dummy1]='\0';
+      dummy1 = strchr(s2, '_')+sizeof(char);
+      dummy1 = strchr(dummy1, '_')+sizeof(char);
+      dummy2 = strchr(dummy1, ' ') < strchr(dummy1, '\t') ? strchr(dummy1, ' ') : strchr(dummy1, '\t');
+      strncpy(number2, dummy1, dummy2-dummy1); // copy the number
+      number2[dummy2-dummy1]='\0';
+      return (atoi(number1) < atoi(number2));
+    }
+  }
+};
+
+/** Constructor for ConfigFileBuffer class.
+ */
+ConfigFileBuffer::ConfigFileBuffer() : buffer(NULL), LineMapping(NULL), CurrentLine(0), NoLines(0)
+{
+};
+
+/** Constructor for ConfigFileBuffer class with filename to be parsed.
+ * \param *filename file name
+ */
+ConfigFileBuffer::ConfigFileBuffer(const char * const filename) : buffer(NULL), LineMapping(NULL), CurrentLine(0), NoLines(0)
+{
+  InitFileBuffer(filename);
+}
+
+void ConfigFileBuffer::InitFileBuffer(const char * const filename)
+{
+  ifstream *file= new ifstream(filename);
+  InitFileBuffer(file);
+}
+
+void ConfigFileBuffer::InitFileBuffer(istream *file)
+{
+  char line[MAXSTRINGSIZE];
+
+  RemoveMapping();
+
+  // prescan number of lines
+  if (file->fail()) {
+    DoeLog(1) && (eLog()<< Verbose(1) << "config file missing!" << endl);
+    return;
+  }
+  NoLines = 0; // we're overcounting by one
+  long file_position = file->tellg(); // mark current position
+  do {
+    file->getline(line, MAXSTRINGSIZE-1);
+    NoLines++;
+  } while (!file->eof());
+  file->clear();
+  file->seekg(file_position, ios::beg);
+  DoLog(1) && (Log() << Verbose(1) << NoLines-1 << " lines were recognized." << endl);
+
+  // allocate buffer's 1st dimension
+  if (buffer != NULL) {
+    DoeLog(1) && (eLog()<< Verbose(1) << "FileBuffer->buffer is not NULL!" << endl);
+    return;
+  } else
+    buffer = new char *[NoLines];
+
+  // scan each line and put into buffer
+  int lines=0;
+  int i;
+  do {
+    buffer[lines] = new char[MAXSTRINGSIZE];
+    file->getline(buffer[lines], MAXSTRINGSIZE-1);
+    i = strlen(buffer[lines]);
+    buffer[lines][i] = '\n';
+    buffer[lines][i+1] = '\0';
+    lines++;
+  } while((!file->eof()) && (lines < NoLines));
+  DoLog(1) && (Log() << Verbose(1) << lines-1 << " lines were read into the buffer." << endl);
+  file->clear();
+  file->seekg(file_position, ios::beg);
+
+  InitMapping();
+}
+
+/** Destructor for ConfigFileBuffer class.
+ */
+ConfigFileBuffer::~ConfigFileBuffer()
+{
+  RemoveBuffer();
+  RemoveMapping();
+}
+
+
+/** Create trivial mapping.
+ */
+void ConfigFileBuffer::InitMapping()
+{
+  LineMapping = new int[NoLines];
+  for (int i=0;i<NoLines;i++)
+    LineMapping[i] = i;
+  MappingAllocated = true;
+}
+
+/** Remove allocated mapping.
+ */
+void ConfigFileBuffer::RemoveMapping()
+{
+  delete[](LineMapping);
+  MappingAllocated = false;
+}
+
+/** Remove allocated mapping.
+ */
+void ConfigFileBuffer::RemoveBuffer()
+{
+  for(int i=0;i<NoLines;++i)
+    delete[](buffer[i]);
+  delete[](buffer);
+}
+
+
+/** Creates a mapping for the \a *FileBuffer's lines containing the Ion_Type keyword such that they are sorted.
+ * \a *map on return contains a list of NoAtom entries such that going through the list, yields indices to the
+ * lines in \a *FileBuffer in a sorted manner of the Ion_Type?_? keywords. We assume that ConfigFileBuffer::CurrentLine
+ * points to first Ion_Type entry.
+ * \param *FileBuffer pointer to buffer structure
+ * \param NoAtoms of subsequent lines to look at
+ */
+void ConfigFileBuffer::MapIonTypesInBuffer(const int NoAtoms)
+{
+  map<const char *, int, IonTypeCompare> IonTypeLineMap;
+  if (!MappingAllocated) {
+    InitMapping();
+  }
+
+  // put all into hashed map
+  for (int i=0; i<NoAtoms; ++i) {
+    IonTypeLineMap.insert(pair<const char *, int> (buffer[CurrentLine+i], CurrentLine+i));
+  }
+
+  // fill map
+  int nr=0;
+  for (map<const char *, int, IonTypeCompare>::iterator runner = IonTypeLineMap.begin(); runner != IonTypeLineMap.end(); ++runner) {
+    if (CurrentLine+nr < NoLines)
+      LineMapping[CurrentLine+(nr++)] = runner->second;
+    else {
+      DoeLog(0) && (eLog()<< Verbose(0) << "config::MapIonTypesInBuffer - NoAtoms is wrong: We are past the end of the file!" << endl);
+      performCriticalExit();
+    }
+  }
+}
Index: src/ConfigFileBuffer.hpp
===================================================================
--- src/ConfigFileBuffer.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/ConfigFileBuffer.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,53 @@
+/*
+ * ConfigFileBuffer.hpp
+ *
+ *  Created on: 12.06.2010
+ *      Author: heber
+ */
+
+#ifndef CONFIGFILEBUFFER_HPP_
+#define CONFIGFILEBUFFER_HPP_
+
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <iostream>
+
+/****************************************** forward declarations *****************************/
+
+/********************************************** declarations *******************************/
+
+class ConfigFileBuffer {
+  public:
+    char **buffer;
+    int *LineMapping;
+    int CurrentLine;
+    int NoLines;
+
+    ConfigFileBuffer();
+    ConfigFileBuffer(const char * const filename);
+    ~ConfigFileBuffer();
+
+    void InitFileBuffer(const char * const filename);
+    void InitFileBuffer(std::istream *file);
+    void MapIonTypesInBuffer(const int NoAtoms);
+
+private:
+
+    /*
+     * Whether LineMapping is allocated or not.
+     */
+    bool MappingAllocated;
+
+    void InitMapping();
+    void RemoveMapping();
+    void RemoveBuffer();
+};
+
+
+#endif /* CONFIGFILEBUFFER_HPP_ */
Index: src/Descriptors/AtomDescriptor.cpp
===================================================================
--- src/Descriptors/AtomDescriptor.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Descriptors/AtomDescriptor.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,175 @@
+/*
+ * AtomDescriptor.cpp
+ *
+ *  Created on: Feb 5, 2010
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Descriptors/AtomDescriptor.hpp"
+#include "Descriptors/AtomDescriptor_impl.hpp"
+
+#include "World.hpp"
+#include "atom.hpp"
+
+#include <boost/bind.hpp>
+
+#include <iostream>
+
+using namespace std;
+
+typedef World::AtomSet::iterator atoms_iter_t;
+
+/************************ Forwarding object **************************************/
+
+
+AtomDescriptor::AtomDescriptor(impl_ptr _impl) :
+    impl(_impl)
+{}
+
+AtomDescriptor::AtomDescriptor(const AtomDescriptor& src) :
+    impl(src.get_impl())
+{}
+
+AtomDescriptor::~AtomDescriptor()
+{}
+
+AtomDescriptor& AtomDescriptor::operator=(AtomDescriptor &src){
+  if(&src!=this) {
+    impl=src.get_impl();
+  }
+  return *this;
+}
+
+atom* AtomDescriptor::find(){
+  return impl->find();
+}
+
+std::vector<atom*> AtomDescriptor::findAll(){
+  return impl->findAll();
+}
+
+AtomDescriptor::impl_ptr AtomDescriptor::get_impl() const{
+  return impl;
+}
+
+
+
+
+/**************************** implementation ********************/
+
+AtomDescriptor_impl::AtomDescriptor_impl()
+{
+}
+
+AtomDescriptor_impl::~AtomDescriptor_impl()
+{
+}
+
+World::AtomSet& AtomDescriptor_impl::getAtoms(){
+  return World::getInstance().atoms;
+}
+
+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;
+}
+
+vector<atom*> AtomDescriptor_impl::findAll() {
+  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);
+    }
+  }
+  return res;
+}
+
+/************************** Universe and Emptyset *****************/
+
+AtomAllDescriptor_impl::AtomAllDescriptor_impl()
+{}
+
+AtomAllDescriptor_impl::~AtomAllDescriptor_impl()
+{}
+
+bool AtomAllDescriptor_impl::predicate(std::pair<atomId_t,atom*>){
+  return true;
+}
+
+AtomDescriptor AllAtoms(){
+  return AtomDescriptor(AtomDescriptor::impl_ptr(new AtomAllDescriptor_impl));
+}
+
+AtomNoneDescriptor_impl::AtomNoneDescriptor_impl()
+{}
+
+AtomNoneDescriptor_impl::~AtomNoneDescriptor_impl()
+{}
+
+bool AtomNoneDescriptor_impl::predicate(std::pair<atomId_t,atom*>){
+  return false;
+}
+
+AtomDescriptor NoAtoms(){
+  return AtomDescriptor(AtomDescriptor::impl_ptr(new AtomNoneDescriptor_impl));
+}
+
+/************************** Operator stuff ************************/
+
+// AND
+AtomAndDescriptor_impl::AtomAndDescriptor_impl(AtomDescriptor::impl_ptr _lhs, AtomDescriptor::impl_ptr _rhs) :
+    lhs(_lhs), rhs(_rhs)
+{}
+
+AtomAndDescriptor_impl::~AtomAndDescriptor_impl()
+{}
+
+bool AtomAndDescriptor_impl::predicate(std::pair<atomId_t,atom*> atom){
+  return lhs->predicate(atom) && rhs->predicate(atom);
+}
+AtomDescriptor operator&&(const AtomDescriptor &lhs, const AtomDescriptor &rhs){
+  AtomDescriptor::impl_ptr newImpl = AtomDescriptor::impl_ptr(new AtomAndDescriptor_impl(lhs.get_impl(),rhs.get_impl()));
+  return AtomDescriptor(newImpl);
+}
+
+// OR
+AtomOrDescriptor_impl::AtomOrDescriptor_impl(AtomDescriptor::impl_ptr _lhs ,AtomDescriptor::impl_ptr _rhs) :
+    lhs(_lhs), rhs(_rhs)
+{}
+
+AtomOrDescriptor_impl::~AtomOrDescriptor_impl(){
+}
+
+bool AtomOrDescriptor_impl::predicate(std::pair<atomId_t,atom*> atom){
+  return lhs->predicate(atom) || rhs->predicate(atom);
+}
+
+AtomDescriptor  operator||(const AtomDescriptor &lhs, const AtomDescriptor &rhs){
+  AtomDescriptor::impl_ptr newImpl = AtomDescriptor::impl_ptr(new AtomOrDescriptor_impl(lhs.get_impl(),rhs.get_impl()));
+  return AtomDescriptor(newImpl);
+}
+
+// NOT
+
+AtomNotDescriptor_impl::AtomNotDescriptor_impl(AtomDescriptor::impl_ptr _arg) :
+    arg(_arg)
+{}
+
+
+AtomNotDescriptor_impl::~AtomNotDescriptor_impl()
+{
+}
+
+bool AtomNotDescriptor_impl::predicate(std::pair<atomId_t,atom*> atom){
+ return !(arg->predicate(atom));
+}
+
+AtomDescriptor operator!(const AtomDescriptor &arg){
+  AtomDescriptor::impl_ptr newImpl = AtomDescriptor::impl_ptr(new AtomNotDescriptor_impl(arg.get_impl()));
+  return AtomDescriptor(newImpl);
+}
Index: src/Descriptors/AtomDescriptor.hpp
===================================================================
--- src/Descriptors/AtomDescriptor.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Descriptors/AtomDescriptor.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,114 @@
+/*
+ * AtomDescriptor.hpp
+ *
+ *  Created on: Feb 5, 2010
+ *      Author: crueger
+ */
+
+#ifndef ATOMDESCRIPTOR_HPP_
+#define ATOMDESCRIPTOR_HPP_
+
+
+#include <vector>
+#include <map>
+#include <boost/shared_ptr.hpp>
+#include "World.hpp"
+
+class World;
+class atom;
+
+// internal implementation, allows assignment, copying etc
+class AtomDescripter_impl;
+
+/**
+ * An AtomDescriptor describes a Set of Atoms from the World. Can be used for any method that needs to work on
+ * a specific set of Atoms.
+ *
+ * This Class is implemented using the PIMPL-Idion, i.e. this class only contains an abstract structure
+ * that forwards any request to a wrapped pointer-to-implementation. This way operators and calculations
+ * on Descriptors are possible.
+ *
+ * Concrete Implementation Objects can be shared between multiple Wrappers, so make sure that
+ * any Implementation remainst constant during lifetime.
+ */
+class AtomDescriptor {
+  // close coupling to the world to allow access
+  friend atom* World::getAtom(AtomDescriptor descriptor);
+  friend std::vector<atom*> World::getAllAtoms(AtomDescriptor descriptor);
+  template <class,class,class> friend class SelectiveIterator;
+
+  friend AtomDescriptor operator&&(const AtomDescriptor &lhs, const AtomDescriptor &rhs);
+  friend AtomDescriptor operator||(const AtomDescriptor &lhs, const AtomDescriptor &rhs);
+  friend AtomDescriptor operator!(const AtomDescriptor &arg);
+
+public:
+  typedef boost::shared_ptr<AtomDescriptor_impl> impl_ptr; //!< Allow easy changes of the pointer-to-implementation type
+
+  AtomDescriptor(impl_ptr);
+
+  /**
+   * Copy constructor.
+   * Takes the Implementation from the copied object and sets it's own pointer to link there.
+   * This way the actuall implementation object is shared between copy and original
+   */
+  AtomDescriptor(const AtomDescriptor&);
+  ~AtomDescriptor();
+
+  /**
+   * Assignment Operator.
+   *
+   * Implemented by setting the pointer to the new Implementation.
+   */
+  AtomDescriptor &operator=(AtomDescriptor &);
+
+protected:
+  /**
+   * forward Method to implementation
+   */
+  atom* find();
+
+  /**
+   * forward Method to implementation
+   */
+  std::vector<atom*> findAll();
+
+  /**
+   * Return the implementation this Wrapper currently points to.
+   * Used for copying, assignment and in Iterators over subsets of the World.
+   */
+  impl_ptr get_impl() const;
+
+private:
+  impl_ptr impl;
+};
+
+/**
+ * produce an Atomdescriptor that at the point of construction contains an implementation that matches all Atoms
+ */
+AtomDescriptor AllAtoms();
+
+/**
+ * produce an Atomdescriptor that at the point of construction contains an implementation that matches no Atoms
+ */
+AtomDescriptor NoAtoms();
+
+/**
+ * Set Intersection for two Atomdescriptors. The resulting Atomdescriptor will only match an Atom if both
+ * given Atomdescriptors also match. Uses short circuit inside, so the second predicate wont be called
+ * when the first one failed.
+ */
+AtomDescriptor operator&&(const AtomDescriptor &lhs, const AtomDescriptor &rhs);
+
+/**
+ * Set Union for two AtomDescriptors. The resulting AtomDescriptor will match an Atom if at least one of
+ * the two given AtomDescriptors does match. Used short circuit inside, so the second predicate wont
+ * be called when the first one failed.
+ */
+AtomDescriptor operator||(const AtomDescriptor &lhs, const AtomDescriptor &rhs);
+
+/**
+ * Set inversion for an AtomDescriptor. Matches an Atom if the given AtomDescriptor did not match.
+ */
+AtomDescriptor operator!(const AtomDescriptor &arg);
+
+#endif /* ATOMDESCRIPTOR_HPP_ */
Index: src/Descriptors/AtomDescriptor_impl.hpp
===================================================================
--- src/Descriptors/AtomDescriptor_impl.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Descriptors/AtomDescriptor_impl.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,145 @@
+#ifndef ATOMDESCRIPTOR_IMPL_HPP
+#define ATOMDESCRIPTOR_IMPL_HPP
+
+#include "Descriptors/AtomDescriptor.hpp"
+
+/************************ Declarations of implementation Objects ************************/
+
+/**
+ * This class implements a general Base class for AtomDescriptors using the PIMPL-Idiom
+ *
+ * The predicate for this class is empty and should be implemented by derived classes.
+ * By the predicate it is described which atoms should be picked for a given descriptor.
+ */
+
+class AtomDescriptor_impl
+{
+  friend class AtomDescriptor;
+public:
+
+  AtomDescriptor_impl();
+  virtual ~AtomDescriptor_impl();
+
+  /**
+   * Implement this abstract Method to make a concrete AtomDescriptor pick certain Atoms
+   */
+  virtual bool predicate(std::pair<atomId_t,atom*>)=0;
+
+protected:
+
+  /**
+   * This method is called when the Descriptor is used to find the first matching
+   * Atom. Walks through all Atoms and stops on the first match. Can be implemented
+   * when the searched Atom can be found in a more efficient way. Calculated
+   * Atomdescriptors will always use this method, so no improvement there.
+   */
+  virtual atom* find();
+
+  /**
+   * This method is called when the Descriptor is used to find all matching Atoms.
+   * Walks through all Atoms and tests the predicate on each one. A vector of all
+   * matching Atoms is returned.
+   */
+  virtual std::vector<atom*> findAll();
+
+  /**
+   * This method is used internally to query the Set of Atoms from the world.
+   * By using this method derived classes can also access the Internal World Datastructre.
+   * Implemented in full in the Base Descriptor Implementation, so only this one method
+   * needs to be friend with the World class.
+   */
+  World::AtomSet& getAtoms();
+};
+
+/************************** Universe and Emptyset *****************/
+
+/**
+ * A simple AtomDescriptor that will always match all Atoms present in the World.
+ */
+class AtomAllDescriptor_impl : public AtomDescriptor_impl {
+public:
+  AtomAllDescriptor_impl();
+  virtual ~AtomAllDescriptor_impl();
+
+  /**
+   * Always returns true for any Atom
+   */
+  virtual bool predicate(std::pair<atomId_t,atom*>);
+};
+
+
+/**
+ * An AtomDescriptor that never matches any Atom in the World.
+ */
+class AtomNoneDescriptor_impl : public AtomDescriptor_impl {
+public:
+  AtomNoneDescriptor_impl();
+  virtual ~AtomNoneDescriptor_impl();
+
+  /**
+   * Always returns false for any Atom
+   */
+  virtual bool predicate(std::pair<atomId_t,atom*>);
+};
+
+/************************** Operator stuff ************************/
+
+/**
+ * Intersection of two AtomDescriptors
+ */
+class AtomAndDescriptor_impl : public AtomDescriptor_impl
+{
+public:
+  AtomAndDescriptor_impl(AtomDescriptor::impl_ptr _lhs, AtomDescriptor::impl_ptr _rhs);
+  ~AtomAndDescriptor_impl();
+
+  /**
+   * This predicate uses the predicate from the first && the predicate from the
+   * second Descriptor to decide if an Atom should be selected.
+   */
+  virtual bool predicate(std::pair<atomId_t,atom*>);
+
+private:
+  AtomDescriptor::impl_ptr lhs;
+  AtomDescriptor::impl_ptr rhs;
+};
+
+/**
+ * Union of two AtomDescriptors
+ */
+class AtomOrDescriptor_impl : public AtomDescriptor_impl
+{
+public:
+  AtomOrDescriptor_impl(AtomDescriptor::impl_ptr _lhs, AtomDescriptor::impl_ptr _rhs);
+  virtual ~AtomOrDescriptor_impl();
+
+  /**
+   * This predicate uses the predicate form the first || the predicate from the
+   * second Descriptor to decide if an Atom should be selected.
+   */
+  virtual bool predicate(std::pair<atomId_t,atom*>);
+
+private:
+  AtomDescriptor::impl_ptr lhs;
+  AtomDescriptor::impl_ptr rhs;
+};
+
+/**
+ * Set Inversion of a Descriptor
+ */
+class AtomNotDescriptor_impl : public AtomDescriptor_impl
+{
+public:
+  AtomNotDescriptor_impl(AtomDescriptor::impl_ptr _arg);
+  virtual ~AtomNotDescriptor_impl();
+
+  /**
+   * Opposite of the given descriptor predicate.
+   */
+  virtual bool predicate(std::pair<atomId_t,atom*>);
+
+private:
+  AtomDescriptor::impl_ptr arg;
+};
+
+#endif //ATOMDESCRIPTOR_IMPL_HPP
Index: src/Descriptors/AtomIdDescriptor.cpp
===================================================================
--- src/Descriptors/AtomIdDescriptor.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Descriptors/AtomIdDescriptor.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+/*
+ * AtomIdDescriptor.cpp
+ *
+ *  Created on: Feb 5, 2010
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "AtomIdDescriptor.hpp"
+#include "AtomIdDescriptor_impl.hpp"
+
+#include "atom.hpp"
+
+using namespace std;
+
+
+AtomIdDescriptor_impl::AtomIdDescriptor_impl(atomId_t _id) :
+  id(_id)
+{}
+
+AtomIdDescriptor_impl::~AtomIdDescriptor_impl()
+{}
+
+bool AtomIdDescriptor_impl::predicate(std::pair<atomId_t,atom*> atom) {
+  return atom.first==id;
+}
+
+AtomDescriptor AtomById(atomId_t id){
+  return AtomDescriptor(AtomDescriptor::impl_ptr(new AtomIdDescriptor_impl(id)));
+}
+
+atom *AtomIdDescriptor_impl::find(){
+  World::AtomSet atoms = getAtoms();
+  World::AtomSet::iterator res = atoms.find(id);
+  return (res!=atoms.end())?((*res).second):0;
+}
+
+vector<atom*> AtomIdDescriptor_impl::findAll(){
+  atom *res = find();
+  return (res)?(vector<atom*>(1,res)):(vector<atom*>());
+}
Index: src/Descriptors/AtomIdDescriptor.hpp
===================================================================
--- src/Descriptors/AtomIdDescriptor.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Descriptors/AtomIdDescriptor.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,16 @@
+/*
+ * AtomIdDescriptor.hpp
+ *
+ *  Created on: Feb 5, 2010
+ *      Author: crueger
+ */
+
+#ifndef ATOMIDDESCRIPTOR_HPP_
+#define ATOMIDDESCRIPTOR_HPP_
+
+#include "defs.hpp"
+#include "Descriptors/AtomDescriptor.hpp"
+
+AtomDescriptor AtomById(atomId_t id);
+
+#endif /* ATOMIDDESCRIPTOR_HPP_ */
Index: src/Descriptors/AtomIdDescriptor_impl.hpp
===================================================================
--- src/Descriptors/AtomIdDescriptor_impl.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Descriptors/AtomIdDescriptor_impl.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,21 @@
+#ifndef ATOMIDDESCRIPTOR_IMPL_HPP
+#define ATOMIDDESCRIPTOR_IMPL_HPP
+
+#include "Descriptors/AtomDescriptor_impl.hpp"
+
+class AtomIdDescriptor_impl : public AtomDescriptor_impl
+{
+public:
+  AtomIdDescriptor_impl(atomId_t _id);
+  virtual ~AtomIdDescriptor_impl();
+
+  bool predicate(std::pair<atomId_t,atom*> atom);
+
+protected:
+  virtual atom *find();
+  virtual std::vector<atom*> findAll();
+private:
+  atomId_t id;
+};
+
+#endif //ATOMIDDESCRIPTOR_IMPL_HPP
Index: src/Descriptors/AtomTypeDescriptor.cpp
===================================================================
--- src/Descriptors/AtomTypeDescriptor.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Descriptors/AtomTypeDescriptor.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,35 @@
+/*
+ * AtomTypeDescriptor_impl.cpp
+ *
+ *  Created on: Feb 25, 2010
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Descriptors/AtomTypeDescriptor.hpp"
+#include "Descriptors/AtomTypeDescriptor_impl.hpp"
+
+#include "atom.hpp"
+#include "World.hpp"
+#include "periodentafel.hpp"
+
+AtomTypeDescriptor_impl::AtomTypeDescriptor_impl(const element* _type) :
+  type(_type)
+{}
+
+AtomTypeDescriptor_impl::~AtomTypeDescriptor_impl()
+{}
+
+bool AtomTypeDescriptor_impl::predicate(std::pair<atomId_t,atom*> atom) {
+  return (atom.second->getType()==type);
+}
+
+AtomDescriptor AtomByType(const element *elem){
+  return AtomDescriptor(AtomDescriptor::impl_ptr(new AtomTypeDescriptor_impl(elem)));
+}
+
+AtomDescriptor AtomByType(int Z){
+  const element * elem = World::getInstance().getPeriode()->FindElement(Z);
+  return AtomByType(elem);
+}
Index: src/Descriptors/AtomTypeDescriptor.hpp
===================================================================
--- src/Descriptors/AtomTypeDescriptor.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Descriptors/AtomTypeDescriptor.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,18 @@
+/*
+ * AtomTypeDescriptor.h
+ *
+ *  Created on: Feb 25, 2010
+ *      Author: crueger
+ */
+
+#ifndef ATOMTYPEDESCRIPTOR_HPP
+#define ATOMTYPEDESCRIPTOR_HPP
+
+#include "Descriptors/AtomDescriptor.hpp"
+
+class element;
+
+AtomDescriptor AtomByType(const element *);
+AtomDescriptor AtomByType(int);
+
+#endif /* ATOMTYPEDESCRIPTOR_HPP */
Index: src/Descriptors/AtomTypeDescriptor_impl.hpp
===================================================================
--- src/Descriptors/AtomTypeDescriptor_impl.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Descriptors/AtomTypeDescriptor_impl.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,24 @@
+/*
+ * AtomTypeDescriptor_impl.hpp
+ *
+ *  Created on: Feb 25, 2010
+ *      Author: crueger
+ */
+
+#ifndef ATOMTYPEDESCRIPTOR_IMPL_HPP_
+#define ATOMTYPEDESCRIPTOR_IMPL_HPP_
+
+#include "Descriptors/AtomDescriptor_impl.hpp"
+
+class AtomTypeDescriptor_impl : public AtomDescriptor_impl
+{
+public:
+  AtomTypeDescriptor_impl(const element* _type);
+  virtual ~AtomTypeDescriptor_impl();
+
+  bool predicate(std::pair<atomId_t,atom*> atom);
+private:
+  const element * const type;
+};
+
+#endif /* ATOMTYPEDESCRIPTOR_IMPL_HPP_ */
Index: src/Descriptors/DescriptorBase.hpp
===================================================================
--- src/Descriptors/DescriptorBase.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Descriptors/DescriptorBase.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,101 @@
+/*
+ * DescriptorBase.hpp
+ *
+ *  Created on: Mar 12, 2010
+ *      Author: crueger
+ */
+
+#ifndef DESCRIPTORBASE_HPP_
+#define DESCRIPTORBASE_HPP_
+
+#include <vector>
+#include <boost/shared_ptr.hpp>
+
+/***
+ * Code in this file is not used.
+ *
+ * I was not able to figure out how to factor out the common code for
+ * descriptors and have given up :-( . If somebody else wants to have
+ * another shot just go ahead, but expect a hard ride from here on.
+ */
+
+template<class _Target,
+         class _Container>
+class DescriptorBase_impl;
+
+
+template<class _Target,
+         class _Container>
+class SelectiveIterator;
+
+template<class _Target,
+         class _Container>
+class DescriptorBase
+{
+  friend class DescriptorBase_impl<_Target,_Container>;
+  friend class SelectiveIterator<_Target,_Container>;
+
+
+  // expose the type of this descriptor to the public
+public:
+  typedef _Target     Target;
+  typedef std::vector<Target> TargetVec;
+
+protected:
+  typedef _Container  Container;
+  typedef typename Container::iterator iterator;
+
+  typedef DescriptorBase_impl<Target,Container>  impl;
+  typedef boost::shared_ptr<impl> impl_ptr;
+
+
+public:
+
+  DescriptorBase();
+  DescriptorBase(const DescriptorBase&);
+  DescriptorBase(impl_ptr);
+  virtual ~DescriptorBase();
+
+  DescriptorBase& operator=(const DescriptorBase&);
+
+  /**
+   * forward Method to implementation
+   */
+  Target find(Container&);
+
+  /**
+   * forward Method to implementation
+   */
+  TargetVec findAll(Container&);
+
+
+private:
+  impl_ptr theImpl;
+};
+
+template<class _Target,
+         class _Container>
+DescriptorBase<_Target,_Container> AllX();
+
+template<class _Target,
+         class _Container>
+DescriptorBase<_Target,_Container> NoX();
+
+template<class _Target,
+         class _Container>
+DescriptorBase<_Target,_Container>
+  operator&&(DescriptorBase<_Target,_Container>&,
+             DescriptorBase<_Target,_Container>&);
+
+template<class _Target,
+         class _Container>
+DescriptorBase<_Target,_Container>
+  operator||(DescriptorBase<_Target,_Container>&,
+             DescriptorBase<_Target,_Container>&);
+
+template<class _Target,
+         class _Container>
+DescriptorBase<_Target,_Container>
+  operator!(DescriptorBase<_Target,_Container>&);
+
+#endif /* DESCRIPTORBASE_HPP_ */
Index: src/Descriptors/DescriptorBase_impl.hpp
===================================================================
--- src/Descriptors/DescriptorBase_impl.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Descriptors/DescriptorBase_impl.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,68 @@
+/*
+ * DescriptorBase_impl.hpp
+ *
+ *  Created on: Mar 12, 2010
+ *      Author: crueger
+ */
+
+#ifndef DESCRIPTORBASE_IMPL_HPP_
+#define DESCRIPTORBASE_IMPL_HPP_
+
+#include "Descriptors/DescriptorBase.hpp"
+#include <utility>
+#include <boost/bind.hpp>
+
+template<class _Target,
+         class _Container>
+class DescriptorBase_impl{
+public:
+  typedef _Target Target;
+  typedef std::vector<Target> TargetVec;
+  typedef _Container Container;
+  typedef typename Container::value_type value_type;
+  typedef typename Container::iterator iterator;
+
+  DescriptorBase_impl();
+  ~DescriptorBase_impl();
+
+  virtual bool predicate(value_type)=0;
+
+  virtual Target    find(Container&);
+  virtual TargetVec findAll(Container&);
+protected:
+  const _take<Target,value_type> take;
+};
+
+template<class _Target,
+         class _Container>
+DescriptorBase_impl<_Target,_Container>::DescriptorBase_impl(){}
+
+template<class _Target,
+         class _Container>
+DescriptorBase_impl<_Target,_Container>::~DescriptorBase_impl(){}
+
+template<class _Target,
+         class _Container>
+typename DescriptorBase_impl<_Target,_Container>::Target
+  DescriptorBase_impl<_Target,_Container>::find(DescriptorBase_impl<_Target,_Container>::Container& container){
+    iterator res = find_if(container.begin(),
+                           container.end(),
+                           boost::bind(&DescriptorBase_impl<_Target,_Container>::predicate,this,_1));
+    return (res!=container.end())?(take(*res)):0;
+  }
+
+template<class _Target,
+         class _Container>
+typename DescriptorBase_impl<_Target,_Container>::TargetVec
+  DescriptorBase_impl<_Target,_Container>::findAll(DescriptorBase_impl<_Target,_Container>::Container& container) {
+  TargetVec res;
+  iterator iter;
+  for(iter=container.begin();iter!=container.end();++iter) {
+    if(predicate(*iter)){
+      res.push_back(take(*iter));
+    }
+  }
+  return res;
+}
+
+#endif /* DESCRIPTORBASE_IMPL_HPP_ */
Index: src/Descriptors/MoleculeDescriptor.cpp
===================================================================
--- src/Descriptors/MoleculeDescriptor.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Descriptors/MoleculeDescriptor.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,175 @@
+/*
+ * MoleculeDescriptor.cpp
+ *
+ *  Created on: Feb 5, 2010
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Descriptors/MoleculeDescriptor.hpp"
+#include "Descriptors/MoleculeDescriptor_impl.hpp"
+
+#include "World.hpp"
+
+#include "molecule.hpp"
+
+#include <boost/bind.hpp>
+#include <iostream>
+
+using namespace std;
+
+typedef World::MoleculeSet::iterator molecules_iter_t;
+
+/************************ Forwarding object **************************************/
+
+
+MoleculeDescriptor::MoleculeDescriptor(impl_ptr _impl) :
+    impl(_impl)
+{}
+
+MoleculeDescriptor::MoleculeDescriptor(const MoleculeDescriptor& src) :
+    impl(src.get_impl())
+{}
+
+MoleculeDescriptor::~MoleculeDescriptor()
+{}
+
+MoleculeDescriptor& MoleculeDescriptor::operator=(MoleculeDescriptor &src){
+  if(&src!=this) {
+    impl=src.get_impl();
+  }
+  return *this;
+}
+
+molecule* MoleculeDescriptor::find(){
+  return impl->find();
+}
+
+std::vector<molecule*> MoleculeDescriptor::findAll(){
+  return impl->findAll();
+}
+
+MoleculeDescriptor::impl_ptr MoleculeDescriptor::get_impl() const{
+  return impl;
+}
+
+
+
+
+/**************************** implementation ********************/
+
+MoleculeDescriptor_impl::MoleculeDescriptor_impl()
+{
+}
+
+MoleculeDescriptor_impl::~MoleculeDescriptor_impl()
+{
+}
+
+World::MoleculeSet& MoleculeDescriptor_impl::getMolecules(){
+  return World::getInstance().molecules;
+}
+
+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;
+}
+
+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);
+    }
+  }
+  return res;
+}
+
+/************************** Universe and Emptyset *****************/
+
+MoleculeAllDescriptor_impl::MoleculeAllDescriptor_impl()
+{}
+
+MoleculeAllDescriptor_impl::~MoleculeAllDescriptor_impl()
+{}
+
+bool MoleculeAllDescriptor_impl::predicate(std::pair<moleculeId_t,molecule*>){
+  return true;
+}
+
+MoleculeDescriptor AllMolecules(){
+  return MoleculeDescriptor(MoleculeDescriptor::impl_ptr(new MoleculeAllDescriptor_impl));
+}
+
+MoleculeNoneDescriptor_impl::MoleculeNoneDescriptor_impl()
+{}
+
+MoleculeNoneDescriptor_impl::~MoleculeNoneDescriptor_impl()
+{}
+
+bool MoleculeNoneDescriptor_impl::predicate(std::pair<moleculeId_t,molecule*>){
+  return false;
+}
+
+MoleculeDescriptor NoMolecules(){
+  return MoleculeDescriptor(MoleculeDescriptor::impl_ptr(new MoleculeNoneDescriptor_impl));
+}
+
+/************************** Operator stuff ************************/
+
+// AND
+MoleculeAndDescriptor_impl::MoleculeAndDescriptor_impl(MoleculeDescriptor::impl_ptr _lhs, MoleculeDescriptor::impl_ptr _rhs) :
+    lhs(_lhs), rhs(_rhs)
+{}
+
+MoleculeAndDescriptor_impl::~MoleculeAndDescriptor_impl()
+{}
+
+bool MoleculeAndDescriptor_impl::predicate(std::pair<moleculeId_t,molecule*> molecule){
+  return lhs->predicate(molecule) && rhs->predicate(molecule);
+}
+MoleculeDescriptor operator&&(const MoleculeDescriptor &lhs, const MoleculeDescriptor &rhs){
+  MoleculeDescriptor::impl_ptr newImpl = MoleculeDescriptor::impl_ptr(new MoleculeAndDescriptor_impl(lhs.get_impl(),rhs.get_impl()));
+  return MoleculeDescriptor(newImpl);
+}
+
+// OR
+MoleculeOrDescriptor_impl::MoleculeOrDescriptor_impl(MoleculeDescriptor::impl_ptr _lhs ,MoleculeDescriptor::impl_ptr _rhs) :
+    lhs(_lhs), rhs(_rhs)
+{}
+
+MoleculeOrDescriptor_impl::~MoleculeOrDescriptor_impl(){
+}
+
+bool MoleculeOrDescriptor_impl::predicate(std::pair<moleculeId_t,molecule*> molecule){
+  return lhs->predicate(molecule) || rhs->predicate(molecule);
+}
+
+MoleculeDescriptor  operator||(const MoleculeDescriptor &lhs, const MoleculeDescriptor &rhs){
+  MoleculeDescriptor::impl_ptr newImpl = MoleculeDescriptor::impl_ptr(new MoleculeOrDescriptor_impl(lhs.get_impl(),rhs.get_impl()));
+  return MoleculeDescriptor(newImpl);
+}
+
+// NOT
+
+MoleculeNotDescriptor_impl::MoleculeNotDescriptor_impl(MoleculeDescriptor::impl_ptr _arg) :
+    arg(_arg)
+{}
+
+
+MoleculeNotDescriptor_impl::~MoleculeNotDescriptor_impl()
+{
+}
+
+bool MoleculeNotDescriptor_impl::predicate(std::pair<moleculeId_t,molecule*> molecule){
+ return !(arg->predicate(molecule));
+}
+
+MoleculeDescriptor operator!(const MoleculeDescriptor &arg){
+  MoleculeDescriptor::impl_ptr newImpl = MoleculeDescriptor::impl_ptr(new MoleculeNotDescriptor_impl(arg.get_impl()));
+  return MoleculeDescriptor(newImpl);
+}
Index: src/Descriptors/MoleculeDescriptor.hpp
===================================================================
--- src/Descriptors/MoleculeDescriptor.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Descriptors/MoleculeDescriptor.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,115 @@
+/*
+ * MoleculeDescriptor.hpp
+ *
+ *  Created on: Feb 5, 2010
+ *      Author: crueger
+ */
+
+#ifndef MOLECULEDESCRIPTOR_HPP_
+#define MOLECULEDESCRIPTOR_HPP_
+
+
+#include <vector>
+#include <map>
+#include <boost/shared_ptr.hpp>
+#include "World.hpp"
+
+class World;
+class molecule;
+
+// internal implementation, allows assignment, copying etc
+class MoleculeDescriptor_impl;
+
+/**
+ * An MoleculeDescriptor describes a Set of Molecules from the World. Can be used for any method that needs to work on
+ * a specific set of Molecules.
+ *
+ * This Class is implemented using the PIMPL-Idion, i.e. this class only contains an abstract structure
+ * that forwards any request to a wrapped pointer-to-implementation. This way operators and calculations
+ * on Descriptors are possible.
+ *
+ * Concrete Implementation Objects can be shared between multiple Wrappers, so make sure that
+ * any Implementation remainst constant during lifetime.
+ */
+class MoleculeDescriptor {
+  // close coupling to the world to allow access
+  friend molecule* World::getMolecule(MoleculeDescriptor descriptor);
+  friend std::vector<molecule*> World::getAllMolecules(MoleculeDescriptor descriptor);
+  template <class,class,class> friend class SelectiveIterator;
+
+  friend MoleculeDescriptor operator&&(const MoleculeDescriptor &lhs, const MoleculeDescriptor &rhs);
+  friend MoleculeDescriptor operator||(const MoleculeDescriptor &lhs, const MoleculeDescriptor &rhs);
+  friend MoleculeDescriptor operator!(const MoleculeDescriptor &arg);
+
+public:
+  typedef MoleculeDescriptor_impl impl_t;
+  typedef boost::shared_ptr<impl_t> impl_ptr; //!< Allow easy changes of the pointer-to-implementation type
+
+  MoleculeDescriptor(impl_ptr);
+
+  /**
+   * Copy constructor.
+   * Takes the Implementation from the copied object and sets it's own pointer to link there.
+   * This way the actuall implementation object is shared between copy and original
+   */
+  MoleculeDescriptor(const MoleculeDescriptor&);
+  ~MoleculeDescriptor();
+
+  /**
+   * Assignment Operator.
+   *
+   * Implemented by setting the pointer to the new Implementation.
+   */
+  MoleculeDescriptor &operator=(MoleculeDescriptor &);
+
+protected:
+  /**
+   * forward Method to implementation
+   */
+  molecule* find();
+
+  /**
+   * forward Method to implementation
+   */
+  std::vector<molecule*> findAll();
+
+  /**
+   * Return the implementation this Wrapper currently points to.
+   * Used for copying, assignment and in Iterators over subsets of the World.
+   */
+  impl_ptr get_impl() const;
+
+private:
+  impl_ptr impl;
+};
+
+/**
+ * produce an Moleculedescriptor that at the point of construction contains an implementation that matches all Molecules
+ */
+MoleculeDescriptor AllMolecules();
+
+/**
+ * produce an Moleculedescriptor that at the point of construction contains an implementation that matches no Molecules
+ */
+MoleculeDescriptor NoMolecules();
+
+/**
+ * Set Intersection for two Moleculedescriptors. The resulting Moleculedescriptor will only match an Molecule if both
+ * given Moleculedescriptors also match. Uses short circuit inside, so the second predicate wont be called
+ * when the first one failed.
+ */
+MoleculeDescriptor operator&&(const MoleculeDescriptor &lhs, const MoleculeDescriptor &rhs);
+
+/**
+ * Set Union for two MoleculeDescriptors. The resulting MoleculeDescriptor will match an Molecule if at least one of
+ * the two given MoleculeDescriptors does match. Used short circuit inside, so the second predicate wont
+ * be called when the first one failed.
+ */
+MoleculeDescriptor operator||(const MoleculeDescriptor &lhs, const MoleculeDescriptor &rhs);
+
+/**
+ * Set inversion for an MoleculeDescriptor. Matches an Molecule if the given MoleculeDescriptor did not match.
+ */
+MoleculeDescriptor operator!(const MoleculeDescriptor &arg);
+
+#endif /* MOLECULEDESCRIPTOR_HPP_ */
Index: src/Descriptors/MoleculeDescriptor_impl.hpp
===================================================================
--- src/Descriptors/MoleculeDescriptor_impl.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Descriptors/MoleculeDescriptor_impl.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,145 @@
+#ifndef MOLECULEDESCRIPTOR_IMPL_HPP
+#define MOLECULEDESCRIPTOR_IMPL_HPP
+
+#include "Descriptors/MoleculeDescriptor.hpp"
+
+/************************ Declarations of implementation Objects ************************/
+
+/**
+ * This class implements a general Base class for MoleculeDescriptors using the PIMPL-Idiom
+ *
+ * The predicate for this class is empty and should be implemented by derived classes.
+ * By the predicate it is described which molecules should be picked for a given descriptor.
+ */
+
+class MoleculeDescriptor_impl
+{
+  friend class MoleculeDescriptor;
+public:
+
+  MoleculeDescriptor_impl();
+  virtual ~MoleculeDescriptor_impl();
+
+  /**
+   * Implement this abstract Method to make a concrete MoleculeDescriptor pick certain Molecules
+   */
+  virtual bool predicate(std::pair<moleculeId_t,molecule*>)=0;
+
+protected:
+
+  /**
+   * This method is called when the Descriptor is used to find the first matching
+   * Molecule. Walks through all Molecules and stops on the first match. Can be implemented
+   * when the searched Molecule can be found in a more efficient way. Calculated
+   * Moleculedescriptors will always use this method, so no improvement there.
+   */
+  virtual molecule* find();
+
+  /**
+   * This method is called when the Descriptor is used to find all matching Molecules.
+   * Walks through all Molecules and tests the predicate on each one. A vector of all
+   * matching Molecules is returned.
+   */
+  virtual std::vector<molecule*> findAll();
+
+  /**
+   * This method is used internally to query the Set of Molecules from the world.
+   * By using this method derived classes can also access the Internal World Datastructre.
+   * Implemented in full in the Base Descriptor Implementation, so only this one method
+   * needs to be friend with the World class.
+   */
+  World::MoleculeSet& getMolecules();
+};
+
+/************************** Universe and Emptyset *****************/
+
+/**
+ * A simple MoleculeDescriptor that will always match all Molecules present in the World.
+ */
+class MoleculeAllDescriptor_impl : public MoleculeDescriptor_impl {
+public:
+  MoleculeAllDescriptor_impl();
+  virtual ~MoleculeAllDescriptor_impl();
+
+  /**
+   * Always returns true for any Molecule
+   */
+  virtual bool predicate(std::pair<moleculeId_t,molecule*>);
+};
+
+
+/**
+ * An MoleculeDescriptor that never matches any Molecule in the World.
+ */
+class MoleculeNoneDescriptor_impl : public MoleculeDescriptor_impl {
+public:
+  MoleculeNoneDescriptor_impl();
+  virtual ~MoleculeNoneDescriptor_impl();
+
+  /**
+   * Always returns false for any Molecule
+   */
+  virtual bool predicate(std::pair<moleculeId_t,molecule*>);
+};
+
+/************************** Operator stuff ************************/
+
+/**
+ * Intersection of two MoleculeDescriptors
+ */
+class MoleculeAndDescriptor_impl : public MoleculeDescriptor_impl
+{
+public:
+  MoleculeAndDescriptor_impl(MoleculeDescriptor::impl_ptr _lhs, MoleculeDescriptor::impl_ptr _rhs);
+  ~MoleculeAndDescriptor_impl();
+
+  /**
+   * This predicate uses the predicate from the first && the predicate from the
+   * second Descriptor to decide if an Molecule should be selected.
+   */
+  virtual bool predicate(std::pair<moleculeId_t,molecule*>);
+
+private:
+  MoleculeDescriptor::impl_ptr lhs;
+  MoleculeDescriptor::impl_ptr rhs;
+};
+
+/**
+ * Union of two MoleculeDescriptors
+ */
+class MoleculeOrDescriptor_impl : public MoleculeDescriptor_impl
+{
+public:
+  MoleculeOrDescriptor_impl(MoleculeDescriptor::impl_ptr _lhs, MoleculeDescriptor::impl_ptr _rhs);
+  virtual ~MoleculeOrDescriptor_impl();
+
+  /**
+   * This predicate uses the predicate form the first || the predicate from the
+   * second Descriptor to decide if an Molecule should be selected.
+   */
+  virtual bool predicate(std::pair<moleculeId_t,molecule*>);
+
+private:
+  MoleculeDescriptor::impl_ptr lhs;
+  MoleculeDescriptor::impl_ptr rhs;
+};
+
+/**
+ * Set Inversion of a Descriptor
+ */
+class MoleculeNotDescriptor_impl : public MoleculeDescriptor_impl
+{
+public:
+  MoleculeNotDescriptor_impl(MoleculeDescriptor::impl_ptr _arg);
+  virtual ~MoleculeNotDescriptor_impl();
+
+  /**
+   * Opposite of the given descriptor predicate.
+   */
+  virtual bool predicate(std::pair<moleculeId_t,molecule*>);
+
+private:
+  MoleculeDescriptor::impl_ptr arg;
+};
+
+#endif //MOLECULEDESCRIPTOR_IMPL_HPP
Index: src/Descriptors/MoleculeIdDescriptor.cpp
===================================================================
--- src/Descriptors/MoleculeIdDescriptor.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Descriptors/MoleculeIdDescriptor.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+/*
+ * MoleculeIdDescriptor.cpp
+ *
+ *  Created on: Feb 5, 2010
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "MoleculeIdDescriptor.hpp"
+#include "MoleculeIdDescriptor_impl.hpp"
+
+#include "molecule.hpp"
+
+using namespace std;
+
+
+MoleculeIdDescriptor_impl::MoleculeIdDescriptor_impl(moleculeId_t _id) :
+  id(_id)
+{}
+
+MoleculeIdDescriptor_impl::~MoleculeIdDescriptor_impl()
+{}
+
+bool MoleculeIdDescriptor_impl::predicate(std::pair<moleculeId_t,molecule*> molecule) {
+  return molecule.first==id;
+}
+
+MoleculeDescriptor MoleculeById(moleculeId_t id){
+  return MoleculeDescriptor(MoleculeDescriptor::impl_ptr(new MoleculeIdDescriptor_impl(id)));
+}
+
+molecule *MoleculeIdDescriptor_impl::find(){
+  World::MoleculeSet molecules = getMolecules();
+  World::MoleculeSet::iterator res = molecules.find(id);
+  return (res!=molecules.end())?((*res).second):0;
+}
+
+vector<molecule*> MoleculeIdDescriptor_impl::findAll(){
+  molecule *res = find();
+  return (res)?(vector<molecule*>(1,res)):(vector<molecule*>());
+}
Index: src/Descriptors/MoleculeIdDescriptor.hpp
===================================================================
--- src/Descriptors/MoleculeIdDescriptor.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Descriptors/MoleculeIdDescriptor.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,16 @@
+/*
+ * MoleculeIdDescriptor.hpp
+ *
+ *  Created on: Feb 5, 2010
+ *      Author: crueger
+ */
+
+#ifndef MOLECULEIDDESCRIPTOR_HPP_
+#define MOLECULEIDDESCRIPTOR_HPP_
+
+#include "defs.hpp"
+#include "Descriptors/MoleculeDescriptor.hpp"
+
+MoleculeDescriptor MoleculeById(moleculeId_t id);
+
+#endif /* MOLECULEIDDESCRIPTOR_HPP_ */
Index: src/Descriptors/MoleculeIdDescriptor_impl.hpp
===================================================================
--- src/Descriptors/MoleculeIdDescriptor_impl.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Descriptors/MoleculeIdDescriptor_impl.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,21 @@
+#ifndef MOLECULEIDDESCRIPTOR_IMPL_HPP
+#define MOLECULEIDDESCRIPTOR_IMPL_HPP
+
+#include "Descriptors/MoleculeDescriptor_impl.hpp"
+
+class MoleculeIdDescriptor_impl : public MoleculeDescriptor_impl
+{
+public:
+  MoleculeIdDescriptor_impl(moleculeId_t _id);
+  virtual ~MoleculeIdDescriptor_impl();
+
+  bool predicate(std::pair<moleculeId_t,molecule*> molecule);
+
+protected:
+  virtual molecule *find();
+  virtual std::vector<molecule*> findAll();
+private:
+  moleculeId_t id;
+};
+
+#endif //MOLECULEIDDESCRIPTOR_IMPL_HPP
Index: src/Descriptors/MoleculeNameDescriptor.cpp
===================================================================
--- src/Descriptors/MoleculeNameDescriptor.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Descriptors/MoleculeNameDescriptor.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,43 @@
+/*
+ * MoleculeNameDescriptor.cpp
+ *
+ *  Created on: Jun 9, 2010
+ *      Author: heber
+ */
+
+#include "MoleculeNameDescriptor.hpp"
+#include "MoleculeNameDescriptor_impl.hpp"
+
+#include "molecule.hpp"
+
+using namespace std;
+
+
+MoleculeNameDescriptor_impl::MoleculeNameDescriptor_impl(std::string _name) :
+  name(_name)
+{}
+
+MoleculeNameDescriptor_impl::~MoleculeNameDescriptor_impl()
+{}
+
+bool MoleculeNameDescriptor_impl::predicate(std::pair<moleculeId_t,molecule*> molecule) {
+  return molecule.second->name==name;
+}
+
+MoleculeDescriptor MoleculeByName(std::string name){
+  return MoleculeDescriptor(MoleculeDescriptor::impl_ptr(new MoleculeNameDescriptor_impl(name)));
+}
+
+molecule *MoleculeNameDescriptor_impl::find(){
+  World::MoleculeSet molecules = getMolecules();
+  World::MoleculeSet::iterator res = molecules.begin();
+  for (; res != molecules.end(); res++)
+    if (res->second->name == name)
+      break;
+  return (res!=molecules.end())?((*res).second):0;
+}
+
+vector<molecule*> MoleculeNameDescriptor_impl::findAll(){
+  molecule *res = find();
+  return (res)?(vector<molecule*>(1,res)):(vector<molecule*>());
+}
Index: src/Descriptors/MoleculeNameDescriptor.hpp
===================================================================
--- src/Descriptors/MoleculeNameDescriptor.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Descriptors/MoleculeNameDescriptor.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,16 @@
+/*
+ * MoleculeNameDescriptor.hpp
+ *
+ *  Created on: Jun 9, 2010
+ *      Author: heber
+ */
+
+#ifndef MOLECULENAMEDESCRIPTOR_HPP_
+#define MOLECULENAMEDESCRIPTOR_HPP_
+
+#include "defs.hpp"
+#include "Descriptors/MoleculeDescriptor.hpp"
+
+MoleculeDescriptor MoleculeByName(std::string name);
+
+#endif /* MOLECULENAMEDESCRIPTOR_HPP_ */
Index: src/Descriptors/MoleculeNameDescriptor_impl.hpp
===================================================================
--- src/Descriptors/MoleculeNameDescriptor_impl.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Descriptors/MoleculeNameDescriptor_impl.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,21 @@
+#ifndef MOLECULENAMEDESCRIPTOR_IMPL_HPP
+#define MOLECULENAMEDESCRIPTOR_IMPL_HPP
+
+#include "Descriptors/MoleculeDescriptor_impl.hpp"
+
+class MoleculeNameDescriptor_impl : public MoleculeDescriptor_impl
+{
+public:
+  MoleculeNameDescriptor_impl(std::string _name);
+  virtual ~MoleculeNameDescriptor_impl();
+
+  bool predicate(std::pair<moleculeId_t,molecule*> molecule);
+
+protected:
+  virtual molecule *find();
+  virtual std::vector<molecule*> findAll();
+private:
+  std::string name;
+};
+
+#endif //MOLECULENAMEDESCRIPTOR_IMPL_HPP
Index: src/Descriptors/MoleculePtrDescriptor.cpp
===================================================================
--- src/Descriptors/MoleculePtrDescriptor.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Descriptors/MoleculePtrDescriptor.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+/*
+ * MoleculePtrDescriptor.cpp
+ *
+ *  Created on: Feb 5, 2010
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "MoleculePtrDescriptor.hpp"
+#include "MoleculePtrDescriptor_impl.hpp"
+
+#include "molecule.hpp"
+
+using namespace std;
+
+
+MoleculePtrDescriptor_impl::MoleculePtrDescriptor_impl(molecule * _ptr) :
+  ptr(_ptr)
+{}
+
+MoleculePtrDescriptor_impl::~MoleculePtrDescriptor_impl()
+{}
+
+bool MoleculePtrDescriptor_impl::predicate(std::pair<moleculeId_t,molecule*> molecule) {
+  return molecule.second==ptr;
+}
+
+MoleculeDescriptor MoleculeByPtr(molecule * ptr){
+  return MoleculeDescriptor(MoleculeDescriptor::impl_ptr(new MoleculePtrDescriptor_impl(ptr)));
+}
+
+molecule *MoleculePtrDescriptor_impl::find(){
+  World::MoleculeSet molecules = getMolecules();
+  World::MoleculeSet::iterator res = molecules.find(ptr->getId());
+  return (res!=molecules.end())?((*res).second):0;
+}
+
+vector<molecule*> MoleculePtrDescriptor_impl::findAll(){
+  molecule *res = find();
+  return (res)?(vector<molecule*>(1,res)):(vector<molecule*>());
+}
Index: src/Descriptors/MoleculePtrDescriptor.hpp
===================================================================
--- src/Descriptors/MoleculePtrDescriptor.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Descriptors/MoleculePtrDescriptor.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,16 @@
+/*
+ * MoleculeIdDescriptor.hpp
+ *
+ *  Created on: Feb 5, 2010
+ *      Author: crueger
+ */
+
+#ifndef MOLECULEPTRDESCRIPTOR_HPP_
+#define MOLECULEPTRDESCRIPTOR_HPP_
+
+#include "defs.hpp"
+#include "Descriptors/MoleculeDescriptor.hpp"
+
+MoleculeDescriptor MoleculeByPtr(molecule * ptr);
+
+#endif /* MOLECULEPTRDESCRIPTOR_HPP_ */
Index: src/Descriptors/MoleculePtrDescriptor_impl.hpp
===================================================================
--- src/Descriptors/MoleculePtrDescriptor_impl.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Descriptors/MoleculePtrDescriptor_impl.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,23 @@
+#ifndef MOLECULEPTRDESCRIPTOR_IMPL_HPP
+#define MOLECULEPTRDESCRIPTOR_IMPL_HPP
+
+#include "Descriptors/MoleculeDescriptor_impl.hpp"
+
+class molecule;
+
+class MoleculePtrDescriptor_impl : public MoleculeDescriptor_impl
+{
+public:
+  MoleculePtrDescriptor_impl(molecule * ptr);
+  virtual ~MoleculePtrDescriptor_impl();
+
+  bool predicate(std::pair<moleculeId_t,molecule*> molecule);
+
+protected:
+  virtual molecule *find();
+  virtual std::vector<molecule*> findAll();
+private:
+  molecule * ptr;
+};
+
+#endif //MOLECULEPTRDESCRIPTOR_IMPL_HPP
Index: src/Descriptors/SelectiveIterator.hpp
===================================================================
--- src/Descriptors/SelectiveIterator.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Descriptors/SelectiveIterator.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,52 @@
+/*
+ * SelectiveIterator.hpp
+ *
+ *  Created on: Mar 17, 2010
+ *      Author: crueger
+ */
+
+#ifndef SELECTIVEITERATOR_HPP_
+#define SELECTIVEITERATOR_HPP_
+
+#include <iterator>
+
+template<class _Target,
+         class _Container,
+         class _Descriptor>
+class SelectiveIterator :
+  public std::iterator<typename std::iterator_traits<typename _Container::iterator>::difference_type,
+                       typename std::iterator_traits<typename _Container::iterator>::value_type,
+                       typename std::iterator_traits<typename _Container::iterator>::pointer,
+                       typename std::iterator_traits<typename _Container::iterator>::reference>
+{
+public:
+  typedef typename _Container::iterator     Iter;
+  typedef          _Target                  Target;
+  typedef typename Iter::value_type         value_type;
+  typedef typename Iter::difference_type    difference_type;
+  typedef typename Iter::pointer            pointer;
+  typedef typename Iter::reference          reference;
+  typedef typename Iter::iterator_category  iterator_category;
+
+
+  SelectiveIterator(_Descriptor, _Container&);
+  SelectiveIterator(_Descriptor, _Container&, Iter);
+  SelectiveIterator(const SelectiveIterator&);
+  SelectiveIterator& operator=(const SelectiveIterator&);
+  SelectiveIterator& operator++();     // prefix
+  SelectiveIterator  operator++(int);  // postfix with dummy parameter
+  bool operator==(const SelectiveIterator&);
+  bool operator!=(const SelectiveIterator&);
+  Target operator*();
+
+  int getCount();
+protected:
+  void advanceState();
+  Iter state;
+  typename _Descriptor::impl_ptr descr;
+  int index;
+
+  _Container &content;
+};
+
+#endif /* SELECTIVEITERATOR_HPP_ */
Index: src/Descriptors/SelectiveIterator_impl.hpp
===================================================================
--- src/Descriptors/SelectiveIterator_impl.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Descriptors/SelectiveIterator_impl.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,137 @@
+/*
+ * SelectiveIterator_impl.hpp
+ *
+ *  Created on: Mar 17, 2010
+ *      Author: crueger
+ */
+
+#ifndef SELECTIVEITERATOR_IMPL_HPP_
+#define SELECTIVEITERATOR_IMPL_HPP_
+
+#include "helpers.hpp"
+
+template<class _Target,
+         class _Container,
+         class _Descriptor>
+SelectiveIterator<_Target,_Container,_Descriptor>::SelectiveIterator(_Descriptor _descr, _Container &_content) :
+    descr(_descr.get_impl()),
+    index(0),
+    content(_content)
+{
+  state = content.begin();
+  advanceState();
+}
+
+template<class _Target,
+         class _Container,
+         class _Descriptor>
+SelectiveIterator<_Target,_Container,_Descriptor>::SelectiveIterator(_Descriptor _descr, _Container &_content, SelectiveIterator<_Target,_Container,_Descriptor>::Iter _state) :
+    state(_state),
+    descr(_descr.get_impl()),
+    index(0),
+    content(_content)
+{
+  advanceState();
+}
+
+template<class _Target,
+         class _Container,
+         class _Descriptor>
+SelectiveIterator<_Target,_Container,_Descriptor>::SelectiveIterator(const SelectiveIterator<_Target,_Container,_Descriptor>& rhs) :
+    state(rhs.state),
+    descr(rhs.descr),
+    index(rhs.index),
+    content(rhs.content)
+  {}
+
+template<class _Target,
+         class _Container,
+         class _Descriptor>
+SelectiveIterator<_Target,_Container,_Descriptor>& SelectiveIterator<_Target,_Container,_Descriptor>::operator=(const SelectiveIterator<_Target,_Container,_Descriptor>& rhs)
+{
+  if(&rhs!=this){
+    state=rhs.state;
+    descr=rhs.descr;
+    index=rhs.index;
+  }
+  return *this;
+}
+
+template<class _Target,
+         class _Container,
+         class _Descriptor>
+SelectiveIterator<_Target,_Container,_Descriptor>&
+  SelectiveIterator<_Target,_Container,_Descriptor>::operator++(){
+    ++state;
+    ++index;
+    advanceState();
+    return *this;
+  }
+
+template<class _Target,
+         class _Container,
+         class _Descriptor>
+SelectiveIterator<_Target,_Container,_Descriptor> SelectiveIterator<_Target,_Container,_Descriptor>::operator++(int){
+    SelectiveIterator<_Target,_Container,_Descriptor> res = SelectiveIterator<_Target,_Container,_Descriptor>(*this);
+    ++(*this);
+    return res;
+  }
+
+template<class _Target,
+         class _Container,
+         class _Descriptor>
+bool
+  SelectiveIterator<_Target,_Container,_Descriptor>::operator==(const SelectiveIterator<_Target,_Container,_Descriptor>& rhs){
+    return state==rhs.state;
+  }
+
+template<class _Target,
+         class _Container,
+         class _Descriptor>
+bool
+  SelectiveIterator<_Target,_Container,_Descriptor>::operator!=(const SelectiveIterator<_Target,_Container,_Descriptor>& rhs){
+    return state!=rhs.state;
+  }
+
+template<class _Target,
+         class _Container,
+         class _Descriptor>
+typename SelectiveIterator<_Target,_Container,_Descriptor>::Target
+  SelectiveIterator<_Target,_Container,_Descriptor>::operator*(){
+    return _take<_Target,value_type>::get(*state);
+  }
+
+template<class _Target,
+         class _Container,
+         class _Descriptor>
+void
+  SelectiveIterator<_Target,_Container,_Descriptor>::advanceState(){
+    // go forward until we have a matching atom or the end is reached
+    while((state!=content.end()) && (!descr->predicate(*state))){
+      ++state;
+      ++index;
+    }
+  }
+
+template<class _Target,
+         class _Container,
+         class _Descriptor>
+int
+  SelectiveIterator<_Target,_Container,_Descriptor>::getCount(){
+    return index;
+  }
+
+
+#define CONSTRUCT_SELECTIVE_ITERATOR(_Target,_Container,_Descriptor) \
+		template SelectiveIterator<_Target,_Container,_Descriptor>::SelectiveIterator(_Descriptor, _Container&); \
+		template SelectiveIterator<_Target,_Container,_Descriptor>::SelectiveIterator(_Descriptor, _Container&, SelectiveIterator<_Target,_Container,_Descriptor>::Iter); \
+    template SelectiveIterator<_Target,_Container,_Descriptor>::SelectiveIterator(const SelectiveIterator<_Target,_Container,_Descriptor>&); \
+    template SelectiveIterator<_Target,_Container,_Descriptor>& SelectiveIterator<_Target,_Container,_Descriptor>::operator=(const SelectiveIterator<_Target,_Container,_Descriptor>&); \
+    template SelectiveIterator<_Target,_Container,_Descriptor>& SelectiveIterator<_Target,_Container,_Descriptor>::operator++(); \
+    template SelectiveIterator<_Target,_Container,_Descriptor> SelectiveIterator<_Target,_Container,_Descriptor>::operator++(int); \
+    template bool SelectiveIterator<_Target,_Container,_Descriptor>::operator==(const SelectiveIterator<_Target,_Container,_Descriptor>&); \
+    template bool SelectiveIterator<_Target,_Container,_Descriptor>::operator!=(const SelectiveIterator<_Target,_Container,_Descriptor>&); \
+    template SelectiveIterator<_Target,_Container,_Descriptor>::Target SelectiveIterator<_Target,_Container,_Descriptor>::operator*(); \
+    template int SelectiveIterator<_Target,_Container,_Descriptor>::getCount();
+
+#endif /* SELECTIVEITERATOR_IMPL_HPP_ */
Index: src/Exceptions/CustomException.cpp
===================================================================
--- src/Exceptions/CustomException.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Exceptions/CustomException.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,27 @@
+/*
+ * CustomException.cpp
+ *
+ *  Created on: Apr 7, 2010
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "CustomException.hpp"
+
+using namespace std;
+
+CustomException::CustomException(std::string _file, int _line):
+ file(_file),
+ line(_line)
+{}
+
+CustomException::~CustomException() throw ()
+{}
+
+
+ostream& operator<<(ostream &ost,CustomException &excp){
+  // we use this to let others know from where the exception was thrown
+  ost << excp.what() << "\nIn " << excp.file << ":" << excp.line;
+  return ost;
+}
Index: src/Exceptions/CustomException.hpp
===================================================================
--- src/Exceptions/CustomException.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Exceptions/CustomException.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,32 @@
+/*
+ * CustomException.hpp
+ *
+ *  Created on: Apr 7, 2010
+ *      Author: crueger
+ */
+
+#ifndef CUSTOMEXCEPTION_HPP_
+#define CUSTOMEXCEPTION_HPP_
+
+#include <exception>
+#include <iostream>
+
+/**
+ * Custom Exceptions are simply a bit more verbose versions of the
+ * std::exceptions.
+ */
+class CustomException : public std::exception
+{
+  friend std::ostream& operator<<(std::ostream &ost, CustomException &excp);
+public:
+  CustomException(std::string file, int line);
+  virtual ~CustomException() throw();
+
+private:
+  std::string file;
+  int line;
+};
+
+std::ostream& operator<<(std::ostream &ost, CustomException &excp);
+
+#endif /* CUSTOMEXCEPTION_HPP_ */
Index: src/Exceptions/LinearDependenceException.cpp
===================================================================
--- src/Exceptions/LinearDependenceException.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Exceptions/LinearDependenceException.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,24 @@
+/*
+ * LinearDependenceException.cpp
+ *
+ *  Created on: Apr 7, 2010
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "LinearDependenceException.hpp"
+
+using namespace std;
+
+LinearDependenceException::LinearDependenceException(string _file, int _line) :
+  MathException(_file,_line)
+{}
+
+LinearDependenceException::~LinearDependenceException() throw ()
+{}
+
+const char* LinearDependenceException::what() const throw()
+{
+  return "Given vectors are linear dependent.";
+}
Index: src/Exceptions/LinearDependenceException.hpp
===================================================================
--- src/Exceptions/LinearDependenceException.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Exceptions/LinearDependenceException.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,22 @@
+/*
+ * LinearDependenceException.hpp
+ *
+ *  Created on: Apr 7, 2010
+ *      Author: crueger
+ */
+
+#ifndef LINEARDEPENDENCEEXCEPTION_HPP_
+#define LINEARDEPENDENCEEXCEPTION_HPP_
+
+#include "Exceptions/MathException.hpp"
+
+class LinearDependenceException : public MathException
+{
+public:
+  LinearDependenceException(std::string _file, int _line);
+  virtual ~LinearDependenceException() throw ();
+
+  virtual const char* what() const throw();
+};
+
+#endif /* LINEARDEPENDENCEEXCEPTION_HPP_ */
Index: src/Exceptions/MathException.cpp
===================================================================
--- src/Exceptions/MathException.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Exceptions/MathException.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,17 @@
+/*
+ * MathException.cpp
+ *
+ *  Created on: Apr 30, 2010
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "MathException.hpp"
+
+MathException::MathException(std::string file, int line) :
+  CustomException(file,line)
+{}
+
+MathException::~MathException() throw ()
+{}
Index: src/Exceptions/MathException.hpp
===================================================================
--- src/Exceptions/MathException.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Exceptions/MathException.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,20 @@
+/*
+ * MathException.hpp
+ *
+ *  Created on: Apr 30, 2010
+ *      Author: crueger
+ */
+
+#ifndef MATHEXCEPTION_HPP_
+#define MATHEXCEPTION_HPP_
+
+#include "Exceptions/CustomException.hpp"
+
+class MathException : public CustomException
+{
+public:
+  MathException(std::string file, int line);
+  virtual ~MathException() throw();
+};
+
+#endif /* MATHEXCEPTION_HPP_ */
Index: src/Exceptions/MultipleSolutionsException.hpp
===================================================================
--- src/Exceptions/MultipleSolutionsException.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Exceptions/MultipleSolutionsException.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,38 @@
+/*
+ * InfiniteSolutionsException.hpp
+ *
+ *  Created on: May 28, 2010
+ *      Author: crueger
+ */
+
+#ifndef INFINITESOLUTIONSEXCEPTION_HPP_
+#define INFINITESOLUTIONSEXCEPTION_HPP_
+
+template<class T>
+class MultipleSolutionsException : public MathException
+{
+public:
+  MultipleSolutionsException(std::string _file, int _line, const T& _solution) :
+    MathException(_file,_line),
+    solution(_solution)
+  {}
+
+  virtual ~MultipleSolutionsException() throw(){}
+
+  virtual const char* what() const throw(){
+    return "Multiple solutions possible....";
+  }
+
+  /**
+   * use this method in case you don't care that there is more than one
+   * solution and just any solution is fine
+   */
+  virtual T getAnySolution(){
+    return solution;
+  }
+
+private:
+  T solution;
+};
+
+#endif /* MULTIPLESOLUTIONSEXCEPTION_HPP_ */
Index: src/Exceptions/SkewException.cpp
===================================================================
--- src/Exceptions/SkewException.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Exceptions/SkewException.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,24 @@
+/*
+ * SkewException.cpp
+ *
+ *  Created on: May 27, 2010
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "SkewException.hpp"
+
+using namespace std;
+
+SkewException::SkewException(string _file, int _line) :
+  MathException(_file,_line)
+{}
+
+SkewException::~SkewException() throw()
+{}
+
+const char* SkewException::what() const throw()
+{
+  return "Given lines were askew.";
+}
Index: src/Exceptions/SkewException.hpp
===================================================================
--- src/Exceptions/SkewException.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Exceptions/SkewException.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,22 @@
+/*
+ * SkewException.hpp
+ *
+ *  Created on: May 27, 2010
+ *      Author: crueger
+ */
+
+#ifndef SKEWEXCEPTION_HPP_
+#define SKEWEXCEPTION_HPP_
+
+#include "Exceptions/MathException.hpp"
+
+class SkewException : public MathException
+{
+public:
+  SkewException(std::string _file, int _line);
+  virtual ~SkewException() throw ();
+
+  virtual const char* what() const throw();
+};
+
+#endif /* SKEWEXCEPTION_HPP_ */
Index: src/Exceptions/ZeroVectorException.cpp
===================================================================
--- src/Exceptions/ZeroVectorException.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Exceptions/ZeroVectorException.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,22 @@
+/*
+ * ZeroVectorException.cpp
+ *
+ *  Created on: Apr 30, 2010
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "ZeroVectorException.hpp"
+
+ZeroVectorException::ZeroVectorException(std::string file, int line) :
+  MathException(file,line)
+{}
+
+ZeroVectorException::~ZeroVectorException() throw ()
+{}
+
+const char* ZeroVectorException::what() const throw()
+{
+  return "Given vector was a zero Vector.";
+}
Index: src/Exceptions/ZeroVectorException.hpp
===================================================================
--- src/Exceptions/ZeroVectorException.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Exceptions/ZeroVectorException.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,22 @@
+/*
+ * ZeroVectorException.hpp
+ *
+ *  Created on: Apr 30, 2010
+ *      Author: crueger
+ */
+
+#ifndef ZEROVECTOREXCEPTION_HPP_
+#define ZEROVECTOREXCEPTION_HPP_
+
+#include "Exceptions/MathException.hpp"
+
+class ZeroVectorException : public MathException
+{
+public:
+  ZeroVectorException(std::string file, int line);
+  virtual ~ZeroVectorException() throw();
+
+  virtual const char* what() const throw();
+};
+
+#endif /* ZEROVECTOREXCEPTION_HPP_ */
Index: src/Hbondangle.db
===================================================================
--- src/Hbondangle.db	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Hbondangle.db	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,13 @@
+# atomicnumber angles for single, double and triple bond (-1 no angle)
+1	180	-1	-1
+5	180	131.0	109.2
+6	180	120	109.47
+7	180	110	106.67
+8	180	104.5	-1
+14	180	120	109.47
+15	180	-1	-1
+16	180	-1	-1
+17	180 -1 -1
+20	180	120	109.47
+34	180 -1 -1
+35	180 -1 -1
Index: src/Hbonddistance.db
===================================================================
--- src/Hbonddistance.db	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Hbonddistance.db	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,14 @@
+#atomic number bond distances for single, double and triple bond (-1 no bond)
+1	0.74	-1	-1
+2	0.77429209	-1	-1
+5	1.23	1.19	1.18
+6	1.09	1.076	1.06
+7	1.04	1.02	1.01
+8	0.96	0.957	-1
+14	1.48	1.48	1.48
+15	1.42	-1	-1
+16	1.35	-1	-1
+17	1.29	-1	-1
+20	1.09	1.09	-1
+34	1.47	-1	-1
+35	1.44	-1	-1
Index: src/Helpers/Assert.cpp
===================================================================
--- src/Helpers/Assert.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Helpers/Assert.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,130 @@
+/*
+ * Assert.cpp
+ *
+ *  Created on: Mar 18, 2010
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Helpers/Assert.hpp"
+#include <iostream>
+
+using namespace std;
+
+namespace Assert{
+  AssertionFailure::AssertionFailure(std::string _condition,
+                                     std::string _file,
+                                     int _line,
+                                     std::string _message) :
+    condition(_condition),
+    file(_file),
+    line(_line),
+    message(_message)
+  {}
+
+  std::string AssertionFailure::getFile(){
+    return file;
+  }
+
+  int AssertionFailure::getLine(){
+    return line;
+  }
+
+  std::string AssertionFailure::getMessage(){
+    return message;
+  }
+
+  std::ostream& AssertionFailure::operator<<(std::ostream& out){
+    out << "Assertion \"" << condition << "\" failed in file " << file << " at line " << line << endl;
+    out << "Assertion Message: " << message << std::endl;
+    return out;
+  }
+
+  const char  ActionKeys[]  = {'\0','a','t','i'};
+  const char* ActionNames[] = {"Ask","Abort","Throw","Ignore"};
+}
+
+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)
+{
+  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;
+      }
+      else{
+        choice = ActionKeys[defaultAction];
+      }
+      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(){
+  for(vector<hook_t>::reverse_iterator iter = hooks.rbegin(); iter!=hooks.rend(); ++iter ){
+    (*iter)();
+  }
+}
+
+void _my_assert::addHook(hook_t hook){
+  hooks.push_back(hook);
+}
+
+void _my_assert::removeHook(Assert::hook_t hook){
+  for(vector<hook_t>::iterator iter = hooks.begin(); iter!=hooks.end();){
+    if((*iter)==hook){
+      iter = hooks.erase(iter);
+    }
+    else{
+      ++iter;
+    }
+  }
+}
+
+void _my_assert::setDefault(Assert::Action action){
+  defaultAction = action;
+}
+Assert::Action _my_assert::getDefault(){
+  return defaultAction;
+}
+std::string _my_assert::printDefault(){
+  return ActionNames[defaultAction];
+}
+
+#endif
+
Index: src/Helpers/Assert.hpp
===================================================================
--- src/Helpers/Assert.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Helpers/Assert.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,380 @@
+/*
+ * Assert.hpp
+ *
+ *  Created on: Mar 18, 2010
+ *      Author: crueger
+ */
+
+#ifndef ASSERT_HPP_
+#define ASSERT_HPP_
+
+#include<sstream>
+#include<string>
+#include<iostream>
+#include<vector>
+#include<map>
+
+/**
+ * \file Helpers/Assert.hpp
+ * <H1> ASSERT Howto </H1>
+ *
+ * <H2> Introduction </H2>
+ *
+ * ASSERT() is a small macro that allows easier debugging, when it is widely used. The custom
+ * ASSERT macro defined in this file works mainly the same way as the assert() macro that
+ * is defined in the Ansi-C standard, but includes a few nice additions.
+ *
+ * <H3> What ASSERT() does </H3>
+ *
+ * ASSERT can be used to make sure that a condition that always needs to be true for the code to
+ * work correctly is holding. If you have a function that takes a value greater than 0 and a value
+ * smaller than 0 indicates a mistake you should always do it the following way: <br>
+ * @code
+ * void foo(int a) // a should be greater 0
+ * {
+ *  ASSERT(a>0,"Parameter passed to foo was smaller than 0");
+ *  ...
+ * }
+ * @endcode
+ *
+ * (Note: some people say, that assertions like these should not be used to check function parameters.
+ * This is mainly due to the reason, that a failed assertion will show up inside the function. The buggy
+ * code however is at a completely different place, i.e. at the callers side. Always put the
+ * Assertions as close to the code that produces the value as possible, when looking at function
+ * parameters however this would mean, that any code calling foo would have an ASSERT(...) before
+ * it, which makes it easy to forget the Assertion at some places. Also this makes an easy example.)
+ *
+ * If the condition inside the ASSERT does not evaluate to true the user is shown a message, including
+ * the condition that failed, the line in which the failure was observed and the message of the assertion.
+ * In the above case that would look something like this:<br>
+ * @code
+ * Assertion "a>0" failed in foo.cpp in line 3.
+ * Assertion Message: Parameter passed to foo was smaller than 0
+ * @endcode
+ *
+ * In normal conditions, i.e. when no default action is set (see below for default actions) the user
+ * is then shown a short choice menu, on how to handle the assertion. The user can choose to abort the
+ * program, throw an exception of type AssertionFailure that contains the file, line and message,
+ * ignore the assertion or even to always ignore the assertion at that point (i.e. the ASSERT() macro
+ * at this file and line is fully disabled).
+ *
+ * Both ASSERT() and assert() handle debugging in the same way, i.e. they are only used when the
+ * NDEBUG macro is not defined. If the NDEBUG macro is defined, for example using a CXXFLAG then
+ * all asserts and ASSERTs will be disabled in the compiled program. That way in a end-user version
+ * all assertions can be removed with a single switch, thus not hassling the end-user with potential
+ * bugs.
+ *
+ * <H2> Special functions of ASSERT() </H2>
+ *
+ * Compared to the standard assert() macro the custom ASSERT() contains a few special functions. As
+ * first it is possible to set a global default behavior that is used anytime an assertion fails.
+ * This default behavior can be either of Assert::Ask, Assert::Abort, Assert::Throw or Assert::ignore.
+ * The default behavior is set using the ASSERT_DO() macro. For example if you want to check in a
+ * unittest that wrong code at another point actually makes a certain assert fail you could set
+ * ASSERT_DO(Assert::Throw) to make sure a exception is thrown and catch that exception using
+ * the CPPUNIT_ASSERT_THROW() macro. The current set default behavior can be queried as a string
+ * using the ASSERT_DEFAULT macro.
+ *
+ * As a second enhancement it is possible to install callback functions as hooks that will be executed
+ * when an assertion aborts the program. These callback functions could for example be used to flush
+ * any open streams, thus making sure files on the disk are not corrupted by a unexpected abortion.
+ * It would also be possible to install functions that produce some kind of "coredump" of important
+ * internal data-structures, thus giving the person looking for the bug some valuable information.
+ * These assertion hooks should however not be used to clean up the reserved memory of the program,
+ * because a) this memory is under normal circumstances reclaimed by the OS anyway, once the program
+ * has aborted and b) the memory might still contain some hints that could be useful when running
+ * the program inside a debugger and which could be destroyed by the clean-up. To use the hooking
+ * mechanism you can simply use the ASSERT_HOOK() macro, passing this macro any kind of void function.
+ * For example:<br/>
+ * @code
+ * void foo(){
+ *   // produce a coredump
+ *   ...
+ *   // close and flush all open handles
+ *   ...
+ * }
+ *
+ * int main(int argc, char **argv){
+ *   ASSERT_HOOK(foo);
+ *   ...
+ *   return 0;
+ * }
+ * @endcode
+ *
+ * All hooks will be executed in the reverse order of hooking, i.e. the function hooked last will be
+ * executed first when the abortion is handled. It is also possible to remove a hook to any function
+ * using the ASSERT_UNHOOK() macro and passing it the pointer to the function one wants to remove.
+ *
+ * Assertion hooks will only be executed when the program is terminated by an assertion using the
+ * abort mechanism. They will not be executed when the program exits in any other way. They also
+ * wont be executed when the assertion is ignored or an exception is thrown (even when the exception
+ * is not caught and thus terminates the program).
+ *
+ * <H2> Rules for using ASSERT() </H2>
+ *
+ * The rules for using ASSERT() are basically the same ones that can be used as guidlines for the
+ * standard assert() macro. So if you think you know those guidelines you can skip the following.
+ *
+ * <ul>
+ * <li> ASSERT() should be used only for problems that indicate a bug, i.e. problems that can be
+ * improved by rewriting parts of the program. ASSERT() should not be used to query problems that
+ * can go wrong during the normal execution of the program. For example ASSERT() should not be
+ * used to test whether a file could be opened, or memory could be reserved, as a failure of either
+ * of those tasks can not be improved upon by rewriting the code.
+ * <li> The condition in the ASSERT() macro should never contain any side-effects. Only call methods,
+ * when you are absolutely certain that these methods wont have any side-effects. Calling ASSERT()
+ * should in no way change the state of the program, because once the end-user version is produced
+ * using the NDEBUG flag all assertions are removed and so are the conditions. If the condition did
+ * cause a state transition, this state transition would be removed and the behavior of the end-user
+ * and the debug version might differ. Things you should watch out for are for example<br/>
+ * @code
+ * ASSERT(++i,"i was zero after incrementing");
+ * @endcode
+ * instead always do
+ * @code
+ * ++i;
+ * ASSERT(i,"i was zero after incrementing");
+ * @endcode
+ * <li> Give descriptive error messages. This one is a bit obvious but easy to do wrong, so I included
+ * it here. An
+ * @code
+ * ASSERT(ptr,"Pointer was zero");
+ * @endcode
+ * wont help anyone. If you do <br/>
+ * @code
+ * ASSERT(ptr,"Second argument of function foo should have pointed to an object of type bar, but was zero.");
+ * @endcode
+ * instead, people will almost immidiately know what to look for.
+ * </ul>
+ *
+ * <H2> Differences between ASSERT() and assert() </H2>
+ *
+ * This chapter is to explain why a custom ASSERT() macro was introduced and should be used in place
+ * of the standard assert(). Here are the main differences between ASSERT() and assert().
+ *
+ * <ul>
+ * <li> ASSERT() makes it easy to add a more verbose message about the nature of the failure. For
+ * assert() it has become customary to add messages using constructs like
+ * @code
+ * assert(c>0 && "Counter should be at least 1");
+ * @endcode in order to add descriptions. However both the syntax and the final output for this are
+ * a bit awkward. The custom ASSERT() handles messages in a much better way, as well as making them
+ * mandatory instead of optional.
+ * <li> ASSERT() leaves the user and the programmer a choice how to handle an assertion. While the
+ * assert() macro will always abort the program, the ASSERT() macro normally gives the user a choice on
+ * what to do. For debugging it might also be interesting how a broken assumption influences the rest
+ * of the program, so the assertion can also be ignored. Also the Exception mechanism allows
+ * assertions to be part of unittests, whereas they would always fail if the assert() macro was used.
+ * <li> ASSERT() does not unwind the stack (at least when compiled using gcc). The normal assert()
+ * exits the program, which unwinds the stack and destroys any hope for recovering a stack trace.
+ * ASSERT() on the other hand aborts the program using a special trap function, that leaves the
+ * stack intact. This way, when the program is run inside a debugger the stack is still available
+ * and can be inspected. This is the main reason, why it is safe to use ASSERT() to check function
+ * parameters, whereas assert() would give problems in such cases.
+ * <li> ASSERT() allows for hooks to be installed when the program exits. As mentioned above this
+ * makes it possible to produce coredumps, make sure all files are in a usable state or other tasks
+ * that have to be performed before killing the program.
+ * </ul>
+ *
+ * <H2> Tips and tricks and FAQ </H2>
+ *
+ * <ul>
+ * <li> <H4> ASSERT() is broken. When I abort the program it says something about an
+ * "Illegal instruction"</H4>
+ * The complaints about the illegal instruction after an abortion are no need to worry. This
+ * illegal instruction is part of the trap that is used to exit the program while leaving the stack
+ * intact. This illegal instruction can be detected by the debugger, which means it will give you the
+ * usual prompt once it is encountered. The illegal instruction is guaranteed not to mess up anything,
+ * so there is no need to worry about it.
+ * <li> <H4> When compiling the program with $NON_GCC_COMPILER and then debugging it, it will
+ * unwind the stack. I need the backtrace however to find the bug </H4>
+ * The mechanism to preserve the stack is compiler specific. For now only a mechanism that is supported
+ * by gcc is implemented, because this compiler is widely used. For other compilers the program
+ * is simply exited, and the stack is destroyed. If you need a backtrace and you cannot use gcc you
+ * have to figure out a way to have your compiler produce a trap instruction in the program. You might
+ * want to use google to find out how to get your compiler to do that. For many compilers a
+ * _asm {int 3} is said to work. Also for VC++ the instruction __debugbreak() might produce a trap.
+ * Also dividing by zero is a hack that could be used as a last hope if you don't find a way to produce
+ * traps with your compiler even after a longer search. If you found a way to handle the traps you can
+ * then add the macro DEBUG_BREAK for your compiler and the stack will be preserved.
+ * <li> <H4> I have a portion of the program that should never be executed. How can I assure this
+ * using assert.</H4>
+ * This is a common task for assertions. For example you might have an exhaustive switch/case where
+ * the default value indicates that something went wrong. Simply use the following construct:
+ * @code
+ * switch(foo){
+ *   case Bar:
+ *     ...
+ *     break;
+ *   case Baz:
+ *     ...
+ *     break;
+ *   ...
+ *   default:
+ *     ASSERT(0,"This switch should always be exhaustive.\nDid somebody add values to the enum?");
+ * }
+ * @endcode
+  * </ul>
+ */
+
+#ifndef NDEBUG
+  #ifndef STRINGIFY
+    #define STRINGIFY(x) #x
+  #endif
+
+  #ifdef __GNUC__
+    // on gcc we know how to exit to the Debugger
+    #define DEBUG_BREAK __builtin_trap()
+  #else
+    #define DEBUG_BREAK exit(1)
+  #endif
+
+  #define ASSERT(condition,message) \
+    do{\
+      static bool ignore = false;\
+      if(!ignore){\
+        if(Assert::_my_assert::check((condition),STRINGIFY(condition),(message),\
+                                     __FILE__,__LINE__,ignore)){\
+          Assert::_my_assert::doHooks();\
+          DEBUG_BREAK;\
+        }\
+      } \
+    }while(0)
+
+  #define ASSERT_NOCATCH(message) \
+		catch(Assert::AssertionFailure&){throw;}\
+		catch(...){\
+		  static bool ignore = false; \
+		  if(!ignore){\
+			  if(Assert::_my_assert::check(false,"Exception caught",(message),__FILE__,__LINE__,ignore)){\
+			    Assert::_my_assert::doHooks();\
+          DEBUG_BREAK;\
+			  }\
+		  }\
+		} do{(void)(0);}while(0)
+
+  #define assert_cast Assert::_wrapper(__LINE__,__FILE__)._convert
+
+  #define ASSERT_DO(action)    do{Assert::_my_assert::setDefault(action);}while(0)
+  #define ASSERT_HOOK(hook)    do{Assert::_my_assert::addHook(hook);}while(0)
+  #define ASSERT_UNHOOK(hook)  do{Assert::_my_assert::removeHook(hook);}while(0)
+  #define ASSERT_DEFAULT       (Assert::_myAssert::printDefault())
+#else
+  // we need to do something, so this is the usual solution (e.g. assert.h)
+  #define ASSERT(condition,message) (void)(0)
+  #define ASSERT_NOCATCH(message)   catch(...) {throw;} do{(void)(0);}while(0)
+  #define assert_cast static_cast
+  #define ASSERT_DO(action)         (void)(0)
+  #define ASSERT_HOOK(hook)         (void)(0)
+  #define ASSERT_UNHOOK(hook)       (void)(0)
+  #define ASSERT_DEFAULT            std::string("Deactivated")
+#endif
+
+namespace Assert{
+
+  typedef void (*hook_t)(void);
+
+
+  enum Action {Ask,Abort,Throw,Ignore,MAX_ACTION};
+  extern const char  ActionKeys[MAX_ACTION];
+  extern const char* ActionNames[MAX_ACTION];
+
+  class AssertionFailure{
+  public:
+    AssertionFailure(std::string _condition, std::string _file, int _line, std::string _message);
+    std::string getFile();
+    int getLine();
+    std::string getMessage();
+
+    std::ostream& operator<<(std::ostream&);
+  private:
+    std::string condition;
+    std::string file;
+    int line;
+    std::string message;
+  };
+
+  //! @cond
+#ifndef NDEBUG
+    class _my_assert{
+    public:
+      static bool check(const bool res,
+                        const char* condition,
+                        const char* message,
+                        const char* filename,
+                        const int line,
+                        bool& ignore);
+      static void addHook(Assert::hook_t hook);
+      static void removeHook(Assert::hook_t hook);
+      static void doHooks();
+      static void setDefault(Assert::Action);
+      static Assert::Action getDefault();
+      static std::string printDefault();
+    private:
+      static Assert::Action defaultAction;
+      static std::vector<Assert::hook_t> hooks;
+    };
+
+
+  class _wrapper{
+  public:
+    _wrapper(int _line,const char* _file) :
+      line(_line),
+      file(_file)
+      {}
+
+    // Overloaded template for pointers
+    template<typename target,typename source>
+    target _convert(source *src){
+      std::stringstream sstr;
+      sstr << file << ":" << line;
+      bool &ignore = ignores[sstr.str()];
+
+      if(!ignore){
+        if(_my_assert::check(dynamic_cast<target>(src)==static_cast<target>(src),"type-safe typecast",
+                                       message_ptr,file,line,ignore)){
+          _my_assert::doHooks();
+          DEBUG_BREAK;
+        }
+      }
+      return static_cast<target>(src);
+    }
+
+    // Overloaded template for references
+    template<typename target, typename source>
+    target _convert(source &src){
+            std::stringstream sstr;
+      sstr << file << ":" << line;
+      bool &ignore = ignores[sstr.str()];
+
+      try{
+        target res =dynamic_cast<target>(src);
+        return res;
+      }
+      catch(...){
+        if(!ignore){
+          if(_my_assert::check(0,"type-safe typecast",message_ref,file,line,ignore)){
+            _my_assert::doHooks();
+            DEBUG_BREAK;
+          }
+        }
+      }
+      // The error was ignored. Just return whatever a static_cast would do
+      return static_cast<target>(src);
+    }
+  private:
+    int line;
+    const char *file;
+    static std::map<std::string,bool> ignores;
+    // this avoids duplication of the strings when templates are instantiated
+    static const char* message_ptr;
+    static const char* message_ref;
+  };
+#endif
+  //! @endcond
+}
+
+
+
+
+#endif /* ASSERT_HPP_ */
Index: src/Helpers/MemDebug.cpp
===================================================================
--- src/Helpers/MemDebug.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Helpers/MemDebug.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,491 @@
+/*
+ * MemDebug.cpp
+ *
+ *  Created on: Apr 28, 2010
+ *      Author: crueger
+ */
+
+#ifndef NDEBUG
+#ifndef NO_MEMDEBUG
+
+#include <iostream>
+#include <cstdlib>
+#include <cstring>
+#include <boost/thread.hpp>
+
+#ifdef __GNUC__
+#include <execinfo.h>
+#include <cxxabi.h>
+#endif
+
+using namespace std;
+
+// we need our own low level mutexex, since we cannot assure the time of construction and destruction
+// otherwise
+#if defined(unix) || defined(__unix)
+
+#include <pthread.h>
+#include <cassert>
+#define mutex_t    pthread_mutex_t
+#define mutex_init PTHREAD_MUTEX_INITIALIZER
+#define mutex_lock(mtx) \
+  do{\
+    int res = pthread_mutex_lock(&(mtx));\
+    assert(!res && "Could not lock mutex!");\
+  }while(0)
+
+#define mutex_unlock(mtx) \
+  do{\
+    int res = pthread_mutex_unlock(&(mtx));\
+    assert(!res && "Could not unlock mutex!");\
+  }while(0)
+
+#else
+# error "No thread structure defined for this plattform..."
+#endif
+
+namespace Memory {
+
+  // This struct is added before each memory chunk
+  // and contains tracking information. Anything used
+  // to track memory cannot use any dynamic memory, so
+  // we have to resort to classic C-idioms here.
+  // This struct also contains pointers to the next
+  // an previous chunks to allow fast traversion of
+  // all allocated memory blocks
+  struct entry_t {
+    // we seperate the tracking info from the rest
+    // A checksum will be calculated for this part of
+    // the struct, so the information in here should
+    // not change during the lifetime of the memory
+    struct info_t {
+      enum {length = 64};
+      char file[length+1];
+      int line;
+#ifdef __GNUC__  // function tracking only works with GCC
+      // function names can get looooong
+      enum {length2 = 256};
+      char function[length2+1];
+#endif
+      size_t nbytes;
+      bool isUsed;
+      void *location;
+    } info;
+    bool isIgnored;
+    char checksum;
+    entry_t *prev;
+    entry_t *next;
+  };
+
+
+  mutex_t memorylock = mutex_init;
+
+  // start and end of the doubly-linked list
+  entry_t *begin=0;
+  entry_t *end=0;
+
+  // current amount of allocated memory
+  size_t state = 0;
+  // maximum amount of allocated memory
+  size_t max = 0;
+  // number of allocations that have been done so far
+  unsigned int allocs = 0;
+
+
+  // this sets the alignment of the returned memory block
+  // malloc guarantees an alignment at the 8 byte border,
+  // so we just do the same
+  const int alignment = 8;
+
+  // calculates a simple checksum for the info block
+  // the checksum is used to find memory corruptions
+  inline char calcChecksum(entry_t::info_t *info){
+    char *buffer = (char*)info;
+    char checksum =0;
+    for(size_t i=0;i<sizeof(entry_t::info_t);i++){
+      checksum+=buffer[i];
+    }
+    return checksum;
+  }
+
+  // gets the next alignet point which is greater than nbytes
+  // this function is only called a fixed number of times, so
+  // there is no need to optimize
+  inline size_t doAlign(size_t nbytes){
+    int nonaligned = nbytes % alignment;
+    if(nonaligned) {
+     return(nbytes - nonaligned + alignment);
+    }
+    else{
+      return nbytes;
+    }
+  }
+
+  // Output some state information
+  void getState(){
+    cout << "Maximum allocated Memory: " << max << " bytes" << endl;
+    cout << "Currently allocated Memory: " << state <<" bytes" << endl;
+    cout << allocs << " allocated chunks total" << endl;
+
+    // simple traversal of the chunk list
+    for(entry_t *pos=begin;pos;pos=pos->next){
+      cout << "\nChunk of " << pos->info.nbytes << " bytes" << " still available" << endl;
+#ifdef __GNUC__
+      cout << "Chunk reserved at: " << pos->info.function
+           << " (" << pos->info.file << ":" << pos->info.line  << ")" << endl;
+#else
+      cout << "Chunk reserved at: " << pos->info.file << ":" << pos->info.line << endl;
+#endif
+    }
+  }
+
+  // Adds an entry to the linked list
+  void addEntry(entry_t *entry){
+    // check if the entry is already in the list
+    if(!entry->isIgnored)
+      return;
+
+    mutex_lock(Memory::memorylock);
+
+    entry->next=0;            // the created block is last in the list
+    entry->prev=Memory::end;  // the created block is last in the list
+    if(!Memory::begin){
+      // the list was empty... start a new one
+      Memory::begin=entry;
+    }
+    else {
+      // other blocks present... we can add to the last one
+      Memory::end->next=entry;
+    }
+    Memory::end=entry;
+
+    // update some global info
+    Memory::state  += entry->info.nbytes;
+    if(Memory::state>Memory::max){
+        Memory::max = Memory::state;
+    }
+    ++Memory::allocs;
+    // done with the list... it is safe to unlock now
+    mutex_unlock(Memory::memorylock);
+    entry->isIgnored = false;
+  }
+
+  // Deletes an entry from the linked list
+  void deleteEntry(entry_t *entry){
+    if(entry->isIgnored)
+      return;
+
+    mutex_lock(memorylock);
+    if(entry->prev){
+      entry->prev->next = entry->next;
+    }
+    else{
+      // this node was the beginning of the list
+      begin = entry->next;
+    }
+
+    if(entry->next){
+      entry->next->prev = entry->prev;
+    }
+    else{
+      // this node was the end of the list
+      end = entry->prev;
+    }
+    Memory::state  -= entry->info.nbytes;
+    mutex_unlock(memorylock);
+    entry->isIgnored = true;
+
+  }
+
+  void _ignore(void *ptr){
+    // just deletes the node from the list, but leaves the info intact
+    static const size_t entrySpace = Memory::doAlign(sizeof(Memory::entry_t));
+    entry_t *entry = (Memory::entry_t*)((char*)ptr-entrySpace);
+    deleteEntry(entry);
+  }
+
+#ifdef __GNUC__
+  // this function let's us find the caller's name
+  char* getCaller(){
+    // stack looks like this:
+    // getCaller();
+    // operator new();
+    // function_we_are_looking_for(); <-
+    const size_t max_depth = 3;
+    void* stack_addrs[max_depth];
+    size_t stack_depth;
+    char **stack_strings=0;
+    const char *func_name=0;
+    const char *toplevel = "Global scope";
+    char *retval=0;
+
+    // get the backtrace, depth three
+    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(entry_t::info_t::length2));
+    if(!dm_function){
+      // malloc failed... we are out of luck
+      throw std::bad_alloc();
+    }
+
+    // see if we found our function name
+    if(stack_depth==max_depth){
+      // find the mangled function name
+      char *begin = stack_strings[max_depth-1];
+      // 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
+
+        size_t sz = entry_t::info_t::length2;
+        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{
+          // demangling failed... get the function name without demangling
+          func_name = begin;
+        }
+      }
+      else{
+        // function name not found... get the whole line
+        func_name = stack_strings[max_depth-1];
+      }
+
+    }
+    else{
+      func_name = toplevel;
+    }
+
+    // now we copy the desired function name
+    if((retval = static_cast<char*>(malloc(strlen(func_name)+1)))){
+      // we know that the string will fit, so strcpy is safe here
+      strcpy(retval,func_name);
+    }
+    else{
+      free(stack_strings); // malloc()ed by backtrace_symbols
+      free(dm_function);
+      // uh-uh ... seems we are out of luck for allocations now
+      throw std::bad_alloc();
+    }
+    free(dm_function);
+    free(stack_strings); // malloc()ed by backtrace_symbols
+    return retval;
+  }
+#endif
+}
+
+#ifdef __GNUC__
+
+void *operator new(size_t nbytes,const char* file, int line, const char* func) throw(std::bad_alloc) {
+
+  // to avoid allocations of 0 bytes if someone screws up
+  // allocation with 0 byte size are undefined behavior, so we are
+  // free to handle it this way
+  if(!nbytes) {
+    nbytes = 1;
+  }
+
+  // get the size of the entry, including alignment
+  static const size_t entrySpace = Memory::doAlign(sizeof(Memory::entry_t));
+
+  void *res;
+  if(!(res=malloc(entrySpace + nbytes))){
+    // new must throw, when space is low
+    throw std::bad_alloc();
+  }
+
+  // build the entry in front of the space
+  Memory::entry_t *entry = (Memory::entry_t*) res;
+  memset(res,0,entrySpace);
+  entry->info.nbytes = nbytes;
+  entry->info.isUsed = true;
+  strncpy(entry->info.file,file,Memory::entry_t::info_t::length);
+  entry->info.file[Memory::entry_t::info_t::length] = '\0';
+  entry->info.line=line;
+  strncpy(entry->info.function,func,Memory::entry_t::info_t::length2);
+  entry->info.function[Memory::entry_t::info_t::length2] = '\0';
+  // the space starts behind the info
+  entry->info.location = (char*)res + entrySpace;
+
+  // mark the block as not in the list (will be changed by addEntry)
+  entry->isIgnored = true;
+  Memory::addEntry(entry);
+
+  // get the checksum...
+  entry->checksum = Memory::calcChecksum(&entry->info);
+
+  // ok, space is prepared... the user can have it.
+  // the rest (constructor, deleting when something is thrown etc)
+  // is handled automatically
+  return entry->info.location;
+}
+
+#else
+
+void *operator new(size_t nbytes,const char* file, int line) throw(std::bad_alloc) {
+
+  // to avoid allocations of 0 bytes if someone screws up
+  // allocation with 0 byte size are undefined behavior, so we are
+  // free to handle it this way
+  if(!nbytes) {
+    nbytes = 1;
+  }
+
+  // get the size of the entry, including alignment
+  static const size_t entrySpace = Memory::doAlign(sizeof(Memory::entry_t));
+
+  void *res;
+  if(!(res=malloc(entrySpace + nbytes))){
+    // new must throw, when space is low
+    throw std::bad_alloc();
+  }
+
+  // build the entry in front of the space
+  Memory::entry_t *entry = (Memory::entry_t*) res;
+  memset(res,0,entrySpace);
+  entry->info.nbytes = nbytes;
+  entry->info.isUsed = true;
+  strncpy(entry->info.file,file,Memory::entry_t::info_t::length);
+  entry->info.file[Memory::entry_t::info_t::length] = '\0';
+  entry->info.line=line;
+  // the space starts behind the info
+  entry->info.location = (char*)res + entrySpace;
+
+  // mark the block as not in the list (will be changed by addEntry)
+  entry->isIgnored = true;
+  Memory::addEntry(entry);
+
+  // get the checksum...
+  entry->checksum = Memory::calcChecksum(&entry->info);
+  // this will be set to true, when the block is removed from
+  // the list for any reason
+  entry->isIgnored = false;
+
+  // ok, space is prepared... the user can have it.
+  // the rest (constructor, deleting when something is thrown etc)
+  // is handled automatically
+  return entry->info.location;
+}
+
+#endif
+
+void *operator new(size_t nbytes) throw(std::bad_alloc) {
+  // Just forward to the other operator, when we do not know from
+  // where the allocation came
+#ifdef __GNUC__
+  // this might throw bad_alloc
+  char *caller = Memory::getCaller();
+  void* retval = 0;
+
+  // if this throws, we have to clean up the caller anyway
+  try{
+    retval = operator new(nbytes,"Unknown",0,caller);
+  }
+  catch(...)
+  {
+    free(caller); // malloc()ed by Memory::getCaller();
+    throw;
+  }
+  free(caller); // malloc()ed by Memory::getCaller();
+  return retval;
+#else
+  return operator new(nbytes,"Unknown",0);
+#endif
+}
+
+#ifdef __GNUC__
+
+void *operator new[] (size_t nbytes,const char* file, int line, const char* func) throw(std::bad_alloc) {
+  // The difference between new and new[] is just for compiler bookkeeping.
+  return operator new(nbytes,file,line,func);
+}
+
+#else
+
+void *operator new[] (size_t nbytes,const char* file, int line) throw(std::bad_alloc) {
+  // The difference between new and new[] is just for compiler bookkeeping.
+  return operator new(nbytes,file,line);
+}
+
+#endif
+
+void *operator new[] (size_t nbytes) throw(std::bad_alloc) {
+  // Forward again
+#ifdef __GNUC__
+  // this might throw bad_alloc
+    char *caller = Memory::getCaller();
+    void *retval=0;
+
+    // if this throws, we have to clean up the caller anyway
+    try{
+      retval = operator new[] (nbytes,"Unknown",0,caller);
+    }
+    catch(...)
+    {
+      free(caller); // malloc()ed by Memory::getCaller();
+      throw;
+    }
+    free(caller); // malloc()ed by Memory::getCaller();
+    return retval;
+#else
+  return operator new[] (nbytes,"Unknown",0);
+#endif
+}
+
+void operator delete(void *ptr) throw() {
+  if(!ptr){
+    cerr << "Warning: Deleting NULL pointer" << endl;
+    return;
+  }
+
+  // get the size for the entry, including alignment
+  static const size_t entrySpace = Memory::doAlign(sizeof(Memory::entry_t));
+
+  // get the position for the entry from the pointer the user gave us
+  Memory::entry_t *entry = (Memory::entry_t*)((char*)ptr-entrySpace);
+
+  // let's see if the checksum is still matching
+  if(Memory::calcChecksum(&entry->info)!=entry->checksum){
+    cerr << "Possible memory corruption detected!" << endl;
+    cerr << "Trying to recover allocation information..." << endl;
+    cerr << "Memory was allocated at " << entry->info.file << ":" << entry->info.line << endl;
+    terminate();
+  }
+
+  // this will destroy the checksum, so double deletes are caught
+  entry->info.isUsed = false;
+  Memory::deleteEntry(entry);
+
+  // delete the space reserved by malloc
+  free((char*)ptr-entrySpace);
+}
+
+// operator that is called when the constructor throws
+// do not call manually
+void operator delete(void *ptr,const char*, int) throw() {
+  operator delete(ptr);
+}
+
+void operator delete[](void *ptr){
+  // again difference between delete and delete[] is just in compiler bookkeeping
+  operator delete(ptr);
+}
+
+// and another operator that can be called when a constructor throws
+void operator delete[](void *ptr,const char*, int) throw(){
+  operator delete(ptr);
+}
+#endif
+#endif
Index: src/Helpers/MemDebug.hpp
===================================================================
--- src/Helpers/MemDebug.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Helpers/MemDebug.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,106 @@
+/*
+ * MemDebug.hpp
+ *
+ *  Created on: Apr 28, 2010
+ *      Author: crueger
+ */
+
+#ifndef MEMDEBUG_HPP_
+#define MEMDEBUG_HPP_
+
+/**
+ * @file
+ * This module allows easy automatic memory tracking. Link this module to replace the
+ * operators new, new[], delete and delete[] with custom versions that add tracking
+ * information to allocated blocks.
+ *
+ * All tracking is done in O(1) for new and delete operators. Summaries for the
+ * used memory take O(N), where N is the number of currently allocated memory chunks.
+ *
+ * To use full tracking including file name and line number include this file in
+ * your sourcefiles.
+ */
+#ifndef NDEBUG
+#ifndef NO_MEMDEBUG
+
+#ifndef MEMDEBUG
+#define MEMDEBUG
+#endif
+
+#include <new>
+
+// some light header files, that do weird new stuff and therefore need
+// to be loaded before the define
+#include <string>
+#include <boost/optional.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/function.hpp>
+#include <boost/program_options.hpp>
+
+
+namespace Memory {
+
+  /**
+   * Displays a short summary of the memory state.
+   */
+  void getState();
+
+  void _ignore(void*);
+
+  /**
+   * Use this to disable memory for a certain pointer on the heap.
+   * This is useful for pointers which should live over the run of the
+   * program, and which are deleted automatically at the end. Usually these
+   * pointers should be wrapped inside some kind of smart pointer to
+   * ensure destruction at the end.
+   */
+  template <typename T>
+  T *ignore(T* ptr){
+    _ignore((void*)ptr);
+    return ptr;
+  }
+}
+#ifdef __GNUC__
+void *operator new   (size_t nbytes,const char* file, int line, const char* func) throw(std::bad_alloc);
+void *operator new[] (size_t nbytes,const char* file, int line, const char* func) throw(std::bad_alloc);
+#else
+void *operator new   (size_t nbytes,const char* file, int line) throw(std::bad_alloc);
+void *operator new[] (size_t nbytes,const char* file, int line) throw(std::bad_alloc);
+#endif
+void operator delete   (void *ptr,const char*, int) throw();
+void operator delete[] (void *ptr,const char*, int) throw();
+
+
+
+/**
+ * This macro replaces all occurences of the keyword new with a replaced
+ * version that allows tracking.
+ */
+#ifdef __GNUC__
+#define new new(__FILE__,__LINE__,__PRETTY_FUNCTION__)
+#else
+#define new new(__FILE__,__LINE__)
+#endif
+
+#endif
+#endif
+
+
+#ifdef NDEBUG
+#undef MEMDEBUG
+#endif
+
+#ifndef MEMDEBUG
+// memory debugging was disabled
+
+namespace Memory {
+  inline void getState(){}
+
+  template <typename T>
+  inline T *ignore(T* ptr){
+    return ptr;
+  }
+}
+
+#endif
+#endif /* MEMDEBUG_HPP_ */
Index: src/Helpers/fast_functions.hpp
===================================================================
--- src/Helpers/fast_functions.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Helpers/fast_functions.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,82 @@
+/*
+ * fast_functions.hpp
+ *
+ *  Created on: Apr 1, 2010
+ *      Author: crueger
+ */
+
+#ifndef FAST_FUNCTIONS_HPP_
+#define FAST_FUNCTIONS_HPP_
+
+#include "defs.hpp"
+
+/**
+ * !@file
+ * This file contains several functions that need to be very fast and which are inlined for this
+ * reason.
+ *
+ * Warning: do not forget inline keyword for functions in this file to avoid multiple definitions!
+ */
+
+/********************************* Functions ************************************************/
+
+/** hard-coded determinant of a 3x3 matrix.
+ * \param a[9] matrix
+ * \return \f$det(a)\f$
+ */
+inline double RDET3(const double a[NDIM*NDIM])
+{
+  return ((a)[0]*(a)[4]*(a)[8] + (a)[3]*(a)[7]*(a)[2] + (a)[6]*(a)[1]*(a)[5] - (a)[2]*(a)[4]*(a)[6] - (a)[5]*(a)[7]*(a)[0] - (a)[8]*(a)[1]*(a)[3]);
+};
+
+/** hard-coded determinant of a 2x2 matrix.
+ * \param a[4] matrix
+ * \return \f$det(a)\f$
+ */
+inline double RDET2(const double a[4])
+{
+  return ((a[0])*(a[3])-(a[1])*(a[2]));
+};
+
+/** hard-coded determinant of a 2x2 matrix.
+ * \param a0 (0,0) entry of matrix
+ * \param a1 (0,1) entry of matrix
+ * \param a2 (1,0) entry of matrix
+ * \param a3 (1,1) entry of matrix
+ * \return \f$det(a)\f$
+ */
+inline double RDET2(const double a0, const double a1, const double a2, const double a3)
+{
+  return ((a0)*(a3)-(a1)*(a2));
+};
+
+/** Returns the power of \a n with respect to \a base.
+ * \param base basis
+ * \param n power
+ * \return \f$base^n\f$
+ */
+inline int pot(int base, int n)
+{
+  int res = 1;
+  int j;
+  for (j=n;j--;)
+    res *= base;
+  return res;
+};
+
+/*************************** Templatized functions ************************************/
+
+/** Flips two values.
+ * \param x first value
+ * \param y second value
+ */
+template <typename T>
+inline void flip(T &x, T &y)
+{
+  T tmp;
+  tmp = x;
+  x = y;
+  y = tmp;
+};
+
+#endif /* FAST_FUNCTIONS_HPP_ */
Index: src/Legacy/oldmenu.cpp
===================================================================
--- src/Legacy/oldmenu.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Legacy/oldmenu.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,1119 @@
+/** \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: src/Legacy/oldmenu.hpp
===================================================================
--- src/Legacy/oldmenu.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Legacy/oldmenu.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,46 @@
+/** \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: src/Line.cpp
===================================================================
--- src/Line.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Line.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,222 @@
+/*
+ * 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: src/Line.hpp
===================================================================
--- src/Line.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Line.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,50 @@
+/*
+ * 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/Makefile.am
===================================================================
--- src/Makefile.am	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Makefile.am	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,326 @@
+# PLEASE adhere to the alphabetical ordering in this Makefile!
+# 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
+		        
+ATOMSOURCE = \
+  atom.cpp \
+  atom_atominfo.cpp \
+  atom_bondedparticle.cpp \
+  atom_bondedparticleinfo.cpp \
+  atom_graphnode.cpp \
+  atom_graphnodeinfo.cpp \
+  atom_particleinfo.cpp \
+  atom_trajectoryparticle.cpp \
+  atom_trajectoryparticleinfo.cpp
+ATOMHEADER = \
+  atom.hpp \
+  atom_atominfo.hpp \
+  atom_bondedparticle.hpp \
+  atom_bondedparticleinfo.hpp \
+  atom_graphnode.hpp \
+  atom_graphnodeinfo.hpp \
+  atom_particleinfo.hpp \
+  atom_trajectoryparticle.hpp \
+  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 \
+  analysis_correlation.cpp
+ANALYSISHEADER = \
+  analysis_bonds.hpp \
+  analysis_correlation.hpp
+
+ACTIONSSOURCE = \
+  Actions/Action.cpp \
+  Actions/ActionHistory.cpp \
+  Actions/ActionRegistry.cpp \
+  Actions/ActionSequence.cpp \
+  Actions/ErrorAction.cpp \
+  Actions/MakroAction.cpp \
+  Actions/ManipulateAtomsProcess.cpp \
+  Actions/MethodAction.cpp \
+  Actions/Process.cpp
+
+ACTIONSHEADER = \
+  Actions/Action.hpp \
+  Actions/ActionHistory.hpp \
+  Actions/ActionRegistry.hpp \
+  Actions/ActionSequence.hpp \
+  Actions/Calculation.hpp \
+  Actions/Calculation_impl.hpp \
+  Actions/ErrorAction.hpp \
+  Actions/MakroAction.hpp \
+  Actions/ManipulateAtomsProcess.hpp \
+  Actions/MapOfActions.hpp \
+  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 = \
+  Patterns/Observer.cpp
+PATTERNHEADER = \
+  Patterns/Cacheable.hpp \
+  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
+
+DESCRIPTORSOURCE = Descriptors/AtomDescriptor.cpp \
+  Descriptors/AtomIdDescriptor.cpp \
+  Descriptors/AtomTypeDescriptor.cpp \
+  Descriptors/MoleculeDescriptor.cpp \
+  Descriptors/MoleculeIdDescriptor.cpp \
+  Descriptors/MoleculeNameDescriptor.cpp \
+  Descriptors/MoleculePtrDescriptor.cpp 
+				   
+
+DESCRIPTORHEADER = Descriptors/AtomDescriptor.hpp \
+  Descriptors/AtomIdDescriptor.hpp \
+  Descriptors/AtomTypeDescriptor.hpp \
+  Descriptors/MoleculeDescriptor.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
+				  
+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
+             
+QTUIHEADER = ${QTUIMOC_HEADER} UIElements/QT4/QTUIFactory.hpp
+
+QTUI_DEFS =
+
+SOURCE = \
+  ${ANALYSISSOURCE} \
+  ${ACTIONSSOURCE} \
+  ${ATOMSOURCE} \
+  ${PATTERNSOURCE} \
+  ${PARSERSOURCE} \
+  ${DESCRIPTORSOURCE} \
+  ${HELPERSOURCE} \
+  ${EXCEPTIONSOURCE} \
+  bond.cpp \
+  bondgraph.cpp \
+  boundary.cpp \
+  CommandLineParser.cpp \
+  config.cpp \
+  ConfigFileBuffer.cpp \
+  element.cpp \
+  elements_db.cpp \
+  ellipsoid.cpp \
+  errorlogger.cpp \
+  graph.cpp \
+  helpers.cpp \
+  info.cpp \
+  leastsquaremin.cpp \
+  Line.cpp \
+  linkedcell.cpp \
+  log.cpp \
+  logger.cpp \
+  moleculelist.cpp \
+  molecule.cpp \
+  molecule_dynamics.cpp \
+  molecule_fragmentation.cpp \
+  molecule_geometry.cpp \
+  molecule_graph.cpp \
+  molecule_pointcloud.cpp \
+  parser.cpp \
+  periodentafel.cpp \
+  Plane.cpp \
+  Space.cpp \
+  tesselation.cpp \
+  tesselationhelpers.cpp \
+  ThermoStatContainer.cpp \
+  triangleintersectionlist.cpp \
+  vector.cpp \
+  vector_ops.cpp \
+  verbose.cpp \
+  World.cpp
+
+HEADER = \
+  ${ANALYSISHEADER} \
+  ${ACTIONSHEADER} \
+  ${ATOMHEADER} \
+  ${PARSERHEADER} \
+  ${PATTERNHEADER} \
+  ${DESCRIPTORHEADER} \
+  ${EXCEPTIONHEADER} \
+  bond.hpp \
+  bondgraph.hpp \
+  boundary.hpp \
+  CommandLineParser.hpp \
+  config.hpp \
+  ConfigFileBuffer.hpp \
+  defs.hpp \
+  element.hpp \
+  elements_db.hpp \
+  ellipsoid.hpp \
+  errorlogger.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 \
+  World.hpp 
+
+# the following files are no longer used:
+#  memoryallocator.hpp \
+#  memoryallocator.cpp \
+#  memoryusageobserver.hpp \
+#  memoryusageobserver.cpp
+
+BOOST_LIB = $(BOOST_LDFLAGS) $(BOOST_MPL_LIB)
+GUI_LIBS = ${QT_LDADD} ${QT_LIB_GUI} -lQtOpenGL ${GLU_LIBS}
+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
+bin_PROGRAMS = molecuilder molecuildergui joiner analyzer
+
+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
+
+molecuilder_CXXFLAGS = $(BOOST_CPPFLAGS)
+#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}
+
+#Stuff for building the GUI using QT
+molecuildergui_SOURCES = ${QTUISOURCE} ${LEGACYSOURCE} builder.cpp
+molecuildergui_SOURCES += $(srcdir)/version.c
+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}
+
+#Rules needed for QT4
+# UI-Files are scattered throughout several subdirectories
+# Therfore `%'-rules do not seem to work
+#Quick fix to get it done otherwise
+${QTUIMOC_TARGETS}: ${QTUIMOC_HEADER}
+	list='$(QTUIMOC_HEADER)'; for header in $$list; do \
+	echo "Making mocfile for $$header"; \
+	target=`basename $$header | sed "s/\(.*\)\..*/\1.moc.cpp/"`;\
+	$(MOC) $(srcdir)/$$header -o $$target \
+	|| eval $$failcom; \
+	done;
+
+MOSTLYCLEANFILES = ${QTUIMOC_TARGETS}
+	
+#EXTRA_DIST = ${molecuilder_DATA}
+
+FORCE:
+$(srcdir)/.git-version: FORCE
+	@if (test -d $(top_srcdir)/.git && cd $(srcdir) \
+	     && { git describe --dirty --always || git describe; } ) > .git-version-t 2>/dev/null \
+	  && ! diff .git-version-t $(srcdir)/.git-version >/dev/null 2>&1; then \
+	  mv -f .git-version-t $(srcdir)/.git-version; \
+	else \
+	  rm -f .git-version-t; \
+	fi
+
+EXTRA_DIST = $(srcdir)/.git-version
+
+$(srcdir)/version.c: $(srcdir)/.git-version
+	echo "const char *ESPACKVersion = \"$(PACKAGE_NAME) -- git version: "`cat $(srcdir)/.git-version`"\";" > $@
+
+
Index: src/Parser/ChangeTracker.cpp
===================================================================
--- src/Parser/ChangeTracker.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Parser/ChangeTracker.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,56 @@
+/*
+ * ChangeTracker.cpp
+ *
+ *  Created on: Mar 1, 2010
+ *      Author: metzler
+ */
+
+#include "Helpers/MemDebug.hpp"
+#include "Parser/ChangeTracker.hpp"
+#include "Patterns/Singleton_impl.hpp"
+
+
+/**
+ * Constructor. Signs on as an observer for the World.
+ */
+ChangeTracker::ChangeTracker() :
+  Observable("ChangeTracker")
+{
+  isConsistent = true;
+  World::getInstance().signOn(this);
+}
+
+/**
+ * Destructor. Signs off from the World.
+ */
+ChangeTracker::~ChangeTracker() {
+  World::getInstance().signOff(this);
+}
+
+/**
+ * With this, the World can update the change tracker's state.
+ */
+void ChangeTracker::update(Observable *publisher) {
+  isConsistent = false;
+}
+
+/**
+ * Gets whether there are non-saved changes.
+ *
+ * \param true if there are any changes, false otherwise
+ */
+bool ChangeTracker::hasChanged() {
+  return !isConsistent;
+}
+
+/**
+ * Tells all observers (which are the different parsers) that they are supposed
+ * to save the current state.
+ */
+void ChangeTracker::saveStatus() {
+  if (hasChanged()) {
+    notifyAll();
+  }
+}
+
+CONSTRUCT_SINGLETON(ChangeTracker)
Index: src/Parser/ChangeTracker.hpp
===================================================================
--- src/Parser/ChangeTracker.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Parser/ChangeTracker.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,40 @@
+/*
+ * ChangeTracker.hpp
+ *
+ *  Created on: Mar 1, 2010
+ *      Author: metzler
+ */
+
+#ifndef CHANGETRACKER_HPP_
+#define CHANGETRACKER_HPP_
+
+#include "Patterns/Observer.hpp"
+#include "World.hpp"
+
+using namespace std;
+
+/**
+ * Observes the world and notifies subscribers via saveStatus if there are
+ * changes to it.
+ */
+class ChangeTracker : public Singleton<ChangeTracker>, public Observable {
+  friend class Singleton<ChangeTracker>;
+public:
+  void saveStatus();
+  static ChangeTracker* get();
+  static void destroy();
+
+protected:
+  void update(Observable *publisher);
+  bool hasChanged();
+
+private:
+  bool isConsistent;
+  static ChangeTracker* instance;
+
+  // private constructor and destructor due to singleton
+  ChangeTracker();
+  ~ChangeTracker();
+};
+
+#endif /* CHANGETRACKER_HPP_ */
Index: src/Parser/FormatParser.cpp
===================================================================
--- src/Parser/FormatParser.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Parser/FormatParser.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,59 @@
+/*
+ * FormatParser.cpp
+ *
+ *  Created on: Mar 1, 2010
+ *      Author: metzler
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "FormatParser.hpp"
+#include <iostream>
+
+using namespace std;
+
+/**
+ * Constructor.
+ */
+FormatParser::FormatParser() :
+  Observer("FormatParser")
+{
+  ChangeTracker::getInstance().signOn(this);
+  saveStream = NULL;
+}
+
+/**
+ * Destructor.
+ */
+FormatParser::~FormatParser() {
+  ChangeTracker::getInstance().signOff(this);
+}
+
+/**
+ * Update operation which can be invoked by the observable (which should be the
+ * change tracker here).
+ */
+void FormatParser::update(Observable *publisher) {
+  if (!saveStream) {
+    cerr << "Please invoke setOstream() so the parser knows where to save the World's data." << endl;
+    return;
+  }
+
+  save(saveStream);
+}
+
+/**
+ * The observable can tell when it dies.
+ */
+void FormatParser::subjectKilled(Observable *publisher) {}
+
+
+/**
+ * Sets the output stream for save, so the save() method can be invoked on update
+ * automatically.
+ *
+ * \param ostream where to save the World's state
+ */
+void FormatParser::setOstream(ostream* output) {
+  saveStream = output;
+}
Index: src/Parser/FormatParser.hpp
===================================================================
--- src/Parser/FormatParser.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Parser/FormatParser.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,32 @@
+/*
+ * FormatParser.hpp
+ *
+ *  Created on: Mar 1, 2010
+ *      Author: metzler
+ */
+
+#ifndef FORMATPARSER_HPP_
+#define FORMATPARSER_HPP_
+
+#include "Patterns/Observer.hpp"
+#include "ChangeTracker.hpp"
+#include "parser.hpp"
+
+/**
+ * General parser which observes the change tracker.
+ */
+class FormatParser : public Observer {
+public:
+  FormatParser();
+  virtual ~FormatParser();
+  virtual void save(std::ostream* file)=0;
+  virtual void load(std::istream* file)=0;
+  void setOstream(std::ostream* file);
+  void update(Observable *publisher);
+  void subjectKilled(Observable *publisher);
+
+private:
+  std::ostream* saveStream;
+};
+
+#endif /* FORMATPARSER_HPP_ */
Index: src/Parser/FormatParserStorage.cpp
===================================================================
--- src/Parser/FormatParserStorage.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Parser/FormatParserStorage.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,199 @@
+/** \file FormatParserStorage.cpp
+ *
+ *  date: Jun, 22 2010
+ *  author: heber
+ *
+ */
+
+#include <iostream>
+#include <fstream>
+
+#include "Parser/FormatParserStorage.hpp"
+
+#include "Parser/FormatParser.hpp"
+#include "Parser/MpqcParser.hpp"
+#include "Parser/PcpParser.hpp"
+#include "Parser/TremoloParser.hpp"
+#include "Parser/XyzParser.hpp"
+
+#include "log.hpp"
+#include "verbose.hpp"
+
+#include "Helpers/Assert.hpp"
+
+#include "Patterns/Singleton_impl.hpp"
+
+/** Increment operator for the enumeration ParserTypes to allow loops.
+ * \param &type value
+ * \return value incremented by one
+ */
+ParserTypes &operator++(ParserTypes &type)
+{
+  return type = ParserTypes(type+1);
+}
+
+/** Constructor of class FormatParserStorage.
+ */
+FormatParserStorage::FormatParserStorage()
+{
+  ParserList.resize(ParserTypes_end, NULL);
+  ParserStream.resize(ParserTypes_end, NULL);
+  ParserPresent.resize(ParserTypes_end, false);
+  ParserSuffix.resize(ParserTypes_end, "");
+
+  ParserSuffix[mpqc] = "in";
+  ParserSuffix[pcp] = "conf";
+  ParserSuffix[tremolo] = "data";
+  ParserSuffix[xyz] = "xyz";
+}
+
+/** Destructor of class FormatParserStorage.
+ * Free all stored FormatParsers. 
+ * Save on Exit.
+ */
+FormatParserStorage::~FormatParserStorage()
+{
+  for (ParserTypes iter = ParserTypes_begin; iter < ParserTypes_end; ++iter)
+    if (ParserPresent[iter]) {
+      if (ParserStream[iter]->is_open())
+        ParserStream[iter]->close();
+      delete ParserStream[iter];
+      delete ParserList[iter];
+    }
+}
+
+/** Sets the filename of all current parsers in storage to prefix.suffix.
+ * \param &prefix prefix to use.
+ */
+void FormatParserStorage::SetOutputPrefixForAll(std::string &_prefix)
+{
+  prefix=_prefix;
+};
+
+
+void FormatParserStorage::SaveAll()
+{
+  std::string filename;
+  for (ParserTypes iter = ParserTypes_begin; iter < ParserTypes_end; ++iter)
+    if (ParserPresent[iter]) {
+      filename = prefix;
+      filename += ".";
+      filename += ParserSuffix[iter];
+      ParserStream[iter] = new std::ofstream(filename.c_str());
+      ParserList[iter]->setOstream((std::ostream *)ParserStream[iter]);
+    }
+}
+
+
+/** Adds an MpqcParser to the storage.
+ */
+void FormatParserStorage::addMpqc()
+{
+  if (!ParserPresent[mpqc]) {
+    ParserList[mpqc] = dynamic_cast<FormatParser *>(new MpqcParser);
+    ParserPresent[mpqc] = true;
+  }
+  else
+    DoeLog(1) && (eLog() << Verbose(1) << "Parser mpqc is already present." << endl);
+}
+
+/** Adds an PcpParser to the storage.
+ */
+void FormatParserStorage::addPcp()
+{
+  if (!ParserPresent[pcp]) {
+    ParserList[pcp] = new PcpParser();
+    ParserPresent[pcp] = true;
+  } else
+    DoeLog(1) && (eLog() << Verbose(1) << "Parser pcp is already present." << endl);
+}
+
+
+/** Adds an TremoloParser to the storage.
+ */
+void FormatParserStorage::addTremolo()
+{
+  if (!ParserPresent[tremolo]) {
+    ParserList[tremolo] = new TremoloParser();
+    ParserPresent[tremolo] = true;
+  } else
+    DoeLog(1) && (eLog() << Verbose(1) << "Parser tremolo is already present." << endl);
+}
+
+
+/** Adds an XyzParser to the storage.
+ */
+void FormatParserStorage::addXyz()
+{
+  if (!ParserPresent[xyz]) {
+    ParserList[xyz] = new XyzParser();
+    ParserPresent[xyz] = true;
+  } else
+    DoeLog(1) && (eLog() << Verbose(1) << "Parser xyz is already present." << endl);
+}
+
+/** Parses an istream depending on its suffix
+ * \param &input input stream
+ * \param suffix
+ * \return true - parsing ok, false - suffix unknown
+ */
+bool FormatParserStorage::get(std::istream &input, std::string suffix)
+{
+  if (suffix == ParserSuffix[mpqc]) {
+    getMpqc().load(&input);
+  } else if (suffix == ParserSuffix[pcp]) {
+    getPcp().load(&input);
+  } else if (suffix == ParserSuffix[tremolo]) {
+    getTremolo().load(&input);
+  } else if (suffix == ParserSuffix[xyz]) {
+    getXyz().load(&input);
+  } else {
+    DoeLog(1) && (eLog() << Verbose(1) << "Unknown suffix to for FormatParserStorage::get()." << endl);
+    return false;
+  }
+  return true;
+}
+
+/** Returns reference to the output MpqcParser, adds if not present.
+ * \return reference to the output MpqcParser
+ */
+MpqcParser &FormatParserStorage::getMpqc()
+{
+  if (!ParserPresent[mpqc])
+    addMpqc();
+  return dynamic_cast<MpqcParser &>(*ParserList[mpqc]);
+}
+
+/** Returns reference to the output PcpParser, adds if not present.
+ * \return reference to the output PcpParser
+ */
+PcpParser &FormatParserStorage::getPcp()
+{
+  if (!ParserPresent[pcp])
+    addPcp();
+  return dynamic_cast<PcpParser &>(*ParserList[pcp]);
+}
+
+/** Returns reference to the output TremoloParser, adds if not present.
+ * \return reference to the output TremoloParser
+ */
+TremoloParser &FormatParserStorage::getTremolo()
+{
+  if (!ParserPresent[tremolo])
+    addTremolo();
+  return dynamic_cast<TremoloParser &>(*ParserList[tremolo]);
+}
+
+/** Returns reference to the output XyzParser, adds if not present.
+ * \return reference to the output XyzParser
+ */
+XyzParser &FormatParserStorage::getXyz()
+{
+  if (!ParserPresent[xyz])
+    addXyz();
+  return dynamic_cast<XyzParser &>(*ParserList[xyz]);
+}
+
+
+
+CONSTRUCT_SINGLETON(FormatParserStorage)
Index: src/Parser/FormatParserStorage.hpp
===================================================================
--- src/Parser/FormatParserStorage.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Parser/FormatParserStorage.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,73 @@
+/** \file FormatParserStorage.hpp
+ *
+ *  date: Jun, 22 2010
+ *  author: heber
+ *
+ */
+
+#ifndef FORMATPARSERSTORAGE_HPP_
+#define FORMATPARSERSTORAGE_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Patterns/Singleton.hpp"
+
+#include <string>
+#include <vector>
+
+class FormatParser;
+class MpqcParser;
+class PcpParser;
+class TremoloParser;
+class XyzParser;
+
+// enum has to be outside of class for operator++ to be possible
+enum ParserTypes { mpqc, pcp, tremolo, xyz, ParserTypes_end, ParserTypes_begin = mpqc };
+typedef enum ParserTypes ParserTypes;
+
+ParserTypes &operator++(ParserTypes &type);
+
+class FormatParserStorage : public Singleton<FormatParserStorage> {
+  friend class Singleton<FormatParserStorage>;
+public:
+
+
+  void addMpqc();
+  void addPcp();
+  void addTremolo();
+  void addXyz();
+
+  bool get(std::istream &input, std::string suffix);
+  MpqcParser &getMpqc();
+  PcpParser &getPcp();
+  TremoloParser &getTremolo();
+  XyzParser &getXyz();
+
+  void SetOutputPrefixForAll(std::string &_prefix);
+  void SaveAll();
+
+private:
+  // private constructors as this is a singleton
+  FormatParserStorage();
+  ~FormatParserStorage();
+  
+  // list of allocated parsers
+  std::vector<FormatParser *> ParserList;
+
+  // list of allocated strams
+  std::vector<std::ofstream *> ParserStream;
+
+  // which parser is already present
+  std::vector<bool> ParserPresent;
+
+  // default suffix of each parser type
+  std::vector<std::string> ParserSuffix;
+
+  // prefix of the filenames to use on save
+  std::string prefix;
+};
+
+#endif // FORMATPARSERSTORAGE_HPP_
Index: src/Parser/MpqcParser.cpp
===================================================================
--- src/Parser/MpqcParser.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Parser/MpqcParser.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,152 @@
+/*
+ * MpqcParser.cpp
+ *
+ *  Created on: 12.06.2010
+ *      Author: heber
+ */
+
+#include "MpqcParser.hpp"
+
+#include "atom.hpp"
+#include "config.hpp"
+#include "element.hpp"
+#include "log.hpp"
+#include "periodentafel.hpp"
+#include "vector.hpp"
+#include "verbose.hpp"
+#include "World.hpp"
+
+
+/** Constructor of MpqcParser.
+ *
+ */
+MpqcParser::MpqcParser() : HessianPresent(false)
+{
+
+}
+
+/** Destructor of MpqcParser.
+ *
+ */
+MpqcParser::~MpqcParser() {
+
+}
+
+/** Load an MPQC config file into the World.
+ * \param *file input stream
+ */
+void MpqcParser::load(istream *file)
+{
+  DoeLog(0) && (Log() << Verbose(0) << "Not yet implemented" << endl) ;
+}
+
+void MpqcParser::save(ostream *file)
+{
+  if (HessianPresent)
+    saveHessian(file);
+  else
+    saveSimple(file);
+}
+
+/** Saves all atoms and data into a MPQC config file without hessian.
+ * \param *file output stream
+ */
+void MpqcParser::saveSimple(ostream *file)
+{
+  int AtomNo = 0;
+  Vector center;
+  vector<atom *> allatoms = World::getInstance().getAllAtoms();
+
+  // calculate center
+  for (vector<atom *>::iterator runner = allatoms.begin();runner != allatoms.end(); ++runner)
+    center += (*runner)->x;
+  center.Scale(1./allatoms.size());
+
+  // first without hessian
+  if (file->fail()) {
+    DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open mpqc output file." << endl);
+  } else {
+    *file << "% Created by MoleCuilder" << endl;
+    *file << "mpqc: (" << endl;
+    *file << "\tsavestate = no" << endl;
+    *file << "\tdo_gradient = yes" << endl;
+    *file << "\tmole<MBPT2>: (" << endl;
+    *file << "\t\tmaxiter = 200" << endl;
+    *file << "\t\tbasis = $:basis" << endl;
+    *file << "\t\tmolecule = $:molecule" << endl;
+    *file << "\t\treference<CLHF>: (" << endl;
+    *file << "\t\t\tbasis = $:basis" << endl;
+    *file << "\t\t\tmolecule = $:molecule" << endl;
+    *file << "\t\t)" << endl;
+    *file << "\t)" << endl;
+    *file << ")" << endl;
+    *file << "molecule<Molecule>: (" << endl;
+    *file << "\tunit = " << (World::getInstance().getConfig()->GetIsAngstroem() ? "angstrom" : "bohr" ) << endl;
+    *file << "\t{ atoms geometry } = {" << endl;
+    // output of atoms
+    for (vector<atom *>::iterator AtomRunner = allatoms.begin(); AtomRunner != allatoms.end(); ++AtomRunner) {
+      (*AtomRunner)->OutputMPQCLine(file, &center, &AtomNo);
+    }
+    *file << "\t}" << endl;
+    *file << ")" << endl;
+    *file << "basis<GaussianBasisSet>: (" << endl;
+    *file << "\tname = \"" << World::getInstance().getConfig()->basis << "\"" << endl;
+    *file << "\tmolecule = $:molecule" << endl;
+    *file << ")" << endl;
+  }
+}
+
+/** Saves all atoms and data into a MPQC config file with hessian.
+ * \param *file output stream
+ */
+void MpqcParser::saveHessian(ostream *file)
+{
+  int AtomNo = 0;
+  Vector center;
+  vector<atom *> allatoms = World::getInstance().getAllAtoms();
+
+  // calculate center
+  for (vector<atom *>::iterator runner = allatoms.begin();runner != allatoms.end(); ++runner)
+    center += (*runner)->x;
+  center.Scale(1./allatoms.size());
+
+  // with hessian
+  if (file->fail()) {
+    DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open mpqc output file." << endl);
+  } else {
+    *file << "% Created by MoleCuilder" << endl;
+    *file << "mpqc: (" << endl;
+    *file << "\tsavestate = no" << endl;
+    *file << "\tdo_gradient = yes" << endl;
+    *file << "\tmole<CLHF>: (" << endl;
+    *file << "\t\tmaxiter = 200" << endl;
+    *file << "\t\tbasis = $:basis" << endl;
+    *file << "\t\tmolecule = $:molecule" << endl;
+    *file << "\t)" << endl;
+    *file << "\tfreq<MolecularFrequencies>: (" << endl;
+    *file << "\t\tmolecule=$:molecule" << endl;
+    *file << "\t)" << endl;
+    *file << ")" << endl;
+    *file << "molecule<Molecule>: (" << endl;
+    *file << "\tunit = " << (World::getInstance().getConfig()->GetIsAngstroem() ? "angstrom" : "bohr" ) << endl;
+    *file << "\t{ atoms geometry } = {" << endl;
+    // output of atoms
+    for (vector<atom *>::iterator AtomRunner = allatoms.begin(); AtomRunner != allatoms.end(); ++AtomRunner) {
+      (*AtomRunner)->OutputMPQCLine(file, &center, &AtomNo);
+    }
+    *file << "\t}" << endl;
+    *file << ")" << endl;
+    *file << "basis<GaussianBasisSet>: (" << endl;
+    *file << "\tname = \"" << World::getInstance().getConfig()->basis << "\"" << endl;
+    *file << "\tmolecule = $:molecule" << endl;
+    *file << ")" << endl;
+  }
+}
+
+/** Sets whether hessian is desired or not
+ * \param hessian statement
+ */
+void MpqcParser::setHessian(bool hessian)
+{
+  HessianPresent = hessian;
+}
Index: src/Parser/MpqcParser.hpp
===================================================================
--- src/Parser/MpqcParser.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Parser/MpqcParser.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,36 @@
+/*
+ * MpqcParser.hpp
+ *
+ *  Created on: 12.06.2010
+ *      Author: heber
+ */
+
+#ifndef MPQCPARSER_HPP_
+#define MPQCPARSER_HPP_
+
+#include "FormatParser.hpp"
+
+#include <iostream>
+
+/**
+ * Loads a MPQC config file into the World and saves the World as a tremolo file.
+ */
+class MpqcParser : public FormatParser
+{
+public:
+  MpqcParser();
+  ~MpqcParser();
+  void load(std::istream* file);
+  void save(std::ostream* file);
+
+  void setHessian(bool hessian);
+
+private:
+  // whether output with computing hessian is desired.
+  bool HessianPresent;
+
+  void saveSimple(std::ostream *file);
+  void saveHessian(std::ostream *file);
+};
+
+#endif /* MPQCPARSER_HPP_ */
Index: src/Parser/PcpParser.cpp
===================================================================
--- src/Parser/PcpParser.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Parser/PcpParser.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,685 @@
+/*
+ * PcpParser.cpp
+ *
+ *  Created on: 12.06.2010
+ *      Author: heber
+ */
+
+#include <iostream>
+
+#include "atom.hpp"
+#include "config.hpp"
+#include "ConfigFileBuffer.hpp"
+#include "element.hpp"
+#include "Helpers/Assert.hpp"
+#include "log.hpp"
+#include "molecule.hpp"
+#include "PcpParser.hpp"
+#include "periodentafel.hpp"
+#include "ThermoStatContainer.hpp"
+#include "verbose.hpp"
+#include "World.hpp"
+
+/** 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;
+}
+
+/** Destructor of PcpParser.
+ *
+ */
+PcpParser::~PcpParser()
+{}
+
+void PcpParser::load(std::istream* file)
+{
+  if (file->fail()) {
+    DoeLog(1) && (eLog()<< Verbose(1) << "could not access given file" << endl);
+    return;
+  }
+
+  // ParseParameterFile
+  class ConfigFileBuffer *FileBuffer = new ConfigFileBuffer();
+  FileBuffer->InitFileBuffer(file);
+
+  /* Oeffne Hauptparameterdatei */
+  int di = 0;
+  double BoxLength[9];
+  string zeile;
+  string dummy;
+  int verbose = 0;
+
+  ParseThermostats(FileBuffer);
+
+  /* Namen einlesen */
+
+  // 1. parse in options
+  ParseForParameter(verbose,FileBuffer, "mainname", 0, 1, 1, string_type, (Paths.mainname), 1, critical);
+  ParseForParameter(verbose,FileBuffer, "defaultpath", 0, 1, 1, string_type, (Paths.defaultpath), 1, critical);
+  ParseForParameter(verbose,FileBuffer, "pseudopotpath", 0, 1, 1, string_type, (Paths.pseudopotpath), 1, critical);
+  ParseForParameter(verbose,FileBuffer,"ProcPEGamma", 0, 1, 1, int_type, &(Parallelization.ProcPEGamma), 1, critical);
+  ParseForParameter(verbose,FileBuffer,"ProcPEPsi", 0, 1, 1, int_type, &(Parallelization.ProcPEPsi), 1, critical);
+
+  if (!ParseForParameter(verbose,FileBuffer,"Seed", 0, 1, 1, int_type, &(LocalizedOrbitals.Seed), 1, optional))
+    LocalizedOrbitals.Seed = 1;
+
+  if(!ParseForParameter(verbose,FileBuffer,"DoOutOrbitals", 0, 1, 1, int_type, &(Switches.DoOutOrbitals), 1, optional)) {
+    Switches.DoOutOrbitals = 0;
+  } else {
+    if (Switches.DoOutOrbitals < 0) Switches.DoOutOrbitals = 0;
+    if (Switches.DoOutOrbitals > 1) Switches.DoOutOrbitals = 1;
+  }
+  ParseForParameter(verbose,FileBuffer,"DoOutVis", 0, 1, 1, int_type, &(Switches.DoOutVis), 1, critical);
+  if (Switches.DoOutVis < 0) Switches.DoOutVis = 0;
+  if (Switches.DoOutVis > 1) Switches.DoOutVis = 1;
+  if (!ParseForParameter(verbose,FileBuffer,"VectorPlane", 0, 1, 1, int_type, &(LocalizedOrbitals.VectorPlane), 1, optional))
+    LocalizedOrbitals.VectorPlane = -1;
+  if (!ParseForParameter(verbose,FileBuffer,"VectorCut", 0, 1, 1, double_type, &(LocalizedOrbitals.VectorCut), 1, optional))
+    LocalizedOrbitals.VectorCut = 0.;
+  ParseForParameter(verbose,FileBuffer,"DoOutMes", 0, 1, 1, int_type, &(Switches.DoOutMes), 1, critical);
+  if (Switches.DoOutMes < 0) Switches.DoOutMes = 0;
+  if (Switches.DoOutMes > 1) Switches.DoOutMes = 1;
+  if (!ParseForParameter(verbose,FileBuffer,"DoOutCurr", 0, 1, 1, int_type, &(Switches.DoOutCurrent), 1, optional))
+    Switches.DoOutCurrent = 0;
+  if (Switches.DoOutCurrent < 0) Switches.DoOutCurrent = 0;
+  if (Switches.DoOutCurrent > 1) Switches.DoOutCurrent = 1;
+  ParseForParameter(verbose,FileBuffer,"AddGramSch", 0, 1, 1, int_type, &(LocalizedOrbitals.UseAddGramSch), 1, critical);
+  if (LocalizedOrbitals.UseAddGramSch < 0) LocalizedOrbitals.UseAddGramSch = 0;
+  if (LocalizedOrbitals.UseAddGramSch > 2) LocalizedOrbitals.UseAddGramSch = 2;
+  if(!ParseForParameter(verbose,FileBuffer,"DoWannier", 0, 1, 1, int_type, &(Switches.DoWannier), 1, optional)) {
+    Switches.DoWannier = 0;
+  } else {
+    if (Switches.DoWannier < 0) Switches.DoWannier = 0;
+    if (Switches.DoWannier > 1) Switches.DoWannier = 1;
+  }
+  if(!ParseForParameter(verbose,FileBuffer,"CommonWannier", 0, 1, 1, int_type, &(LocalizedOrbitals.CommonWannier), 1, optional)) {
+    LocalizedOrbitals.CommonWannier = 0;
+  } else {
+    if (LocalizedOrbitals.CommonWannier < 0) LocalizedOrbitals.CommonWannier = 0;
+    if (LocalizedOrbitals.CommonWannier > 4) LocalizedOrbitals.CommonWannier = 4;
+  }
+  if(!ParseForParameter(verbose,FileBuffer,"SawtoothStart", 0, 1, 1, double_type, &(LocalizedOrbitals.SawtoothStart), 1, optional)) {
+    LocalizedOrbitals.SawtoothStart = 0.01;
+  } else {
+    if (LocalizedOrbitals.SawtoothStart < 0.) LocalizedOrbitals.SawtoothStart = 0.;
+    if (LocalizedOrbitals.SawtoothStart > 1.) LocalizedOrbitals.SawtoothStart = 1.;
+  }
+
+  if (ParseForParameter(verbose,FileBuffer,"DoConstrainedMD", 0, 1, 1, int_type, &(Switches.DoConstrainedMD), 1, optional))
+    if (Switches.DoConstrainedMD < 0)
+      Switches.DoConstrainedMD = 0;
+  ParseForParameter(verbose,FileBuffer,"MaxOuterStep", 0, 1, 1, int_type, &(StepCounts.MaxOuterStep), 1, critical);
+  if (!ParseForParameter(verbose,FileBuffer,"Deltat", 0, 1, 1, double_type, &(Deltat), 1, optional))
+    Deltat = 1;
+  ParseForParameter(verbose,FileBuffer,"OutVisStep", 0, 1, 1, int_type, &(StepCounts.OutVisStep), 1, optional);
+  ParseForParameter(verbose,FileBuffer,"OutSrcStep", 0, 1, 1, int_type, &(StepCounts.OutSrcStep), 1, optional);
+  ParseForParameter(verbose,FileBuffer,"TargetTemp", 0, 1, 1, double_type, &(World::getInstance().getThermostats()->TargetTemp), 1, optional);
+  //ParseForParameter(verbose,FileBuffer,"Thermostat", 0, 1, 1, int_type, &(ScaleTempStep), 1, optional);
+  if (!ParseForParameter(verbose,FileBuffer,"EpsWannier", 0, 1, 1, double_type, &(LocalizedOrbitals.EpsWannier), 1, optional))
+    LocalizedOrbitals.EpsWannier = 1e-8;
+
+  // stop conditions
+  //if (MaxOuterStep <= 0) MaxOuterStep = 1;
+  ParseForParameter(verbose,FileBuffer,"MaxPsiStep", 0, 1, 1, int_type, &(StepCounts.MaxPsiStep), 1, critical);
+  if (StepCounts.MaxPsiStep <= 0) StepCounts.MaxPsiStep = 3;
+
+  ParseForParameter(verbose,FileBuffer,"MaxMinStep", 0, 1, 1, int_type, &(StepCounts.MaxMinStep), 1, critical);
+  ParseForParameter(verbose,FileBuffer,"RelEpsTotalE", 0, 1, 1, double_type, &(StepCounts.RelEpsTotalEnergy), 1, critical);
+  ParseForParameter(verbose,FileBuffer,"RelEpsKineticE", 0, 1, 1, double_type, &(StepCounts.RelEpsKineticEnergy), 1, critical);
+  ParseForParameter(verbose,FileBuffer,"MaxMinStopStep", 0, 1, 1, int_type, &(StepCounts.MaxMinStopStep), 1, critical);
+  ParseForParameter(verbose,FileBuffer,"MaxMinGapStopStep", 0, 1, 1, int_type, &(StepCounts.MaxMinGapStopStep), 1, critical);
+  if (StepCounts.MaxMinStep <= 0) StepCounts.MaxMinStep = StepCounts.MaxPsiStep;
+  if (StepCounts.MaxMinStopStep < 1) StepCounts.MaxMinStopStep = 1;
+  if (StepCounts.MaxMinGapStopStep < 1) StepCounts.MaxMinGapStopStep = 1;
+
+  ParseForParameter(verbose,FileBuffer,"MaxInitMinStep", 0, 1, 1, int_type, &(StepCounts.MaxInitMinStep), 1, critical);
+  ParseForParameter(verbose,FileBuffer,"InitRelEpsTotalE", 0, 1, 1, double_type, &(StepCounts.InitRelEpsTotalEnergy), 1, critical);
+  ParseForParameter(verbose,FileBuffer,"InitRelEpsKineticE", 0, 1, 1, double_type, &(StepCounts.InitRelEpsKineticEnergy), 1, critical);
+  ParseForParameter(verbose,FileBuffer,"InitMaxMinStopStep", 0, 1, 1, int_type, &(StepCounts.InitMaxMinStopStep), 1, critical);
+  ParseForParameter(verbose,FileBuffer,"InitMaxMinGapStopStep", 0, 1, 1, int_type, &(StepCounts.InitMaxMinGapStopStep), 1, critical);
+  if (StepCounts.MaxInitMinStep <= 0) StepCounts.MaxInitMinStep = StepCounts.MaxPsiStep;
+  if (StepCounts.InitMaxMinStopStep < 1) StepCounts.InitMaxMinStopStep = 1;
+  if (StepCounts.InitMaxMinGapStopStep < 1) StepCounts.InitMaxMinGapStopStep = 1;
+
+  // 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();
+  cell_size[0] = BoxLength[0];
+  cell_size[1] = BoxLength[3];
+  cell_size[2] = BoxLength[4];
+  cell_size[3] = BoxLength[6];
+  cell_size[4] = BoxLength[7];
+  cell_size[5] = BoxLength[8];
+  //if (1) fprintf(stderr,"\n");
+
+  ParseForParameter(verbose,FileBuffer,"DoPerturbation", 0, 1, 1, int_type, &(Switches.DoPerturbation), 1, optional);
+  ParseForParameter(verbose,FileBuffer,"DoOutNICS", 0, 1, 1, int_type, &(Switches.DoOutNICS), 1, optional);
+  if (!ParseForParameter(verbose,FileBuffer,"DoFullCurrent", 0, 1, 1, int_type, &(Switches.DoFullCurrent), 1, optional))
+    Switches.DoFullCurrent = 0;
+  if (Switches.DoFullCurrent < 0) Switches.DoFullCurrent = 0;
+  if (Switches.DoFullCurrent > 2) Switches.DoFullCurrent = 2;
+  if (Switches.DoOutNICS < 0) Switches.DoOutNICS = 0;
+  if (Switches.DoOutNICS > 2) Switches.DoOutNICS = 2;
+  if (Switches.DoPerturbation == 0) {
+    Switches.DoFullCurrent = 0;
+    Switches.DoOutNICS = 0;
+  }
+
+  ParseForParameter(verbose,FileBuffer,"ECut", 0, 1, 1, double_type, &(PlaneWaveSpecifics.ECut), 1, critical);
+  ParseForParameter(verbose,FileBuffer,"MaxLevel", 0, 1, 1, int_type, &(PlaneWaveSpecifics.MaxLevel), 1, critical);
+  ParseForParameter(verbose,FileBuffer,"Level0Factor", 0, 1, 1, int_type, &(PlaneWaveSpecifics.Lev0Factor), 1, critical);
+  if (PlaneWaveSpecifics.Lev0Factor < 2) {
+    PlaneWaveSpecifics.Lev0Factor = 2;
+  }
+  ParseForParameter(verbose,FileBuffer,"RiemannTensor", 0, 1, 1, int_type, &di, 1, critical);
+  if (di >= 0 && di < 2) {
+    PlaneWaveSpecifics.RiemannTensor = di;
+  } else {
+    cerr << "0 <= RiemanTensor < 2: 0 UseNotRT, 1 UseRT" << endl;
+    exit(1);
+  }
+  switch (PlaneWaveSpecifics.RiemannTensor) {
+    case 0: //UseNoRT
+      if (PlaneWaveSpecifics.MaxLevel < 2) {
+        PlaneWaveSpecifics.MaxLevel = 2;
+      }
+      PlaneWaveSpecifics.LevRFactor = 2;
+      PlaneWaveSpecifics.RTActualUse = 0;
+      break;
+    case 1: // UseRT
+      if (PlaneWaveSpecifics.MaxLevel < 3) {
+        PlaneWaveSpecifics.MaxLevel = 3;
+      }
+      ParseForParameter(verbose,FileBuffer,"RiemannLevel", 0, 1, 1, int_type, &(PlaneWaveSpecifics.RiemannLevel), 1, critical);
+      if (PlaneWaveSpecifics.RiemannLevel < 2) {
+        PlaneWaveSpecifics.RiemannLevel = 2;
+      }
+      if (PlaneWaveSpecifics.RiemannLevel > PlaneWaveSpecifics.MaxLevel-1) {
+        PlaneWaveSpecifics.RiemannLevel = PlaneWaveSpecifics.MaxLevel-1;
+      }
+      ParseForParameter(verbose,FileBuffer,"LevRFactor", 0, 1, 1, int_type, &(PlaneWaveSpecifics.LevRFactor), 1, critical);
+      if (PlaneWaveSpecifics.LevRFactor < 2) {
+        PlaneWaveSpecifics.LevRFactor = 2;
+      }
+      PlaneWaveSpecifics.Lev0Factor = 2;
+      PlaneWaveSpecifics.RTActualUse = 2;
+      break;
+  }
+  ParseForParameter(verbose,FileBuffer,"PsiType", 0, 1, 1, int_type, &di, 1, critical);
+  if (di >= 0 && di < 2) {
+    PlaneWaveSpecifics.PsiType = di;
+  } else {
+    cerr << "0 <= PsiType < 2: 0 UseSpinDouble, 1 UseSpinUpDown" << endl;
+    exit(1);
+  }
+  switch (PlaneWaveSpecifics.PsiType) {
+  case 0: // SpinDouble
+    ParseForParameter(verbose,FileBuffer,"MaxPsiDouble", 0, 1, 1, int_type, &(PlaneWaveSpecifics.MaxPsiDouble), 1, critical);
+    ParseForParameter(verbose,FileBuffer,"PsiMaxNoUp", 0, 1, 1, int_type, &(PlaneWaveSpecifics.PsiMaxNoUp), 1, optional);
+    ParseForParameter(verbose,FileBuffer,"PsiMaxNoDown", 0, 1, 1, int_type, &(PlaneWaveSpecifics.PsiMaxNoDown), 1, optional);
+    ParseForParameter(verbose,FileBuffer,"AddPsis", 0, 1, 1, int_type, &(PlaneWaveSpecifics.AddPsis), 1, optional);
+    break;
+  case 1: // SpinUpDown
+    if (Parallelization.ProcPEGamma % 2) Parallelization.ProcPEGamma*=2;
+    ParseForParameter(verbose,FileBuffer,"MaxPsiDouble", 0, 1, 1, int_type, &(PlaneWaveSpecifics.MaxPsiDouble), 1, optional);
+    ParseForParameter(verbose,FileBuffer,"PsiMaxNoUp", 0, 1, 1, int_type, &(PlaneWaveSpecifics.PsiMaxNoUp), 1, critical);
+    ParseForParameter(verbose,FileBuffer,"PsiMaxNoDown", 0, 1, 1, int_type, &(PlaneWaveSpecifics.PsiMaxNoDown), 1, critical);
+    ParseForParameter(verbose,FileBuffer,"AddPsis", 0, 1, 1, int_type, &(PlaneWaveSpecifics.AddPsis), 1, optional);
+    break;
+  }
+
+  // IonsInitRead
+
+  ParseForParameter(verbose,FileBuffer,"RCut", 0, 1, 1, double_type, &(PlaneWaveSpecifics.RCut), 1, critical);
+  ParseForParameter(verbose,FileBuffer,"IsAngstroem", 0, 1, 1, int_type, &(IsAngstroem), 1, critical);
+  ParseForParameter(verbose,FileBuffer,"MaxTypes", 0, 1, 1, int_type, &(MaxTypes), 1, critical);
+  if (!ParseForParameter(verbose,FileBuffer,"RelativeCoord", 0, 1, 1, int_type, &(RelativeCoord) , 1, optional))
+    RelativeCoord = 0;
+  if (!ParseForParameter(verbose,FileBuffer,"StructOpt", 0, 1, 1, int_type, &(StructOpt), 1, optional))
+    StructOpt = 0;
+
+  // 3. parse the molecule in
+  molecule *mol = World::getInstance().createMolecule();
+  MoleculeListClass *molecules = World::getInstance().getMolecules();
+  molecules->insert(mol);
+  LoadMolecule(mol, FileBuffer, World::getInstance().getPeriode(), FastParsing);
+  //mol->SetNameFromFilename(filename);
+  mol->ActiveFlag = true;
+  //MolList->insert(mol);
+
+  // 4. dissect the molecule into connected subgraphs
+  // don't do this here ...
+  //MolList->DissectMoleculeIntoConnectedSubgraphs(mol,this);
+  //delete(mol);
+
+  delete(FileBuffer);
+}
+
+/** Saves the World into a PCP config file.
+ * \param *file output stream to save to
+ */
+void PcpParser::save(std::ostream* file)
+{
+  const double * const cell_size = World::getInstance().getDomain();
+  class ThermoStatContainer *Thermostats = World::getInstance().getThermostats();
+  if (!file->fail()) {
+    // calculate number of Psis
+    vector<atom *> allatoms = World::getInstance().getAllAtoms();
+    CalculateOrbitals(allatoms);
+    *file << "# ParallelCarParinello - main configuration file - created with molecuilder" << endl;
+    *file << endl;
+    if (Paths.mainname != NULL)
+      *file << "mainname\t" << Paths.mainname << "\t# programm name (for runtime files)" << endl;
+    else
+      *file << "mainname\tpcp\t# programm name (for runtime files)" << endl;
+    if (Paths.defaultpath != NULL)
+      *file << "defaultpath\t" << Paths.defaultpath << "\t# where to put files during runtime" << endl;
+    else
+      *file << "defaultpath\tnot specified\t# where to put files during runtime" << endl;
+    if (Paths.pseudopotpath != NULL)
+      *file << "pseudopotpath\t" << Paths.pseudopotpath << "\t# where to find pseudopotentials" << endl;
+    else
+      *file << "pseudopotpath\tnot specified\t# where to find pseudopotentials" << endl;
+    *file << endl;
+    *file << "ProcPEGamma\t" << Parallelization.ProcPEGamma << "\t# for parallel computing: share constants" << endl;
+    *file << "ProcPEPsi\t" << Parallelization.ProcPEPsi << "\t# for parallel computing: share wave functions" << endl;
+    *file << "DoOutVis\t" << Switches.DoOutVis << "\t# Output data for OpenDX" << endl;
+    *file << "DoOutMes\t" << Switches.DoOutMes << "\t# Output data for measurements" << endl;
+    *file << "DoOutOrbitals\t" << Switches.DoOutOrbitals << "\t# Output all Orbitals" << endl;
+    *file << "DoOutCurr\t" << Switches.DoOutCurrent << "\t# Ouput current density for OpenDx" << endl;
+    *file << "DoOutNICS\t" << Switches.DoOutNICS << "\t# Output Nucleus independent current shieldings" << endl;
+    *file << "DoPerturbation\t" << Switches.DoPerturbation << "\t# Do perturbation calculate and determine susceptibility and shielding" << endl;
+    *file << "DoFullCurrent\t" << Switches.DoFullCurrent << "\t# Do full perturbation" << endl;
+    *file << "DoConstrainedMD\t" << Switches.DoConstrainedMD << "\t# Do perform a constrained (>0, relating to current MD step) instead of unconstrained (0) MD" << endl;
+    ASSERT(Thermostats != NULL, "PcpParser::save() - Thermostats not initialized!");
+    ASSERT(Thermostats->ThermostatNames != NULL, "PcpParser::save() - Thermostats not initialized!");
+    *file << "Thermostat\t" << Thermostats->ThermostatNames[Thermostats->Thermostat] << "\t";
+    switch(Thermostats->Thermostat) {
+      default:
+      case None:
+        break;
+      case Woodcock:
+        *file << Thermostats->ScaleTempStep;
+        break;
+      case Gaussian:
+        *file << Thermostats->ScaleTempStep;
+        break;
+      case Langevin:
+        *file << Thermostats->TempFrequency << "\t" << Thermostats->alpha;
+        break;
+      case Berendsen:
+        *file << Thermostats->TempFrequency;
+        break;
+      case NoseHoover:
+        *file << Thermostats->HooverMass;
+        break;
+    };
+    *file << "\t# Which Thermostat and its parameters to use in MD case." << endl;
+    *file << "CommonWannier\t" << LocalizedOrbitals.CommonWannier << "\t# Put virtual centers at indivual orbits, all common, merged by variance, to grid point, to cell center" << endl;
+    *file << "SawtoothStart\t" << LocalizedOrbitals.SawtoothStart << "\t# Absolute value for smooth transition at cell border " << endl;
+    *file << "VectorPlane\t" << LocalizedOrbitals.VectorPlane << "\t# Cut plane axis (x, y or z: 0,1,2) for two-dim current vector plot" << endl;
+    *file << "VectorCut\t" << LocalizedOrbitals.VectorCut << "\t# Cut plane axis value" << endl;
+    *file << "AddGramSch\t" << LocalizedOrbitals.UseAddGramSch << "\t# Additional GramSchmidtOrtogonalization to be safe" << endl;
+    *file << "Seed\t\t" << LocalizedOrbitals.Seed << "\t# initial value for random seed for Psi coefficients" << endl;
+    *file << endl;
+    *file << "MaxOuterStep\t" << StepCounts.MaxOuterStep << "\t# number of MolecularDynamics/Structure optimization steps" << endl;
+    *file << "Deltat\t" << Deltat << "\t# time per MD step" << endl;
+    *file << "OutVisStep\t" << StepCounts.OutVisStep << "\t# Output visual data every ...th step" << endl;
+    *file << "OutSrcStep\t" << StepCounts.OutSrcStep << "\t# Output \"restart\" data every ..th step" << endl;
+    *file << "TargetTemp\t" << Thermostats->TargetTemp << "\t# Target temperature" << endl;
+    *file << "MaxPsiStep\t" << StepCounts.MaxPsiStep << "\t# number of Minimisation steps per state (0 - default)" << endl;
+    *file << "EpsWannier\t" << LocalizedOrbitals.EpsWannier << "\t# tolerance value for spread minimisation of orbitals" << endl;
+    *file << endl;
+    *file << "# Values specifying when to stop" << endl;
+    *file << "MaxMinStep\t" << StepCounts.MaxMinStep << "\t# Maximum number of steps" << endl;
+    *file << "RelEpsTotalE\t" << StepCounts.RelEpsTotalEnergy << "\t# relative change in total energy" << endl;
+    *file << "RelEpsKineticE\t" << StepCounts.RelEpsKineticEnergy << "\t# relative change in kinetic energy" << endl;
+    *file << "MaxMinStopStep\t" << StepCounts.MaxMinStopStep << "\t# check every ..th steps" << endl;
+    *file << "MaxMinGapStopStep\t" << StepCounts.MaxMinGapStopStep << "\t# check every ..th steps" << endl;
+    *file << endl;
+    *file << "# Values specifying when to stop for INIT, otherwise same as above" << endl;
+    *file << "MaxInitMinStep\t" << StepCounts.MaxInitMinStep << "\t# Maximum number of steps" << endl;
+    *file << "InitRelEpsTotalE\t" << StepCounts.InitRelEpsTotalEnergy << "\t# relative change in total energy" << endl;
+    *file << "InitRelEpsKineticE\t" << StepCounts.InitRelEpsKineticEnergy << "\t# relative change in kinetic energy" << endl;
+    *file << "InitMaxMinStopStep\t" << StepCounts.InitMaxMinStopStep << "\t# check every ..th steps" << endl;
+    *file << "InitMaxMinGapStopStep\t" << StepCounts.InitMaxMinGapStopStep << "\t# check every ..th steps" << endl;
+    *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;
+    // FIXME
+    *file << endl;
+    *file << "ECut\t\t" << PlaneWaveSpecifics.ECut << "\t# energy cutoff for discretization in Hartrees" << endl;
+    *file << "MaxLevel\t" << PlaneWaveSpecifics.MaxLevel << "\t# number of different levels in the code, >=2" << endl;
+    *file << "Level0Factor\t" << PlaneWaveSpecifics.Lev0Factor << "\t# factor by which node number increases from S to 0 level" << endl;
+    *file << "RiemannTensor\t" << PlaneWaveSpecifics.RiemannTensor << "\t# (Use metric)" << endl;
+    switch (PlaneWaveSpecifics.RiemannTensor) {
+      case 0: //UseNoRT
+        break;
+      case 1: // UseRT
+        *file << "RiemannLevel\t" << PlaneWaveSpecifics.RiemannLevel << "\t# Number of Riemann Levels" << endl;
+        *file << "LevRFactor\t" << PlaneWaveSpecifics.LevRFactor << "\t# factor by which node number increases from 0 to R level from" << endl;
+        break;
+    }
+    *file << "PsiType\t\t" << PlaneWaveSpecifics.PsiType << "\t# 0 - doubly occupied, 1 - SpinUp,SpinDown" << endl;
+    *file << "MaxPsiDouble\t" << PlaneWaveSpecifics.MaxPsiDouble << "\t# here: specifying both maximum number of SpinUp- and -Down-states" << endl;
+    *file << "PsiMaxNoUp\t" << PlaneWaveSpecifics.PsiMaxNoUp << "\t# here: specifying maximum number of SpinUp-states" << endl;
+    *file << "PsiMaxNoDown\t" << PlaneWaveSpecifics.PsiMaxNoDown << "\t# here: specifying maximum number of SpinDown-states" << endl;
+    *file << "AddPsis\t\t" << PlaneWaveSpecifics.AddPsis << "\t# Additional unoccupied Psis for bandgap determination" << endl;
+    *file << endl;
+    *file << "RCut\t\t" << PlaneWaveSpecifics.RCut << "\t# R-cut for the ewald summation" << endl;
+    *file << "StructOpt\t" << StructOpt << "\t# Do structure optimization beforehand" << endl;
+    *file << "IsAngstroem\t" << IsAngstroem << "\t# 0 - Bohr, 1 - Angstroem" << endl;
+    *file << "RelativeCoord\t" << RelativeCoord << "\t# whether ion coordinates are relative (1) or absolute (0)" << endl;
+    map<int, int> ZtoIndexMap;
+    OutputElements(file, allatoms, ZtoIndexMap);
+    OutputAtoms(file, allatoms, ZtoIndexMap);
+  } else {
+    DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open output file." << endl);
+  }
+}
+
+
+/** Counts necessary number of valence electrons and returns number and SpinType.
+ * \param &allatoms all atoms to store away
+ */
+void PcpParser::CalculateOrbitals(vector<atom *> &allatoms)
+{
+  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;
+  }
+  cout << PlaneWaveSpecifics.MaxPsiDouble << endl;
+  PlaneWaveSpecifics.PsiMaxNoDown = PlaneWaveSpecifics.MaxPsiDouble/2 + (PlaneWaveSpecifics.MaxPsiDouble % 2);
+  PlaneWaveSpecifics.PsiMaxNoUp = PlaneWaveSpecifics.MaxPsiDouble/2;
+  PlaneWaveSpecifics.MaxPsiDouble /= 2;
+  PlaneWaveSpecifics.PsiType = (PlaneWaveSpecifics.PsiMaxNoDown == PlaneWaveSpecifics.PsiMaxNoUp) ? 0 : 1;
+  if ((PlaneWaveSpecifics.PsiType == 1) && (Parallelization.ProcPEPsi < 2) && ((PlaneWaveSpecifics.PsiMaxNoDown != 1) || (PlaneWaveSpecifics.PsiMaxNoUp != 0))) {
+    Parallelization.ProcPEGamma /= 2;
+    Parallelization.ProcPEPsi *= 2;
+  } else {
+    Parallelization.ProcPEGamma *= Parallelization.ProcPEPsi;
+    Parallelization.ProcPEPsi = 1;
+  }
+  cout << PlaneWaveSpecifics.PsiMaxNoDown << ">" << PlaneWaveSpecifics.PsiMaxNoUp << endl;
+  if (PlaneWaveSpecifics.PsiMaxNoDown > PlaneWaveSpecifics.PsiMaxNoUp) {
+    StepCounts.InitMaxMinStopStep = StepCounts.MaxMinStopStep = PlaneWaveSpecifics.PsiMaxNoDown;
+    cout << PlaneWaveSpecifics.PsiMaxNoDown << " " << StepCounts.InitMaxMinStopStep << endl;
+  } else {
+    StepCounts.InitMaxMinStopStep = StepCounts.MaxMinStopStep = PlaneWaveSpecifics.PsiMaxNoUp;
+    cout << PlaneWaveSpecifics.PsiMaxNoUp << " " << StepCounts.InitMaxMinStopStep << endl;
+  }
+};
+
+/** Prints MaxTypes and list of elements to strea,
+ * \param *file output stream
+ * \param &allatoms vector of all atoms in the system, such as by World::getAllAtoms()
+ * \param &ZtoIndexMap map of which atoms belong to which ion number
+ */
+void PcpParser::OutputElements(ostream *file, vector<atom *> &allatoms, map<int, int> &ZtoIndexMap)
+{
+  map<int, int> PresentElements;
+  pair <   map<int, int>::iterator, bool > Inserter;
+  // 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));
+    if (!Inserter.second) // increase if present
+      Inserter.first->second += 1;
+  }
+  // print total element count
+  *file << "MaxTypes\t" << PresentElements.size() <<  "\t# maximum number of different ion types" << endl;
+  *file << endl;
+  // print element list
+  *file << "# Ion type data (PP = PseudoPotential, Z = atomic number)" << endl;
+  *file << "#Ion_TypeNr.\tAmount\tZ\tRGauss\tL_Max(PP)L_Loc(PP)IonMass\t# chemical name, symbol" << endl;
+  // elements are due to map sorted by Z value automatically, hence just count through them
+  int counter = 1;
+  for(map<int, int>::const_iterator iter=PresentElements.begin(); iter!=PresentElements.end();++iter) {
+    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;
+  }
+}
+
+/** Output all atoms one per line.
+ * \param *file output stream
+ * \param &allatoms vector of all atoms in the system, such as by World::getAllAtoms()
+ * \param &ZtoIndexMap map of which atoms belong to which ion number
+ */
+void PcpParser::OutputAtoms(ostream *file, vector<atom *> &allatoms, map<int, int> &ZtoIndexMap)
+{
+  *file << "#Ion_TypeNr._Nr.R[0]    R[1]    R[2]    MoveType (0 MoveIon, 1 FixedIon)" << endl;
+  map<int, int> ZtoCountMap;
+  pair <   map<int, int>::iterator, bool > Inserter;
+  int nr = 0;
+  for (vector<atom *>::iterator AtomRunner = allatoms.begin();AtomRunner != allatoms.end();++AtomRunner) {
+    Inserter = ZtoCountMap.insert( pair<int, int>((*AtomRunner)->type->Z, 1) );
+    if (!Inserter.second)
+      Inserter.first->second += 1;
+    const int Z = (*AtomRunner)->type->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 << "\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";
+    *file << " # molecule nr " << nr++ << endl;
+  }
+}
+
+/** Reading of Thermostat related values from parameter file.
+ * \param *fb file buffer containing the config file
+ */
+void PcpParser::ParseThermostats(class ConfigFileBuffer * const fb)
+{
+  char * const thermo = new char[12];
+  const int verbose = 0;
+  class ThermoStatContainer *Thermostats = World::getInstance().getThermostats();
+
+  // read desired Thermostat from file along with needed additional parameters
+  if (ParseForParameter(verbose,fb,"Thermostat", 0, 1, 1, string_type, thermo, 1, optional)) {
+    if (strcmp(thermo, Thermostats->ThermostatNames[0]) == 0) { // None
+      if (Thermostats->ThermostatImplemented[0] == 1) {
+        Thermostats->Thermostat = None;
+      } else {
+        DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
+        Thermostats->Thermostat = None;
+      }
+    } else if (strcmp(thermo, Thermostats->ThermostatNames[1]) == 0) { // Woodcock
+      if (Thermostats->ThermostatImplemented[1] == 1) {
+        Thermostats->Thermostat = Woodcock;
+        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &Thermostats->ScaleTempStep, 1, critical); // read scaling frequency
+      } else {
+        DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
+        Thermostats->Thermostat = None;
+      }
+    } else if (strcmp(thermo, Thermostats->ThermostatNames[2]) == 0) { // Gaussian
+      if (Thermostats->ThermostatImplemented[2] == 1) {
+        Thermostats->Thermostat = Gaussian;
+        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &Thermostats->ScaleTempStep, 1, critical); // read collision rate
+      } else {
+        DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
+        Thermostats->Thermostat = None;
+      }
+    } else if (strcmp(thermo, Thermostats->ThermostatNames[3]) == 0) { // Langevin
+      if (Thermostats->ThermostatImplemented[3] == 1) {
+        Thermostats->Thermostat = Langevin;
+        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->TempFrequency, 1, critical); // read gamma
+        if (ParseForParameter(verbose,fb,"Thermostat", 0, 3, 1, double_type, &Thermostats->alpha, 1, optional)) {
+          DoLog(2) && (Log() << Verbose(2) << "Extended Stochastic Thermostat detected with interpolation coefficient " << Thermostats->alpha << "." << endl);
+        } else {
+          Thermostats->alpha = 1.;
+        }
+      } else {
+        DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
+        Thermostats->Thermostat = None;
+      }
+    } else if (strcmp(thermo, Thermostats->ThermostatNames[4]) == 0) { // Berendsen
+      if (Thermostats->ThermostatImplemented[4] == 1) {
+        Thermostats->Thermostat = Berendsen;
+        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->TempFrequency, 1, critical); // read \tau_T
+      } else {
+        DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
+        Thermostats->Thermostat = None;
+      }
+    } else if (strcmp(thermo, Thermostats->ThermostatNames[5]) == 0) { // Nose-Hoover
+      if (Thermostats->ThermostatImplemented[5] == 1) {
+        Thermostats->Thermostat = NoseHoover;
+        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->HooverMass, 1, critical); // read Hoovermass
+        Thermostats->alpha = 0.;
+      } else {
+        DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
+        Thermostats->Thermostat = None;
+      }
+    } else {
+      DoLog(1) && (Log() << Verbose(1) << " Warning: thermostat name was not understood!" << endl);
+      Thermostats->Thermostat = None;
+    }
+  } else {
+    if ((Thermostats->TargetTemp != 0))
+      DoLog(2) && (Log() << Verbose(2) <<  "No thermostat chosen despite finite temperature MD, falling back to None." << endl);
+    Thermostats->Thermostat = None;
+  }
+  delete[](thermo);
+};
+
+bool PcpParser::operator==(const PcpParser& b) const
+{
+  ASSERT(Parallelization.ProcPEGamma == b.Parallelization.ProcPEGamma, "PcpParser ==: ProcPEGamma not");
+  ASSERT(Parallelization.ProcPEPsi == b.Parallelization.ProcPEPsi, "PcpParser ==: ProcPEPsi not");
+
+  if ((Paths.databasepath != NULL) && (b.Paths.databasepath != NULL))
+    ASSERT(strcmp(Paths.databasepath, b.Paths.databasepath), "PcpParser ==: databasepath not");
+  if ((Paths.configname != NULL) && (b.Paths.configname != NULL))
+    ASSERT(strcmp(Paths.configname, b.Paths.configname), "PcpParser ==: configname not");
+  if ((Paths.mainname != NULL) && (b.Paths.mainname != NULL))
+    ASSERT(strcmp(Paths.mainname, b.Paths.mainname), "PcpParser ==: mainname not");
+  if ((Paths.defaultpath != NULL) && (b.Paths.defaultpath != NULL))
+    ASSERT(strcmp(Paths.defaultpath, b.Paths.defaultpath), "PcpParser ==: defaultpath not");
+  if ((Paths.pseudopotpath != NULL) && (b.Paths.pseudopotpath != NULL))
+    ASSERT(strcmp(Paths.pseudopotpath, b.Paths.pseudopotpath), "PcpParser ==: pseudopotpath not");
+
+  ASSERT(Switches.DoConstrainedMD == b.Switches.DoConstrainedMD, "PcpParser ==: DoConstrainedMD not");
+  ASSERT(Switches.DoOutVis == b.Switches.DoOutVis, "PcpParser ==: DoOutVis not");
+  ASSERT(Switches.DoOutMes == b.Switches.DoOutMes, "PcpParser ==: DoOutMes not");
+  ASSERT(Switches.DoOutNICS == b.Switches.DoOutNICS, "PcpParser ==: DoOutNICS not");
+  ASSERT(Switches.DoOutOrbitals == b.Switches.DoOutOrbitals, "PcpParser ==: DoOutOrbitals not");
+  ASSERT(Switches.DoOutCurrent == b.Switches.DoOutCurrent, "PcpParser ==: DoOutCurrent not");
+  ASSERT(Switches.DoFullCurrent == b.Switches.DoFullCurrent, "PcpParser ==: DoFullCurrent not");
+  ASSERT(Switches.DoPerturbation == b.Switches.DoPerturbation, "PcpParser ==: DoPerturbation not");
+  ASSERT(Switches.DoWannier == b.Switches.DoWannier, "PcpParser ==: DoWannier not");
+
+  ASSERT(LocalizedOrbitals.CommonWannier == b.LocalizedOrbitals.CommonWannier, "PcpParser ==: CommonWannier not");
+  ASSERT(LocalizedOrbitals.SawtoothStart == b.LocalizedOrbitals.SawtoothStart, "PcpParser ==: SawtoothStart not");
+  ASSERT(LocalizedOrbitals.VectorPlane == b.LocalizedOrbitals.VectorPlane, "PcpParser ==: VectorPlane not");
+  ASSERT(LocalizedOrbitals.VectorCut == b.LocalizedOrbitals.VectorCut, "PcpParser ==: VectorCut not");
+  ASSERT(LocalizedOrbitals.UseAddGramSch == b.LocalizedOrbitals.UseAddGramSch, "PcpParser ==: UseAddGramSch not");
+  ASSERT(LocalizedOrbitals.Seed == b.LocalizedOrbitals.Seed, "PcpParser ==: Seed not");
+  ASSERT(LocalizedOrbitals.EpsWannier == b.LocalizedOrbitals.EpsWannier, "PcpParser ==: EpsWannier not");
+
+  ASSERT(StepCounts.MaxMinStopStep == b.StepCounts.MaxMinStopStep, "PcpParser ==: MaxMinStopStep not");
+  ASSERT(StepCounts.InitMaxMinStopStep == b.StepCounts.InitMaxMinStopStep, "PcpParser ==: InitMaxMinStopStep not");
+  ASSERT(StepCounts.OutVisStep == b.StepCounts.OutVisStep, "PcpParser ==: OutVisStep not");
+  ASSERT(StepCounts.OutSrcStep == b.StepCounts.OutSrcStep, "PcpParser ==: OutSrcStep not");
+  ASSERT(StepCounts.MaxPsiStep == b.StepCounts.MaxPsiStep, "PcpParser ==: MaxPsiStep not");
+  ASSERT(StepCounts.MaxOuterStep == b.StepCounts.MaxOuterStep, "PcpParser ==: MaxOuterStep not");
+  ASSERT(StepCounts.MaxMinStep == b.StepCounts.MaxMinStep, "PcpParser ==: MaxMinStep not");
+  ASSERT(StepCounts.RelEpsTotalEnergy == b.StepCounts.RelEpsTotalEnergy, "PcpParser ==: RelEpsTotalEnergy not");
+  ASSERT(StepCounts.MaxMinGapStopStep == b.StepCounts.MaxMinGapStopStep, "PcpParser ==: MaxMinGapStopStep not");
+  ASSERT(StepCounts.MaxInitMinStep == b.StepCounts.MaxInitMinStep, "PcpParser ==: MaxInitMinStep not");
+  ASSERT(StepCounts.InitRelEpsTotalEnergy == b.StepCounts.InitRelEpsTotalEnergy, "PcpParser ==: InitRelEpsTotalEnergy not");
+  ASSERT(StepCounts.InitRelEpsKineticEnergy == b.StepCounts.InitRelEpsKineticEnergy, "PcpParser ==: InitRelEpsKineticEnergy not");
+  ASSERT(StepCounts.InitMaxMinGapStopStep == b.StepCounts.InitMaxMinGapStopStep, "PcpParser ==: InitMaxMinGapStopStep not");
+
+  ASSERT(PlaneWaveSpecifics.PsiType == b.PlaneWaveSpecifics.PsiType, "PcpParser ==: PsiType not");
+  ASSERT(PlaneWaveSpecifics.MaxPsiDouble == b.PlaneWaveSpecifics.MaxPsiDouble, "PcpParser ==: MaxPsiDouble not");
+  ASSERT(PlaneWaveSpecifics.PsiMaxNoUp == b.PlaneWaveSpecifics.PsiMaxNoUp, "PcpParser ==: PsiMaxNoUp not");
+  ASSERT(PlaneWaveSpecifics.PsiMaxNoDown == b.PlaneWaveSpecifics.PsiMaxNoDown, "PcpParser ==: PsiMaxNoDown not");
+  ASSERT(PlaneWaveSpecifics.ECut == b.PlaneWaveSpecifics.ECut, "PcpParser ==: ECut not");
+  ASSERT(PlaneWaveSpecifics.MaxLevel == b.PlaneWaveSpecifics.MaxLevel, "PcpParser ==: MaxLevel not");
+  ASSERT(PlaneWaveSpecifics.RiemannTensor == b.PlaneWaveSpecifics.RiemannTensor, "PcpParser ==: RiemannTensor not");
+  ASSERT(PlaneWaveSpecifics.LevRFactor == b.PlaneWaveSpecifics.LevRFactor, "PcpParser ==: LevRFactor not");
+  ASSERT(PlaneWaveSpecifics.RiemannLevel == b.PlaneWaveSpecifics.RiemannLevel, "PcpParser ==: RiemannLevel not");
+  ASSERT(PlaneWaveSpecifics.Lev0Factor == b.PlaneWaveSpecifics.Lev0Factor, "PcpParser ==: Lev0Factor not");
+  ASSERT(PlaneWaveSpecifics.RTActualUse == b.PlaneWaveSpecifics.RTActualUse, "PcpParser ==: RTActualUse not");
+  ASSERT(PlaneWaveSpecifics.AddPsis == b.PlaneWaveSpecifics.AddPsis, "PcpParser ==: AddPsis not");
+  ASSERT(PlaneWaveSpecifics.AddPsis == b.PlaneWaveSpecifics.AddPsis, "PcpParser ==: AddPsis not");
+  ASSERT(PlaneWaveSpecifics.RCut == b.PlaneWaveSpecifics.RCut, "PcpParser ==: RCut not");
+
+  ASSERT(FastParsing == b.FastParsing, "PcpParser ==: FastParsing not");
+
+  ASSERT(Deltat == b.Deltat, "PcpParser ==: Deltat not");
+  ASSERT(IsAngstroem == b.IsAngstroem, "PcpParser ==: IsAngstroem not");
+  ASSERT(RelativeCoord == b.RelativeCoord, "PcpParser ==: RelativeCoord not");
+  ASSERT(StructOpt == b.StructOpt, "PcpParser ==: StructOpt not");
+  ASSERT(MaxTypes == b.MaxTypes, "PcpParser ==: MaxTypes not");
+  ASSERT(basis == b.basis, "PcpParser ==: basis not");
+
+  return true;
+}
Index: src/Parser/PcpParser.hpp
===================================================================
--- src/Parser/PcpParser.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Parser/PcpParser.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,129 @@
+/*
+ * PcpParser.hpp
+ *
+ *  Created on: 12.06.2010
+ *      Author: heber
+ */
+
+#ifndef PCPPARSER_HPP_
+#define PCPPARSER_HPP_
+
+#include <iostream>
+#include "Parser/FormatParser.hpp"
+
+/**
+ * Parser for PCP config files.
+ */
+class PcpParser : public FormatParser {
+public:
+  PcpParser();
+  ~PcpParser();
+  void load(std::istream* file);
+  void save(std::ostream* file);
+
+  bool operator==(const PcpParser& b) const;
+
+private:
+
+  void ParseThermostats(class ConfigFileBuffer * const fb);
+  void OutputAtoms(ostream *file, vector<atom *> &allatoms, map<int, int> &ZtoIndexMap);
+  void OutputElements(ostream *file, vector<atom *> &allatoms, map<int, int> &ZtoIndexMap);
+  void CalculateOrbitals(vector<atom *> &allatoms);
+
+  struct StructParallelization {
+    int ProcPEGamma;
+    int ProcPEPsi;
+  } Parallelization;
+
+  /*
+   * Contains all the paths and names
+   */
+  struct StructPaths {
+    char *databasepath;
+    char *configname;
+    char *mainname;
+    char *defaultpath;
+    char *pseudopotpath;
+  } Paths;
+
+  /*
+   * Contains all Do/Don't switches
+   */
+  struct StructSwitches {
+    int DoConstrainedMD;
+    int DoOutVis;
+    int DoOutMes;
+    int DoOutNICS;
+    int DoOutOrbitals;
+    int DoOutCurrent;
+    int DoFullCurrent;
+    int DoPerturbation;
+    int DoWannier;
+  } Switches;
+
+  /*
+   * Contains parameters regarding localization of orbitals or magnetic perturbation
+   */
+  struct StructLocalizedOrbitals {
+    int CommonWannier;
+    double SawtoothStart;
+    int VectorPlane;
+    double VectorCut;
+    int UseAddGramSch;
+    int Seed;
+    double EpsWannier;
+  } LocalizedOrbitals;
+
+  /*
+   * Contains all step count and other epsilon threshold parameters
+   */
+  struct StructStepCounts {
+    int MaxMinStopStep;
+    int InitMaxMinStopStep;
+
+    int OutVisStep;
+    int OutSrcStep;
+    int MaxPsiStep;
+
+    int MaxOuterStep;
+
+    int MaxMinStep;
+    double RelEpsTotalEnergy;
+    double RelEpsKineticEnergy;
+    int MaxMinGapStopStep;
+    int MaxInitMinStep;
+    double InitRelEpsTotalEnergy;
+    double InitRelEpsKineticEnergy;
+    int InitMaxMinGapStopStep;
+  } StepCounts;
+
+  /*
+   * Contains all parameters specific to the plane wave basis set
+   */
+  struct StructPlaneWaveSpecifics {
+    int PsiType;
+    int MaxPsiDouble;
+    int PsiMaxNoUp;
+    int PsiMaxNoDown;
+    double ECut;
+    int MaxLevel;
+    int RiemannTensor;
+    int LevRFactor;
+    int RiemannLevel;
+    int Lev0Factor;
+    int RTActualUse;
+    int AddPsis;
+    double RCut;
+  } PlaneWaveSpecifics;
+
+  bool FastParsing;
+
+  double Deltat;
+  int IsAngstroem;
+  int RelativeCoord;
+  int StructOpt;
+  int MaxTypes;
+  string basis;
+};
+
+#endif /* PCPPARSER_HPP_ */
Index: src/Parser/TremoloParser.cpp
===================================================================
--- src/Parser/TremoloParser.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Parser/TremoloParser.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,502 @@
+/*
+ * TremoloParser.cpp
+ *
+ *  Created on: Mar 2, 2010
+ *      Author: metzler
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Helpers/Assert.hpp"
+#include "TremoloParser.hpp"
+#include "World.hpp"
+#include "atom.hpp"
+#include "element.hpp"
+#include "bond.hpp"
+#include "periodentafel.hpp"
+#include "Descriptors/AtomIdDescriptor.hpp"
+#include <map>
+#include <vector>
+
+
+using namespace std;
+using namespace boost;
+
+/**
+ * Constructor.
+ */
+TremoloParser::TremoloParser() {
+  knownKeys[" "] = TremoloKey::noKey; // with this we can detect invalid keys
+  knownKeys["x"] = TremoloKey::x;
+  knownKeys["u"] = TremoloKey::u;
+  knownKeys["F"] = TremoloKey::F;
+  knownKeys["stress"] = TremoloKey::stress;
+  knownKeys["Id"] = TremoloKey::Id;
+  knownKeys["neighbors"] = TremoloKey::neighbors;
+  knownKeys["imprData"] = TremoloKey::imprData;
+  knownKeys["GroupMeasureTypeNo"] = TremoloKey::GroupMeasureTypeNo;
+  knownKeys["Type"] = TremoloKey::Type;
+  knownKeys["extType"] = TremoloKey::extType;
+  knownKeys["name"] = TremoloKey::name;
+  knownKeys["resName"] = TremoloKey::resName;
+  knownKeys["chainID"] = TremoloKey::chainID;
+  knownKeys["resSeq"] = TremoloKey::resSeq;
+  knownKeys["occupancy"] = TremoloKey::occupancy;
+  knownKeys["tempFactor"] = TremoloKey::tempFactor;
+  knownKeys["segID"] = TremoloKey::segID;
+  knownKeys["Charge"] = TremoloKey::Charge;
+  knownKeys["charge"] = TremoloKey::charge;
+  knownKeys["GrpTypeNo"] = TremoloKey::GrpTypeNo;
+  knownKeys["torsion"] = TremoloKey::torsion;
+
+  // default behavior: use all possible keys on output
+  for (std::map<std::string, TremoloKey::atomDataKey>::iterator iter = knownKeys.begin(); iter != knownKeys.end(); ++iter)
+    usedFields.push_back(iter->first);
+}
+
+/**
+ * Destructor.
+ */
+TremoloParser::~TremoloParser() {
+  usedFields.clear();
+  additionalAtomData.clear();
+  atomIdMap.clear();
+  knownKeys.clear();
+}
+
+/**
+ * Loads atoms from a tremolo-formatted file.
+ *
+ * \param tremolo file
+ */
+void TremoloParser::load(istream* file) {
+  string line;
+  string::size_type location;
+
+  usedFields.clear();
+  while (file->good()) {
+    std::getline(*file, line, '\n');
+    if (usedFields.empty()) {
+      location = line.find("ATOMDATA", 0);
+      if (location != string::npos) {
+       parseAtomDataKeysLine(line, location + 8);
+      }
+    }
+    if (line.length() > 0 && line.at(0) != '#') {
+      readAtomDataLine(line);
+    }
+  }
+
+  processNeighborInformation();
+  adaptImprData();
+  adaptTorsion();
+}
+
+/**
+ * Saves the World's current state into as a tremolo file.
+ *
+ * \param file where to save the state
+ */
+void TremoloParser::save(ostream* file) {
+  vector<atom*>::iterator atomIt;
+  vector<string>::iterator it;
+
+  *file << "# ATOMDATA";
+  for (it=usedFields.begin(); it < usedFields.end(); it++) {
+    *file << "\t" << *it;
+  }
+  *file << endl;
+  vector<atom *> AtomList = World::getInstance().getAllAtoms();
+  for (atomIt = AtomList.begin(); atomIt != AtomList.end(); atomIt++) {
+    saveLine(file, *atomIt);
+  }
+}
+
+/**
+ * Sets the keys for which data should be written to the stream when save is
+ * called.
+ *
+ * \param string of field names with the same syntax as for an ATOMDATA line
+ *        but without the prexix "ATOMDATA"
+ */
+void TremoloParser::setFieldsForSave(std::string atomDataLine) {
+  parseAtomDataKeysLine(atomDataLine, 0);
+}
+
+
+/**
+ * Writes one line of tremolo-formatted data to the provided stream.
+ *
+ * \param stream where to write the line to
+ * \param reference to the atom of which information should be written
+ */
+void TremoloParser::saveLine(ostream* file, atom* currentAtom) {
+  vector<string>::iterator it;
+  TremoloKey::atomDataKey currentField;
+
+  for (it = usedFields.begin(); it != usedFields.end(); it++) {
+    currentField = knownKeys[it->substr(0, it->find("="))];
+    switch (currentField) {
+      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";
+        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";
+        break;
+      case TremoloKey::Type :
+        *file << currentAtom->getType()->getSymbol() << "\t";
+        break;
+      case TremoloKey::Id :
+        *file << currentAtom->getId() << "\t";
+        break;
+      case TremoloKey::neighbors :
+        writeNeighbors(file, atoi(it->substr(it->find("=") + 1, 1).c_str()), currentAtom);
+        break;
+      default :
+        *file << (additionalAtomData.find(currentAtom->getId()) != additionalAtomData.end()
+          ? additionalAtomData[currentAtom->getId()].get(currentField)
+          : defaultAdditionalData.get(currentField));
+        *file << "\t";
+        break;
+    }
+  }
+
+  *file << endl;
+}
+
+/**
+ * Writes the neighbor information of one atom to the provided stream.
+ *
+ * \param stream where to write neighbor information to
+ * \param number of neighbors
+ * \param reference to the atom of which to take the neighbor information
+ */
+void TremoloParser::writeNeighbors(ostream* file, int numberOfNeighbors, atom* currentAtom) {
+  BondList::iterator currentBond = currentAtom->ListOfBonds.begin();
+  for (int i = 0; i < numberOfNeighbors; i++) {
+    *file << (currentBond != currentAtom->ListOfBonds.end()
+        ? (*currentBond)->GetOtherAtom(currentAtom)->getId() : 0) << "\t";
+  }
+}
+
+/**
+ * Stores keys from the ATOMDATA line.
+ *
+ * \param line to parse the keys from
+ * \param with which offset the keys begin within the line
+ */
+void TremoloParser::parseAtomDataKeysLine(string line, int offset) {
+  string keyword;
+  stringstream lineStream;
+
+  lineStream << line.substr(offset);
+  usedFields.clear();
+  while (lineStream.good()) {
+    lineStream >> keyword;
+    if (knownKeys[keyword.substr(0, keyword.find("="))] == TremoloKey::noKey) {
+      // TODO: throw exception about unknown key
+      cout << "Unknown key: " << keyword << " is not part of the tremolo format specification." << endl;
+      break;
+    }
+    usedFields.push_back(keyword);
+  }
+}
+
+/**
+ * Reads one data line of a tremolo file and interprets it according to the keys
+ * obtained from the ATOMDATA line.
+ *
+ * \param line to parse as an atom
+ */
+void TremoloParser::readAtomDataLine(string line) {
+  vector<string>::iterator it;
+  stringstream lineStream;
+  atom* newAtom = World::getInstance().createAtom();
+  TremoloAtomInfoContainer *atomInfo = NULL;
+  additionalAtomData[newAtom->getId()] = *(new TremoloAtomInfoContainer);
+  atomInfo = &additionalAtomData[newAtom->getId()];
+  TremoloKey::atomDataKey currentField;
+  string word;
+  int oldId;
+
+  lineStream << line;
+  for (it = usedFields.begin(); it < usedFields.end(); it++) {
+    currentField = knownKeys[it->substr(0, it->find("="))];
+    switch (currentField) {
+      case TremoloKey::x :
+        // for the moment, assume there are always three dimensions
+        lineStream >> newAtom->x[0];
+        lineStream >> newAtom->x[1];
+        lineStream >> newAtom->x[2];
+        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];
+        break;
+      case TremoloKey::Type :
+        char type[3];
+        lineStream >> type;
+        newAtom->setType(World::getInstance().getPeriode()->FindElement(type));
+        ASSERT(newAtom->getType(), "Type was not set for this atom");
+        break;
+      case TremoloKey::Id :
+        lineStream >> oldId;
+        atomIdMap[oldId] = newAtom->getId();
+        break;
+      case TremoloKey::neighbors :
+        readNeighbors(&lineStream,
+            atoi(it->substr(it->find("=") + 1, 1).c_str()), newAtom->getId());
+        break;
+      default :
+        lineStream >> word;
+        atomInfo->set(currentField, word);
+        break;
+    }
+  }
+}
+
+/**
+ * Reads neighbor information for one atom from the input.
+ *
+ * \param stream where to read the information from
+ * \param number of neighbors to read
+ * \param world id of the atom the information belongs to
+ */
+void TremoloParser::readNeighbors(stringstream* line, int numberOfNeighbors, int atomId) {
+  int neighborId = 0;
+  for (int i = 0; i < numberOfNeighbors; i++) {
+    *line >> neighborId;
+    // 0 is used to fill empty neighbor positions in the tremolo file.
+    if (neighborId > 0) {
+      additionalAtomData[atomId].neighbors.push_back(neighborId);
+    }
+  }
+}
+
+/**
+ * Checks whether the provided name is within the list of used fields.
+ *
+ * \param field name to check
+ *
+ * \return true if the field name is used
+ */
+bool TremoloParser::isUsedField(string fieldName) {
+  bool fieldNameExists = false;
+  for (vector<string>::iterator usedField = usedFields.begin(); usedField != usedFields.end(); usedField++) {
+    if (usedField->substr(0, usedField->find("=")) == fieldName)
+      fieldNameExists = true;
+  }
+
+  return fieldNameExists;
+}
+
+
+/**
+ * Adds the collected neighbor information to the atoms in the world. The atoms
+ * are found by their current ID and mapped to the corresponding atoms with the
+ * Id found in the parsed file.
+ */
+void TremoloParser::processNeighborInformation() {
+  if (!isUsedField("neighbors")) {
+    return;
+  }
+
+  for(map<int, TremoloAtomInfoContainer>::iterator currentInfo = additionalAtomData.begin();
+    currentInfo != additionalAtomData.end(); currentInfo++
+  ) {
+    for(vector<int>::iterator neighbor = currentInfo->second.neighbors.begin();
+      neighbor != currentInfo->second.neighbors.end(); neighbor++
+    ) {
+      World::getInstance().getAtom(AtomById(currentInfo->first))
+          ->addBond(World::getInstance().getAtom(AtomById(atomIdMap[*neighbor])));
+    }
+  }
+}
+
+/**
+ * Replaces atom IDs read from the file by the corresponding world IDs. All IDs
+ * IDs of the input string will be replaced; expected separating characters are
+ * "-" and ",".
+ *
+ * \param string in which atom IDs should be adapted
+ *
+ * \return input string with modified atom IDs
+ */
+string TremoloParser::adaptIdDependentDataString(string data) {
+  // there might be no IDs
+  if (data == "-") {
+    return "-";
+  }
+
+  char separator;
+  int id;
+  stringstream line, result;
+  line << data;
+
+  line >> id;
+  result << atomIdMap[id];
+  while (line.good()) {
+    line >> separator >> id;
+    result << separator << atomIdMap[id];
+  }
+
+  return result.str();
+}
+
+/**
+ * Corrects the atom IDs in each imprData entry to the corresponding world IDs
+ * as they might differ from the originally read IDs.
+ */
+void TremoloParser::adaptImprData() {
+  if (!isUsedField("imprData")) {
+    return;
+  }
+
+  for(map<int, TremoloAtomInfoContainer>::iterator currentInfo = additionalAtomData.begin();
+    currentInfo != additionalAtomData.end(); currentInfo++
+  ) {
+    currentInfo->second.imprData = adaptIdDependentDataString(currentInfo->second.imprData);
+  }
+}
+
+/**
+ * Corrects the atom IDs in each torsion entry to the corresponding world IDs
+ * as they might differ from the originally read IDs.
+ */
+void TremoloParser::adaptTorsion() {
+  if (!isUsedField("torsion")) {
+    return;
+  }
+
+  for(map<int, TremoloAtomInfoContainer>::iterator currentInfo = additionalAtomData.begin();
+    currentInfo != additionalAtomData.end(); currentInfo++
+  ) {
+    currentInfo->second.torsion = adaptIdDependentDataString(currentInfo->second.torsion);
+  }
+}
+
+
+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) {
+  switch (key) {
+    case TremoloKey::F :
+      F = value;
+      break;
+    case TremoloKey::stress :
+      stress = value;
+     break;
+    case TremoloKey::imprData :
+      imprData = value;
+      break;
+    case TremoloKey::GroupMeasureTypeNo :
+      GroupMeasureTypeNo = value;
+      break;
+    case TremoloKey::extType :
+      extType = value;
+      break;
+    case TremoloKey::name :
+      name = value;
+      break;
+    case TremoloKey::resName :
+      resName = value;
+      break;
+    case TremoloKey::chainID :
+      chainID = value;
+      break;
+    case TremoloKey::resSeq :
+      resSeq = value;
+      break;
+    case TremoloKey::occupancy :
+      occupancy = value;
+      break;
+    case TremoloKey::tempFactor :
+      tempFactor = value;
+      break;
+    case TremoloKey::segID :
+      segID = value;
+      break;
+    case TremoloKey::Charge :
+      Charge = value;
+      break;
+    case TremoloKey::charge :
+      charge = value;
+      break;
+    case TremoloKey::GrpTypeNo :
+      GrpTypeNo = value;
+      break;
+    case TremoloKey::torsion :
+      torsion = value;
+      break;
+    default :
+      cout << "Unknown key: " << key << ", value: " << value << endl;
+      break;
+  }
+}
+
+string TremoloAtomInfoContainer::get(TremoloKey::atomDataKey key) {
+  switch (key) {
+    case TremoloKey::F :
+      return F;
+    case TremoloKey::stress :
+      return stress;
+    case TremoloKey::imprData :
+      return imprData;
+    case TremoloKey::GroupMeasureTypeNo :
+      return GroupMeasureTypeNo;
+    case TremoloKey::extType :
+      return extType;
+    case TremoloKey::name :
+      return name;
+    case TremoloKey::resName :
+      return resName;
+    case TremoloKey::chainID :
+      return chainID;
+    case TremoloKey::resSeq :
+      return resSeq;
+    case TremoloKey::occupancy :
+      return occupancy;
+    case TremoloKey::tempFactor :
+      return tempFactor;
+    case TremoloKey::segID :
+      return segID;
+    case TremoloKey::Charge :
+      return Charge;
+    case TremoloKey::charge :
+      return charge;
+    case TremoloKey::GrpTypeNo :
+      return GrpTypeNo;
+    case TremoloKey::torsion :
+      return torsion;
+    default :
+      cout << "Unknown key: " << key << endl;
+      return "";
+  }
+}
+
Index: src/Parser/TremoloParser.hpp
===================================================================
--- src/Parser/TremoloParser.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Parser/TremoloParser.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,125 @@
+/*
+ * TremoloParser.hpp
+ *
+ *  Created on: Mar 2, 2010
+ *      Author: metzler
+ */
+
+#ifndef TREMOLOPARSER_HPP_
+#define TREMOLOPARSER_HPP_
+
+#include <string>
+#include "Parser/FormatParser.hpp"
+
+/**
+ * Known keys for the ATOMDATA line.
+ */
+class TremoloKey {
+public:
+  enum atomDataKey {
+    noKey,
+    x,
+    u,
+    F,
+    stress,
+    Id,
+    neighbors,
+    imprData,
+    GroupMeasureTypeNo,
+    Type,
+    extType,
+    name,
+    resName,
+    chainID,
+    resSeq,
+    occupancy,
+    tempFactor,
+    segID,
+    Charge,
+    charge,
+    GrpTypeNo,
+    torsion
+  };
+};
+
+/**
+ * Holds tremolo-specific information which is not store in the atom class.
+ */
+class TremoloAtomInfoContainer {
+public:
+  TremoloAtomInfoContainer();
+  void set(TremoloKey::atomDataKey key, std::string value);
+  std::string get(TremoloKey::atomDataKey key);
+  std::string F;
+  std::string stress;
+  std::string imprData;
+  std::string GroupMeasureTypeNo;
+  std::string extType;
+  std::string name;
+  std::string resName;
+  std::string chainID;
+  std::string resSeq;
+  std::string occupancy;
+  std::string tempFactor;
+  std::string segID;
+  std::string Charge;
+  std::string charge;
+  std::string GrpTypeNo;
+  std::string torsion;
+  std::vector<int> neighbors;
+};
+
+/**
+ * Loads a tremolo file into the World and saves the World as a tremolo file.
+ */
+class TremoloParser : public FormatParser
+{
+public:
+  TremoloParser();
+  ~TremoloParser();
+  void load(std::istream* file);
+  void save(std::ostream* file);
+  void setFieldsForSave(std::string atomDataLine);
+
+
+private:
+  void readAtomDataLine(string line);
+  void parseAtomDataKeysLine(string line, int offset);
+  void readNeighbors(std::stringstream* line, int numberOfNeighbors, int atomId);
+  void processNeighborInformation();
+  void adaptImprData();
+  void adaptTorsion();
+  std::string adaptIdDependentDataString(std::string data);
+  bool isUsedField(std::string fieldName);
+  void writeNeighbors(std::ostream* file, int numberOfNeighbors, atom* currentAtom);
+  void saveLine(std::ostream* file, atom* currentAtom);
+
+  /**
+   * Map to associate the known keys with numbers.
+   */
+  std::map<std::string, TremoloKey::atomDataKey> knownKeys;
+
+  /**
+   * Fields used in the tremolo file.
+   */
+  std::vector<std::string> usedFields;
+
+  /**
+   * Data which is currently not stored in atoms but was provided by the input
+   * file.
+   */
+  std::map<int, TremoloAtomInfoContainer> additionalAtomData;
+
+  /**
+   * Default additional atom data.
+   */
+  TremoloAtomInfoContainer defaultAdditionalData;
+
+  /**
+   * Maps original atom IDs received from the parsed file to atom IDs in the
+   * world.
+   */
+  std::map<int, int> atomIdMap;
+};
+
+#endif /* TREMOLOPARSER_HPP_ */
Index: src/Parser/XyzParser.cpp
===================================================================
--- src/Parser/XyzParser.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Parser/XyzParser.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,76 @@
+/*
+ * XyzParser.cpp
+ *
+ *  Created on: Mar 2, 2010
+ *      Author: metzler
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "XyzParser.hpp"
+#include "World.hpp"
+#include "atom.hpp"
+#include "element.hpp"
+#include "periodentafel.hpp"
+
+using namespace std;
+
+/**
+ * Constructor.
+ */
+XyzParser::XyzParser() {
+  comment = "";
+}
+
+/**
+ * Destructor.
+ */
+XyzParser::~XyzParser() {
+}
+
+/**
+ * Loads an XYZ file into the World.
+ *
+ * \param XYZ file
+ */
+void XyzParser::load(istream* file) {
+  atom* newAtom;
+  int numberOfAtoms;
+  char commentBuffer[512], type[3];
+
+  // the first line tells number of atoms, the second line is always a comment
+  *file >> numberOfAtoms >> ws;
+  file->getline(commentBuffer, 512);
+  comment = commentBuffer;
+
+  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];
+    newAtom->setType(World::getInstance().getPeriode()->FindElement(type));
+  }
+}
+
+/**
+ * Saves the current state of the World into the given XYZ file.
+ *
+ * \param XYZ file
+ */
+void XyzParser::save(ostream* file) {
+  if (comment == "") {
+    time_t now = time((time_t *)NULL);   // Get the system time and put it into 'now' as 'calender time'
+    comment = "Created by molecuilder on ";
+    // ctime ends in \n\0, we have to cut away the newline
+    std::string time(ctime(&now));
+    size_t pos = time.find('\n');
+    if (pos != 0)
+      comment += time.substr(0,pos);
+    else
+      comment += time;
+  }
+  *file << World::getInstance().numAtoms() << endl << "\t" << comment << endl;
+
+  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;
+  }
+}
Index: src/Parser/XyzParser.hpp
===================================================================
--- src/Parser/XyzParser.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Parser/XyzParser.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,28 @@
+/*
+ * XyzParser.hpp
+ *
+ *  Created on: Mar 2, 2010
+ *      Author: metzler
+ */
+
+#ifndef XYZPARSER_HPP_
+#define XYZPARSER_HPP_
+
+#include <string>
+#include "Parser/FormatParser.hpp"
+
+/**
+ * Parser for XYZ files.
+ */
+class XyzParser : public FormatParser {
+public:
+  XyzParser();
+  ~XyzParser();
+  void load(std::istream* file);
+  void save(std::ostream* file);
+
+private:
+  std::string comment;
+};
+
+#endif /* XYZPARSER_HPP_ */
Index: src/Patterns/Cacheable.hpp
===================================================================
--- src/Patterns/Cacheable.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Patterns/Cacheable.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,280 @@
+/*
+ * Cacheable.hpp
+ *
+ *  Created on: Feb 2, 2010
+ *      Author: crueger
+ */
+
+#ifndef CACHEABLE_HPP_
+#define CACHEABLE_HPP_
+
+#include "Patterns/Observer.hpp"
+#include <boost/function.hpp>
+#include <boost/shared_ptr.hpp>
+#include <iostream>
+
+#include "Helpers/Assert.hpp"
+
+#ifndef NO_CACHING
+
+  template<typename T>
+  class Cacheable : public Observer
+  {
+    // we define the states of the cacheable so we can do very fast state-checks
+    class State{
+    public:
+      State(Cacheable *_owner) :
+        busy(false),
+        owner(_owner)
+        {}
+      virtual T& getValue()=0;
+      virtual void invalidate()=0;
+      virtual bool isValid()=0;
+      virtual void enter()=0;
+      bool isBusy(){
+        return busy;
+      }
+    virtual std::string getName()=0;
+    protected:
+      bool busy;
+      Cacheable *owner;
+    };
+
+    class InvalidState : public State{
+    public:
+      InvalidState(Cacheable *_owner):
+        State(_owner)
+        {}
+
+      virtual T& getValue(){
+        // set the state to valid
+        State::owner->switchState(State::owner->validState);
+        // get the value from the now valid state
+        return State::owner->state->getValue();
+      }
+
+      virtual void invalidate(){
+        // nothing to do on this message
+      }
+
+      virtual bool isValid(){
+        return false;
+      }
+
+      virtual void enter(){
+        // nothing to do when entering this
+      }
+
+      virtual std::string getName(){
+        return "invalid";
+      }
+    };
+
+    class ValidState : public State{
+    public:
+      ValidState(Cacheable *_owner) :
+        State(_owner)
+        {}
+
+      virtual T& getValue(){
+        return content;
+      }
+
+      virtual void invalidate(){
+        State::owner->switchState(State::owner->invalidState);
+      }
+
+      virtual bool isValid(){
+        return true;
+      }
+
+      virtual void enter(){
+        State::busy= true;
+        // as soon as we enter the valid state we recalculate
+        content = State::owner->recalcMethod();
+        State::busy = false;
+      }
+
+      virtual std::string getName(){
+        return "valid";
+      }
+    private:
+      T content;
+    };
+
+    class DestroyedState : public State {
+    public:
+      DestroyedState(Cacheable *_owner) :
+        State(_owner)
+        {}
+
+      virtual T& getValue(){
+        ASSERT(0,"Cannot get a value from a Cacheable after it's Observable has died");
+        // we have to return a grossly invalid reference, because no value can be produced anymore
+        return *(static_cast<T*>(0));
+      }
+
+      virtual void invalidate(){
+        ASSERT(0,"Cannot invalidate a Cacheable after it's Observable has died");
+      }
+
+      virtual bool isValid(){
+        ASSERT(0,"Cannot check validity of a Cacheable after it's Observable has died");
+        return false;
+      }
+
+      virtual void enter(){
+        // nothing to do when entering this state
+      }
+
+      virtual std::string getName(){
+        return "destroyed";
+      }
+    };
+
+
+  typedef boost::shared_ptr<State> state_ptr;
+
+  public:
+    Cacheable(Observable *_owner, boost::function<T()> _recalcMethod, std::string name);
+    virtual ~Cacheable();
+
+    const bool isValid() const;
+    const T operator*() const;
+
+    // methods implemented for base-class Observer
+    void update(Observable *subject);
+    void subjectKilled(Observable *subject);
+  private:
+    void switchState(state_ptr newState);
+
+    mutable state_ptr state;
+    // pre-defined state so we don't have to construct to much
+    state_ptr invalidState;
+    state_ptr validState;
+    // destroyed state is not predefined, because we rarely enter that state and never leave
+
+    Observable *owner;
+    boost::function<T()> recalcMethod;
+
+    // de-activated copy constructor
+    Cacheable(const Cacheable&);
+  };
+
+
+  template<typename T>
+  Cacheable<T>::Cacheable(Observable *_owner, boost::function<T()> _recalcMethod, std::string name) :
+    Observer(name + "(Cached)"),
+    owner(_owner),
+    recalcMethod(_recalcMethod)
+  {
+    // create all states needed for this object
+    invalidState = state_ptr(new InvalidState(this));
+    validState = state_ptr(new ValidState(this));
+    state = invalidState;
+    // we sign on with the best(=lowest) priority, so cached values are recalculated before
+    // anybody else might ask for updated values
+    owner->signOn(this,-20);
+  }
+
+  // de-activated copy constructor
+  template<typename T>
+  Cacheable<T>::Cacheable(const Cacheable&){
+    ASSERT(0,"Cacheables should never be copied");
+  }
+
+  template<typename T>
+  const T Cacheable<T>::operator*() const{
+    // we can only use the cacheable when the owner is not changing at the moment
+    if(!owner->isBlocked()){
+      return state->getValue();
+    }
+    else{
+      return recalcMethod();
+    }
+  }
+
+  template<typename T>
+  Cacheable<T>::~Cacheable()
+  {
+    owner->signOff(this);
+  }
+
+  template<typename T>
+  const bool Cacheable<T>::isValid() const{
+    return state->isValid();
+  }
+
+  template<typename T>
+  void Cacheable<T>::update(Observable *subject) {
+    state->invalidate();
+  }
+
+  template<typename T>
+  void Cacheable<T>::subjectKilled(Observable *subject) {
+    state_ptr destroyed = state_ptr(new DestroyedState(this));
+    switchState(destroyed);
+  }
+
+  template<typename T>
+  void Cacheable<T>::switchState(state_ptr newState){
+    ASSERT(!state->isBusy(),"LOOP DETECTED: Cacheable state switched while recalculating.\nDid the recalculation trigger the Observable?");
+#ifdef LOG_OBSERVER
+    observerLog().addMessage() << "## Cacheable " << observerLog().getName(this) << " changed state (" << state->getName()
+                               << "->" << newState->getName() << ")" << std::endl;
+#endif
+    state = newState;
+    state->enter();
+  }
+
+#else
+  template<typename T>
+  class Cacheable : public Observer
+  {
+  public:
+    Cacheable(Observable *_owner, boost::function<T()> _recalcMethod,std::string name);
+    virtual ~Cacheable();
+
+    const bool isValid() const;
+    const T operator*() const;
+
+    // methods implemented for base-class Observer
+    void update(Observable *subject);
+    void subjectKilled(Observable *subject);
+  private:
+
+    boost::function<T()> recalcMethod;
+  };
+
+  template<typename T>
+  Cacheable<T>::Cacheable(Observable *_owner, boost::function<T()> _recalcMethod, std::string name) :
+    Observer(name),
+    recalcMethod(_recalcMethod)
+  {}
+
+  template<typename T>
+  const T Cacheable<T>::operator*() const{
+    return recalcMethod();
+  }
+
+  template<typename T>
+  Cacheable<T>::~Cacheable()
+  {}
+
+  template<typename T>
+  const bool Cacheable<T>::isValid() const{
+    return true;
+  }
+
+  template<typename T>
+  void Cacheable<T>::update(Observable *subject) {
+    ASSERT(0, "Cacheable::update should never be called when caching is disabled");
+  }
+
+  template<typename T>
+  void Cacheable<T>::subjectKilled(Observable *subject){
+    ASSERT(0, "Cacheable::subjectKilled should never be called when caching is disabled");
+  }
+#endif
+
+#endif /* CACHEABLE_HPP_ */
Index: src/Patterns/ObservedIterator.hpp
===================================================================
--- src/Patterns/ObservedIterator.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Patterns/ObservedIterator.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,145 @@
+/*
+ * ObservedIterator.hpp
+ *
+ *  Created on: Mar 4, 2010
+ *      Author: crueger
+ */
+
+#ifndef OBSERVEDITERATOR_HPP_
+#define OBSERVEDITERATOR_HPP_
+
+#include "Patterns/Observer.hpp"
+
+#include <iterator>
+
+// we build an iterator that observes traversion of some kind of Data structure conforming to STL
+template<class _Set>
+class ObservedIterator
+    : public std::iterator<typename std::iterator_traits<typename _Set::iterator>::iterator_category,
+                           typename std::iterator_traits<typename _Set::iterator>::value_type,
+                           typename std::iterator_traits<typename _Set::iterator>::difference_type,
+                           typename std::iterator_traits<typename _Set::iterator>::pointer,
+                           typename std::iterator_traits<typename _Set::iterator>::reference>
+{
+public:
+  // Some typedefs to conform to STL-Iterator structure
+  typedef typename _Set::iterator _Iter;
+  typedef typename _Iter::value_type value_type;
+  typedef typename _Iter::difference_type difference_type;
+  typedef typename _Iter::pointer pointer;
+  typedef typename _Iter::reference reference;
+  typedef typename _Iter::iterator_category iterator_category;
+
+  ObservedIterator() :
+    protector(0)
+  {}
+
+  ObservedIterator(_Iter iter,Observable *obs) :
+    iter(iter),
+    collection(obs),
+    protector(0)
+  {}
+
+  ObservedIterator(const ObservedIterator &dest) :
+    iter(dest.iter),
+    collection(dest.collection),
+    protector(dest.copyLock())
+  {}
+
+  ~ObservedIterator(){
+    if(protector)
+      delete protector;
+  }
+
+  // standard Iterator methods
+  ObservedIterator& operator=(const ObservedIterator& dest){
+    if(&dest !=this){
+      // get the new lock first, in case the two locks point to the same observable
+      Observable::_Observable_protector *newLock = dest.copyLock();
+      if(protector)
+        delete protector;
+      protector = newLock;
+      // After the new lock is aquired we can safely set the iterator
+      iter = dest.iter;
+      // we need to know the collection, in case we still have to set the lock
+      collection = dest.collection;
+    }
+    return *this;
+  }
+
+  ObservedIterator& operator++()   // prefix
+  {
+    ++iter;
+    return *this;
+  }
+
+  ObservedIterator operator++(int) // postfix with the dummy int parameter
+  {
+    ObservedIterator ret(*this);
+    ++(*this);
+    return ret;
+  }
+
+  ObservedIterator& operator--()   // prefix
+  {
+    --iter;
+    return *this;
+  }
+
+  ObservedIterator  operator--(int) // postfix with the dummy int parameter
+  {
+    ObservedIterator ret(*this);
+    --(*this);
+    return ret;
+  }
+
+  bool operator==(const ObservedIterator &rhs){
+    return iter==rhs.iter;
+  }
+
+  bool operator!=(const ObservedIterator &rhs){
+    return iter!=rhs.iter;
+  }
+
+  value_type operator*(){
+    // access is requested... time to get the lock
+    acquireLock();
+    return (*iter);
+  }
+
+  // when we turn into a const iterator we can loose our lock
+  operator typename _Set::const_iterator() {
+    // typecast will be handled by the typecast method of the original iterator
+    return iter;
+  }
+
+private:
+
+  /**
+   * gets the lock for the collection when needed
+   *
+   * The lock is only acquired when the first change is done, so we can be free to do
+   * anything with the iterator before that. I.e. step forward, turn into a const_iterator
+   * etc.
+   */
+  void acquireLock(){
+    if(!protector)
+      protector = new Observable::_Observable_protector(collection);
+  }
+
+  Observable::_Observable_protector *copyLock() const{
+    // we only copy if we actually carry a lock
+    if(protector){
+      return new Observable::_Observable_protector(*protector);
+    }
+    else{
+      return 0;
+    }
+  }
+
+  _Iter iter;
+  Observable *collection;
+  Observable::_Observable_protector *protector;
+};
+
+#endif /* OBSERVEDITERATOR_HPP_ */
Index: src/Patterns/Observer.cpp
===================================================================
--- src/Patterns/Observer.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Patterns/Observer.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,415 @@
+/*
+ * Observer.cpp
+ *
+ *  Created on: Jan 19, 2010
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Observer.hpp"
+
+
+#include <iostream>
+
+#include "Helpers/Assert.hpp"
+#include "Helpers/MemDebug.hpp"
+
+using namespace std;
+
+/****************** Static stuff for the observer mechanism ************/
+
+// All infrastructure for the observer-pattern is bundled at a central place
+// this is more efficient if many objects can be observed (inherit from observable)
+// but only few are actually coupled with observers. E.g. TMV has over 500.000 Atoms,
+// which might become observable. Handling Observerable infrastructure in each of
+// these would use memory for each atom. By handling Observer-infrastructure
+// here we only need memory for objects that actually are observed.
+// See [Gamma et al, 1995] p. 297
+
+map<Observable*, int> Observable::depth;  //!< Map of Observables to the depth of the DAG of Observers
+map<Observable*,multimap<int,Observer*> > Observable::callTable; //!< Table for each Observable of all its Observers
+std::map<Observable*,std::set<Notification*> > Observable::notifications;
+set<Observable*> Observable::busyObservables; //!< Set of Observables that are currently busy notifying their sign-on'ed Observers
+
+/** Attaching Sub-observables to Observables.
+ * Increases entry in Observable::depth for this \a *publisher by one.
+ *
+ * The two functions \sa start_observer_internal() and \sa finish_observer_internal()
+ * have to be used together at all time. Never use these functions directly
+ * START_OBSERVER and FINISH_OBSERVER also construct a bogus while(0) loop
+ * thus producing compiler-errors whenever only one is used.
+ * \param *publisher reference of sub-observable
+ */
+void Observable::start_observer_internal(Observable *publisher){
+  // increase the count for this observable by one
+  // if no entry for this observable is found, an new one is created
+  // by the STL and initialized to 0 (see STL documentation)
+#ifdef LOG_OBSERVER
+  observerLog().addMessage(depth[publisher]) << ">> Locking " << observerLog().getName(publisher) << endl;
+#endif
+  depth[publisher]++;
+}
+
+/** Detaching Sub-observables from Observables.
+ * Decreases entry in Observable::depth for this \a *publisher by one. If zero, we
+ * start notifying all our Observers.
+ *
+ * The two functions start_observer_internal() and finish_observer_internal()
+ * have to be used together at all time. Never use these functions directly
+ * START_OBSERVER and FINISH_OBSERVER also construct a bogus while(0) loop
+ * thus producing compiler-errors whenever only one is used.
+ * \param *publisher reference of sub-observable
+ */
+void Observable::finish_observer_internal(Observable *publisher){
+  // decrease the count for this observable
+  // if zero is reached all observed blocks are done and we can
+  // start to notify our observers
+  --depth[publisher];
+#ifdef LOG_OBSERVER
+  observerLog().addMessage(depth[publisher]) << "<< Unlocking " << observerLog().getName(publisher) << endl;
+#endif
+  if(depth[publisher]){}
+  else{
+    publisher->notifyAll();
+    // this item is done, so we don't have to keep the count with us
+    // save some memory by erasing it
+    depth.erase(publisher);
+  }
+}
+
+void Observable::enque_notification_internal(Observable *publisher, Notification_ptr notification){
+  ASSERT(notification->owner==publisher,"Some object tried to send a notification it does not own");
+  notifications[publisher].insert(notification);
+}
+
+/** Constructor for Observable Protector.
+ * Basically, calls start_observer_internal(). Hence use this class instead of
+ * calling the function directly.
+ *
+ * \param *protege Observable to be protected.
+ */
+Observable::_Observable_protector::_Observable_protector(Observable *_protege) :
+  protege(_protege)
+{
+  start_observer_internal(protege);
+}
+
+Observable::_Observable_protector::_Observable_protector(const _Observable_protector &dest) :
+    protege(dest.protege)
+{
+  start_observer_internal(protege);
+}
+
+/** Destructor for Observable Protector.
+ * Basically, calls finish_observer_internal(). Hence use this class instead of
+ * calling the function directly.
+ *
+ * \param *protege Observable to be protected.
+ */
+Observable::_Observable_protector::~_Observable_protector()
+{
+  finish_observer_internal(protege);
+}
+
+/************* Notification mechanism for observables **************/
+
+/** Notify all Observers of changes.
+ * Puts \a *this into Observable::busyObservables, calls Observer::update() for all in callee_t
+ * and removes from busy list.
+ */
+void Observable::notifyAll() {
+  // we are busy notifying others right now
+  // add ourselves to the list of busy subjects to enable circle detection
+  busyObservables.insert(this);
+  // see if anyone has signed up for observation
+  // and call all observers
+  try {
+    if(callTable.count(this)) {
+      // elements are stored sorted by keys in the multimap
+      // so iterating over it gives us a the callees sorted by
+      // the priorities
+      callees_t callees = callTable[this];
+      callees_t::iterator iter;
+      for(iter=callees.begin();iter!=callees.end();++iter){
+#ifdef LOG_OBSERVER
+        observerLog().addMessage() << "-> Sending update from " << observerLog().getName(this)
+                                   << " to " << observerLog().getName((*iter).second)
+                                   << " (priority=" << (*iter).first << ")"<< endl;
+#endif
+        (*iter).second->update(this);
+      }
+    }
+  }
+  ASSERT_NOCATCH("Exception thrown from Observer Update");
+
+  // send out all notifications that need to be done
+
+  notificationSet currentNotifications = notifications[this];
+  for(notificationSet::iterator it = currentNotifications.begin();
+      it != currentNotifications.end();++it){
+    (*it)->notifyAll();
+  }
+
+  notifications.erase(this);
+
+   // done with notification, we can leave the set of busy subjects
+  busyObservables.erase(this);
+}
+
+
+/** Handles passing on updates from sub-Observables.
+ * Mimicks basically the Observer::update() function.
+ *
+ * \param *publisher The \a *this we observe.
+ */
+void Observable::update(Observable *publisher) {
+  // circle detection
+  if(busyObservables.find(this)!=busyObservables.end()) {
+    // somehow a circle was introduced... we were busy notifying our
+    // observers, but still we are called by one of our sub-Observables
+    // we cannot be sure observation will still work at this point
+    ASSERT(0,"Circle detected in observation-graph.\n"
+             "Observation-graph always needs to be a DAG to work correctly!\n"
+             "Please check your observation code and fix this!\n");
+    return;
+  }
+  else {
+    // see if we are in the process of changing ourselves
+    // if we are changing ourselves at the same time our sub-observables change
+    // we do not need to publish all the changes at each time we are called
+    if(depth.find(this)==depth.end()) {
+#ifdef LOG_OBSERVER
+      observerLog().addMessage() << "-* Update from " << observerLog().getName(publisher)
+                                 << " propagated by " << observerLog().getName(this) << endl;
+#endif
+      notifyAll();
+    }
+    else{
+#ifdef LOG_OBSERVER
+      observerLog().addMessage() << "-| Update from " <<  observerLog().getName(publisher)
+                                 << " not propagated by " << observerLog().getName(this) << endl;
+#endif
+    }
+  }
+}
+
+/** Sign on an Observer to this Observable.
+ * Puts \a *target into Observable::callTable list.
+ * \param *target Observer
+ * \param priority number in [-20,20]
+ */
+void Observable::signOn(Observer *target,int priority) {
+  ASSERT(priority>=-20 && priority<=+20, "Priority out of range [-20:+20] when signing on Observer");
+#ifdef LOG_OBSERVER
+  observerLog().addMessage() << "@@ Signing on " << observerLog().getName(target) << " to " << observerLog().getName(this) << endl;
+#endif
+  bool res = false;
+  callees_t &callees = callTable[this];
+
+  callees_t::iterator iter;
+  for(iter=callees.begin();iter!=callees.end();++iter){
+    res |= ((*iter).second == target);
+  }
+  if(!res)
+    callees.insert(pair<int,Observer*>(priority,target));
+}
+
+/** Sign off an Observer from this Observable.
+ * Removes \a *target from Observable::callTable list.
+ * \param *target Observer
+ */
+void Observable::signOff(Observer *target) {
+  ASSERT(callTable.count(this),"SignOff called for an Observable without Observers.");
+#ifdef LOG_OBSERVER
+  observerLog().addMessage() << "** Signing off " << observerLog().getName(target) << " from " << observerLog().getName(this) << endl;
+#endif
+  callees_t &callees = callTable[this];
+
+  callees_t::iterator iter;
+  callees_t::iterator deliter;
+  for(iter=callees.begin();iter!=callees.end();) {
+    if((*iter).second == target) {
+      callees.erase(iter++);
+    }
+    else {
+      ++iter;
+    }
+  }
+  if(callees.empty()){
+    callTable.erase(this);
+  }
+}
+
+void Observable::signOn(Observer *target, Notification_ptr notification){
+  ASSERT(notification->owner==this,
+         "Trying to sign on for a notification that is not provided by this object");
+
+  notification->addObserver(target);
+}
+
+void Observable::signOff(Observer *target, Notification_ptr notification){
+  ASSERT(notification->owner==this,
+         "Trying to sign off from a notification that is not provided by this object");
+
+  notification->removeObserver(target);
+}
+
+bool Observable::isBlocked(){
+  return depth.count(this) > 0;
+}
+
+/** Handles sub-observables that just got killed
+ *  when an sub-observerable dies we usually don't need to do anything
+ *  \param *publisher Sub-Observable.
+ */
+void Observable::subjectKilled(Observable *publisher){
+}
+
+/** Constructor for class Observable.
+ */
+Observable::Observable(string name) :
+  Observer(Observer::BaseConstructor())
+{
+#ifdef LOG_OBSERVER
+  observerLog().addName(this,name);
+  observerLog().addMessage() << "++ Creating Observable " << observerLog().getName(this) << endl;
+#endif
+}
+
+/** Destructor for class Observable.
+ * When an observable is deleted, we let all our observers know. \sa Observable::subjectKilled().
+ */
+Observable::~Observable()
+{
+#ifdef LOG_OBSERVER
+  observerLog().addMessage() << "-- Destroying Observable " << observerLog().getName(this) << endl;
+#endif
+  if(callTable.count(this)) {
+    // delete all entries for this observable
+    callees_t callees = callTable[this];
+    callees_t::iterator iter;
+    for(iter=callees.begin();iter!=callees.end();++iter){
+      (*iter).second->subjectKilled(this);
+    }
+    callTable.erase(this);
+  }
+}
+
+/** Constructor for class Observer.
+ */
+Observer::Observer(string name)
+{
+#ifdef LOG_OBSERVER
+  observerLog().addName(this,name);
+  observerLog().addMessage() << "++ Creating Observer " << observerLog().getName(this) << endl;
+#endif
+}
+
+/**
+ * Base Constructor for class Observer
+ *
+ * only called from Observable Constructor
+ */
+Observer::Observer(Observer::BaseConstructor){
+#ifdef LOG_OBSERVER
+  observerLog().addObservable(this);
+#endif
+}
+
+/** Destructor for class Observer.
+ */
+Observer::~Observer()
+{
+#ifdef LOG_OBSERVER
+  if(!observerLog().isObservable(this)){
+    observerLog().addMessage() << "-- Destroying Observer " << observerLog().getName(this) << endl;
+  }
+#endif
+}
+
+/**
+ * Method for specialized notifications.
+ * Most Observers wont need or use this, so it is implemented
+ * empty in the base case;
+ */
+void Observer::recieveNotification(Observable *publisher, Notification_ptr notification){
+  ASSERT(0,"Notification received by object that did not sign on for it.");
+}
+
+Notification::Notification(Observable *_owner) :
+    owner(_owner)
+{}
+
+Notification::~Notification(){}
+
+void Notification::addObserver(Observer *target){
+  targets.insert(target);
+}
+
+void Notification::removeObserver(Observer *target){
+  targets.erase(target);
+}
+
+void Notification::notifyAll(){
+  for(std::set<Observer*>::iterator it=targets.begin();
+      it!=targets.end();++it){
+    (*it)->recieveNotification(owner,this);
+  }
+}
+
+#ifdef LOG_OBSERVER
+
+/************************* Methods to do logging of the Observer Mechanism *********/
+
+// The log needs to exist fairly early, so we make it construct on first use,
+// and never destroy it
+ObserverLog &observerLog(){
+  // yes, this memory is never freed... we need it around for the whole programm,
+  // so no freeing is possible
+  static ObserverLog *theLog = Memory::ignore(new ObserverLog());
+  return *theLog;
+}
+
+
+ObserverLog::ObserverLog() :
+  count (0)
+{}
+
+ObserverLog::~ObserverLog(){}
+
+string ObserverLog::getLog(){return log.str();}
+
+std::string ObserverLog::getName(void* obj){
+  return names[obj];
+}
+
+bool ObserverLog::isObservable(void* obj){
+  return observables.count(obj);
+}
+
+void ObserverLog::addName(void* obj , string name){
+  stringstream sstr;
+  sstr << name << "_" << count++;
+  names[obj] = sstr.str();
+}
+
+void ObserverLog::addObservable(void* obj){
+  observables.insert(obj);
+}
+
+void ObserverLog::deleteName(void* obj){
+  names.erase(obj);
+}
+
+void ObserverLog::deleteObservable(void* obj){
+  observables.erase(obj);
+}
+
+stringstream &ObserverLog::addMessage(int depth){
+  for(int i=depth;i--;)
+    log << "  ";
+  return log;
+}
+
+#endif
Index: src/Patterns/Observer.hpp
===================================================================
--- src/Patterns/Observer.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Patterns/Observer.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,244 @@
+/*
+ * Observer.hpp
+ *
+ *  Created on: Jan 19, 2010
+ *      Author: crueger
+ */
+
+#ifndef OBSERVER_HPP_
+#define OBSERVER_HPP_
+
+#include <map>
+#include <set>
+#include <string>
+#include <sstream>
+
+/**
+ * Basic structure for the observer pattern
+ *
+ * Observers register themselves with the observables to be notified when something changes.
+ * In the Observable code that changes, attributes should be started with OBSERVE;. This macro
+ * locks the observer mechanism while changes are done. At the end of the scope in which the
+ * macro was placed the lock is released. When the last lock is released all changes are
+ * propagated to the observers.
+ *
+ * Each observerable can have sub-observables. When one of these sub-observables changes and
+ * notifies its observers the observable that contains them will also notify its observers.
+ * This passing on of updates is blocked, when the main-observable is in the process of
+ * updating many of its internal sub-observables. This means the update is not passed, if
+ * it is produced while the main-observable itself is within any Observation block.
+ */
+
+// Deactivate any logging when we are not in debug mode
+#ifdef NDEBUG
+#undef LOG_OBSERVER
+#endif
+
+class Observable;
+class Notification;
+
+// Pointers to notifications are used for unique identification
+// using this typedef makes it hard for others to mess up this
+// identification process
+typedef Notification *const Notification_ptr;
+
+template<class _Set>
+class ObservedIterator;
+
+/**
+ * An Observer is notified by all Observed objects, when anything changes.
+ *
+ * If a simple change is done to an Object the Obervable will call the update() method
+ * of all signed on observers, passing itself as a parameter for identification. The
+ * Observers should then react to the changes and update themselves accordingly.
+ *
+ * If an observed Object is destroyed it will call the subjectKilled() method
+ * of all signed on Observers, again passing itself as a parameter for identification.
+ * The Observers should handle the destruction of an observed Object gracefully, i.e.
+ * set themselves inactive, display something else, etc. There is no need
+ * to sign of from the dying object, since this will be handled by the Observable destructor.
+ */
+class Observer
+{
+  friend class Observable;
+  friend class Notification;
+  template<class> friend class ObservedIterator;
+
+  // indicates the constructor called from Observables
+  struct BaseConstructor{};
+
+public:
+  Observer(BaseConstructor);
+  Observer(std::string);
+  virtual ~Observer();
+
+protected:
+  /**
+   * This method is called upon changes of the Observable
+   */
+  virtual void update(Observable *publisher)=0;
+
+  /**
+   * This method is called when a special named change
+   * of the Observable occured
+   */
+  virtual void recieveNotification(Observable *publisher, Notification_ptr notification);
+
+  /**
+   * This method is called when the observed object is destroyed.
+   */
+  virtual void subjectKilled(Observable *publisher)=0;
+};
+
+/**
+ * An Observable implements all neccessary method for being observed.
+ *
+ * That is, it provides methods for signing on and of from an
+ * Observable that can be used by any observer. The actual
+ * observer-mechanism is handled at a central static place
+ * to avoid memory issues when many observable are around but only few
+ * are actually observed.
+ */
+class Observable : public Observer {
+public:
+  Observable(std::string _name);
+  virtual ~Observable();
+
+  /**
+   * Sign an Observer on to this Observable. The Observer will be notified
+   * whenever something inside the Observable changes. The Observer can
+   * assign itself a priority for the changes in the range of -20:+20.
+   * The Observer with lower priority will be called before the others,
+   * same as with Unix nice-levels. This can be used when an Object
+   * contains other objects that observe it (derived values), and these objects have
+   * to recalculate their states before the changes should be propageted to the
+   * UI. A default priority of 0 should be fine in most cases, since there is
+   * ussually no need to order the update sequence.
+   */
+  virtual void signOn(Observer *target, int priority=0);
+
+  /**
+   * Sign of a previously signed on Observer. After this no more
+   * updates will be recieved from that observer.
+   */
+  virtual void signOff(Observer *target);
+
+  /**
+   * Sign on for specialized notifications
+   */
+  virtual void signOn(Observer *target, Notification_ptr notification);
+
+  /**
+   * Stop receiving a specialized notification
+   */
+  virtual void signOff(Observer *target, Notification_ptr notification);
+
+  /**
+   * Ask an Observer if it is currently in a blocked state, i.e. if
+   * Changes are in Progress, that are not yet published.
+   */
+  virtual bool isBlocked();
+
+protected:
+  virtual void update(Observable *publisher);
+  virtual void subjectKilled(Observable *publisher);
+
+  virtual void notifyAll();
+protected:
+// Observer mechanism is done from a static central place
+  /**
+   * Internal method.
+   * Do not call directly. Use OBSERVE macro instead
+   */
+  static void start_observer_internal(Observable *publisher);
+  /**
+   * Internal method.
+   * Do not call directly. Use OBSERVE macro instead
+   */
+  static void finish_observer_internal(Observable *publisher);
+
+  static void enque_notification_internal(Observable *publisher, Notification_ptr notification);
+
+private:
+  typedef std::multimap<int,Observer*> callees_t;
+  typedef std::set<Notification*> notificationSet;
+  static std::map<Observable*, int> depth;
+  static std::map<Observable*,callees_t> callTable;
+  static std::map<Observable*,notificationSet> notifications;
+  static std::set<Observable*> busyObservables;
+
+  //! @cond
+  // Structure for RAII-Style notification
+protected:
+  /**
+   * This structure implements the Observer-mechanism RAII-Idiom.
+   * It triggers certain functions on creation and destruction so that
+   * Observer mechanisms can be linked to scope block.
+   */
+  class _Observable_protector {
+  public:
+    _Observable_protector(Observable *);
+    _Observable_protector(const _Observable_protector&);
+    ~_Observable_protector();
+  private:
+    Observable *protege;
+  };
+  //! @endcond
+};
+
+class Notification {
+  friend class Observable;
+public:
+  Notification(Observable *_owner);
+  virtual ~Notification();
+protected:
+
+  void addObserver(Observer *target);
+  void removeObserver(Observer *target);
+
+  void notifyAll();
+private:
+  Observable * const owner;
+  std::set<Observer*> targets;
+};
+
+#ifdef LOG_OBSERVER
+
+/**
+ * This class is used to log the working of the observer mechanism
+ *
+ * TODO: make this conditional dependent on compiler Flag.
+ */
+class ObserverLog{
+  friend class Observable;
+  friend class Observer;
+  template <typename> friend class Cacheable;
+public:
+  ObserverLog();
+  ~ObserverLog();
+  std::string getLog();                        // get everything that has been logged
+  std::string getName(void*);                  // get the name of an actor
+  bool isObservable(void*);
+private:
+  int count;                                   // number to reference each actor in this framework
+  std::map<void*,std::string> names;           // List of names assigned to actors
+  std::set<void*> observables;                 // List of pointers to Observables. Needed to distinguish Observers and Observables
+  void addName(void*, std::string);            // Assign a name to an Actor
+  void addObservable(void*);
+  void deleteName(void*);                      // delete the name of an Actor
+  void deleteObservable(void*);
+  std::stringstream &addMessage(int depth=0);  // Add a Message to the logging
+  std::stringstream log;                       // The internal log object
+};
+
+ObserverLog &observerLog();
+
+#endif
+
+// extra macro is necessary to work with __LINE__
+#define PASTE(a,b) PASTE_HELPER(a,b)
+#define PASTE_HELPER(a,b) a ## b
+#define OBSERVE Observable::_Observable_protector PASTE(_scope_obs_protector_,__LINE__)(this)
+#define NOTIFY(notification) do{Observable::enque_notification_internal(this,notification);}while(0)
+
+#endif /* OBSERVER_HPP_ */
Index: src/Patterns/Singleton.hpp
===================================================================
--- src/Patterns/Singleton.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Patterns/Singleton.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,279 @@
+/*
+ * Singleton.hpp
+ *
+ *  Created on: Mar 10, 2010
+ *      Author: crueger
+ */
+
+#ifndef SINGLETON_HPP_
+#define SINGLETON_HPP_
+
+#include <boost/thread.hpp>
+
+#include "Helpers/Assert.hpp"
+#include "defs.hpp"
+
+/**
+ * This template produces the generic singleton pattern using the CRTP idiom.
+ *
+ * <h1> Singleton Howto </h1>
+ * <h2> Introduction </h2>
+ *
+ * A Singleton is a class of which there can only be a single Object in the programm. It is
+ * described as an design-pattern in Gof:96 (the famous design-pattern book). In the
+ * molecuilder there are so far several Singletons serving a wide range of purposes:
+ *
+ * - the World, which handles all atoms, molecules and bonds
+ * - the ActionRegistry, which stores all created actions by name for later use
+ * - the UIFactory, which is an AbstractFactory (another design-pattern from Gof:96) and
+ *   handles all creation of gui elements to ensure a single type throughout the programm
+ * - the logger and errorLogger classes, that can be used to output messages on the screen
+ *   depending on certain conditions
+ *
+ * Because those classes can only be instantiated once you cannot simply call <code>new World()</code>
+ * or <code>delete</code> on them. Rather they have to be constructed and accessed using the singleton
+ * mechanism. This mechanism consists of four static functions (and a fifth that is used internally,
+ * but we will get to that later). These functions are:
+ *
+ * - <code>Singleton& Singleton::getInstance()</code> : returns the instance of the singleton as
+ *    a reference
+ * - <code>Singleton* Singleton::getPointer()</code> : returns the instance of the singleton as a
+ *    pointer
+ * - <code>void Singleton::purgeInstance()</code> : destroys the single Instance of the singleton
+ * - <code>Singleton& Singleton::resetInstance()</code> : resets the Singleton, i.e. destroys the
+ *    old instance and creates a new one
+ *
+ * If you need the instance of the singleton it is usually fine just to use one off the accessor
+ * functions (i.e. <code>getInstance()</code> or <code>getPointer()</code>. Any creation of the
+ * Singleton is then handled by these functions, so that the same object will be returned whenever
+ * one of these functions is called. This easy process is true for most singletons you will need
+ * to use. The only special singleton is the UIFactory.
+ *
+ * <h3>Special functions of the UIFactory</h3>
+ *
+ * If you simply call the <code>getInstance()</code> method of the UIFactory class the program
+ * will crash. This happens, because the UIFactory in itself is abstract and needs to know what
+ * kind of user interface it should produce later on. You need to tell the class the type of UI
+ * using the void <code>UIFactory::makeUserInterface(InterfaceTypes type)</code> method. This will
+ * also take care of creating the sole instance, so that the accessor functions will work afterwards.
+ * What this also means is, that you cannot <code>reset()</code> the UIFactory, because at that
+ * point it wont know anymore what to construct. A sequence of <code>UIFactory::purgeInstance()</code>,
+ * <code>UIFactory::makeUserInterface()</code> and <code>UIFactory::getInstance()</code> will work
+ * though.
+ *
+ * In order to make life easier and propagate changes to the singleton mechanism to all those
+ * classes, there is a simple framework class that can be used to make any other class a
+ * singleton through inheritance. This class can be found in the Pattern directory.
+ *
+ * <h2>How to make a class Singleton</h2>
+ *
+ * Most of the time you will only need singletons that don't require additional
+ * information for creation. So I will cover the basic case for constructing singletons
+ * first and then explain what has to be changed to make it accept special parameters.
+ * Singletons are created by inheriting from the <code>Singleton<class T></code> template
+ * using the Curiously recurring template pattern (CRTP). What this means is, that the
+ * class they inherit from carries the inheriting class as a template parameter. For example
+ * <code>class MySingletonExaple : public Singleton<MySingletonExample>{...}</code>. If you
+ * want to know more about this idiom have a look at the
+ * <A HREF="http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern">wikipedia
+ * page for this idiom</A>, but don't worry if you don't quite get how this works for now, for
+ * the use of the singleton framework this is not important.
+ *
+ * If you want to make a class a singleton you can use the following sequence of steps.
+ *
+ * - Inherit from the singleton pattern using the CRTP as above:<br>
+ *   @code
+ *     class MySingletonExaple : public Singleton<MySingletonExample>{ ...}
+ *   @endcode
+ * - Make constructor and destructor private to avoid creation or destruction from
+ *   outside the class:<br>
+ *    @code
+ *      class MySingletonExaple : public Singleton<MySingletonExample>{
+ *        private:
+ *          MySingletonExample();
+ *          ~MySingletonExample();
+ *      ...}
+ *    @endcode
+ * - give the inherited class access to the class internals using a friend declaration:<br>
+ *    @code
+ *       class MySingletonExaple : public Singleton<MySingletonExample>{
+ *         friend class Singleton<MySingletonExample>; // don't forget the template parameters here
+ *         private:
+ *           MySingletonExample();
+ *           ~MySingletonExample();
+ *       ...}
+ *    @endcode
+ *
+ * - include the file "Patterns/Singleton_impl.hpp" that carries the implementation details of
+ *   the singleton functions in your implementation file of the class.
+ * - make the compiler construct the template instantiations. For this you can use the defined
+ *   keyword <code>CONSTRUCT_SINGLETON(name)</code> at any toplevel point in the implementation
+ *   file:<br>
+ *    @code
+ *       void MySingletonExample::foo(){...}
+ *       void MySingletonExample::bar(){...}
+ *       CONSTRUCT_SINGLETON(MySingletonExample) // no ; after this
+ *     @endcode
+ *
+ * <h3>Singleton with initialization parameters</h3>
+ *
+ * Sometimes it is necessary for a singleton to be passed some initilization parameters. For
+ * example the UIFactory mentioned above needs to know what kind of user interface it has to
+ * produce. Making a singleton that takes initialization parameters is only sligtly different
+ * from the steps lined out above. Here are all the differences:
+ *
+ * - pass an extra <code>false</code> to the template to deactivate the standard instantiation
+ *   mechanism
+ * - write a method that handles the special parameters and instantiation. In this method you
+ *   can use the <code>setInstance(T*)</code> method inherited from the singleton pattern to set
+ *   the created instance. The <code>setInstance()</code> method will only work when the
+ *   <code>false<code> template parameter has been set and produce errors otherwise.
+ *
+ */
+template <class T, bool _may_create=true>
+class Singleton
+{
+private:
+  /**
+   * simple auto_ptr that is used by Singleton template
+   *
+   * This ptr_t allows destruction of the object using a private destructor,
+   * when only the Singleton pattern is friend with the class
+   *
+   * All methods have similar sematics to auto_ptr
+   */
+  class ptr_t {
+  public:
+    ptr_t();
+    ptr_t(T* _content);
+    ~ptr_t();
+    T& operator*();
+    T* get();
+    void reset(T* _content);
+    void reset();
+    ptr_t& operator=(const ptr_t& rhs);
+  private:
+    mutable T* content;
+  };
+
+  /**
+   * This object handles the actual creation inside the singleton
+   *
+   * Using template specialization this will allways know what it can
+   * do or cannot do at compile time
+   */
+  template<class creator_T, bool creator_may_create>
+  struct creator_t {
+    inline static creator_T* make();
+    inline static void set(creator_T*&,creator_T*);
+  };
+
+  // specialization to allow fast creations
+
+  /**
+   * Specialized template that allows automatic construction only
+   */
+  template<class creator_T>
+  struct creator_t<creator_T,true>{
+    inline static creator_T* make(){
+      return new creator_T();
+    }
+
+    inline static void set(creator_T*&,creator_T*){
+      ASSERT(0, "Cannot set the Instance for a singleton of this type");
+    }
+  };
+
+  /**
+   * specialized template that allows setting only
+   */
+  template<class creator_T>
+  struct creator_t<creator_T,false>{
+    inline static creator_T* make(){
+      ASSERT(0, "Cannot create a singleton of this type directly");
+      return 0;
+    }
+    inline static void set(ptr_t& dest,creator_T* src){
+      dest.reset(src);
+    }
+  };
+
+  // this is used for creation
+  typedef creator_t<T,_may_create> creator; //< the creator used
+
+public:
+  // make the state of this singleton accessible
+  static const bool may_create=_may_create; //!< the type of singleton that we have
+
+  /**
+   * returns the instance of this Singleton as a reference
+   *
+   * If no Singleton exists at this point and we are allowed to create one
+   * a new one is created and stored inside the singleton
+   *
+   * If no automatic creation is allowed, make sure to create an instance first
+   * using the appropriate methods of the derived class. Otherwise this method
+   * would fail.
+   */
+  static T& getInstance();
+
+  /**
+   * returns the instance of this singleton as a pointer
+   *
+   * If no Singleton exists at this point and we are allowed to create one
+   * a new one is created and stored inside the singleton.
+   *
+   * If no automatic creation is allowed, make sure to create an instance first
+   * using the appropriate methods of the derived class. Otherwise this method
+   * would fail.
+   */
+  static T* getPointer();
+
+  /**
+   * destroys the current instance of this singleton
+   */
+  static void purgeInstance();
+
+  /**
+   * destroys the current instance of the singleton and immidiately constructs
+   * a new one. Similar to using <code>purgeInstance()</code> and <code>getInstance()</code>
+   * but plays more nicely when observers are present. Especially the new instance is created
+   * before the old one is destroyed so observers can switch their targets, when they are notified
+   * of the destruction.
+   *
+   * If no automatic creation is allowed this method wont work.
+   */
+  static T&   resetInstance();
+
+protected:
+  /**
+   * Method used to set the instance, when no automatic creation is allowed.
+   *
+   * Call this after the instantiation method in the derived class has created
+   * it's instance and want's the singleton mechanism to keep it around for later
+   * use.
+   *
+   * This method will always fail when automatic creation is enabled.
+   */
+  static void setInstance(T*);
+
+
+  /**
+   * empty constructor to allow creation of subclases
+   */
+  Singleton();
+
+private:
+  /**
+   * the copy constructor is private to avoid accidental copying of Singletons, for example
+   * when passing singletons to functions by value instead of by reference. If you
+   * need copying of singletons call the default constructor in the copy constructor
+   * of the derived object. The copyied object wont be known to the singleton mechanism.
+   */
+  Singleton(const Singleton&);
+
+  static boost::recursive_mutex instanceLock; //!< a lock for the pointer of the instance
+  static ptr_t theInstance; //!< the actual instance of the singleton
+};
+
+#endif /* SINGLETON_HPP_ */
Index: src/Patterns/Singleton_impl.hpp
===================================================================
--- src/Patterns/Singleton_impl.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Patterns/Singleton_impl.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,142 @@
+/*
+ * Singleton_impl.hpp
+ *
+ *  Created on: Mar 10, 2010
+ *      Author: crueger
+ */
+
+#ifndef SINGLETON_IMPL_HPP_
+#define SINGLETON_IMPL_HPP_
+
+#include "Patterns/Singleton.hpp"
+
+/****** Static instance Variables of the template *******/
+
+template <class T,bool _may_create>
+typename Singleton<T,_may_create>::ptr_t Singleton<T,_may_create>::theInstance(0);
+
+template <class T,bool _may_create>
+boost::recursive_mutex Singleton<T,_may_create>::instanceLock;
+
+/****** templates singleton creation and destruction functions ******/
+
+template <class T,bool _may_create>
+T& Singleton<T,_may_create>::getInstance(){
+  // boost supports RAII-Style locking, so we don't need to unlock
+  boost::recursive_mutex::scoped_lock guard(instanceLock);
+  if(!theInstance.get()) {
+    theInstance.reset(creator::make());
+  }
+  return *theInstance;
+}
+
+template <class T,bool _may_create>
+T* Singleton<T,_may_create>::getPointer(){
+  // boost supports RAII-Style locking, so we don't need to unlock
+  boost::recursive_mutex::scoped_lock guard(instanceLock);
+  if(!theInstance.get()) {
+    theInstance.reset(creator::make());
+  }
+  return theInstance.get();
+
+}
+
+template <class T,bool _may_create>
+void Singleton<T,_may_create>::purgeInstance(){
+  // boost supports RAII-Style locking, so we don't need to unlock
+  boost::recursive_mutex::scoped_lock guard(instanceLock);
+  theInstance.reset();
+}
+
+template <class T,bool _may_create>
+T& Singleton<T,_may_create>::resetInstance(){
+  ptr_t oldInstance;
+  {
+    // boost supports RAII-Style locking, so we don't need to unlock
+    boost::recursive_mutex::scoped_lock guard(instanceLock);
+
+    oldInstance = theInstance;
+    theInstance.reset(creator::make());
+    // oldworld does not need protection any more,
+    // since we should have the only reference
+
+    // worldLock handles access to the pointer,
+    // not to the object
+  } // scope-end releases the lock
+
+  // oldInstance goes out of scope at the End of this function. The carried object will then be destroyed by the auto_ptr
+  return *theInstance;
+}
+
+
+template <class T,bool _may_create>
+void Singleton<T,_may_create>::setInstance(T* newInstance){
+  ASSERT(!theInstance.get(), "Trying to set the instance of an already created singleton");
+  boost::recursive_mutex::scoped_lock guard(instanceLock);
+  theInstance.reset(newInstance);
+}
+
+template<class T, bool _may_create>
+Singleton<T,_may_create>::Singleton(){/* empty */}
+
+// private copy constructor to avoid unintended copying
+template <class T, bool _may_create>
+Singleton<T,_may_create>::Singleton(const Singleton<T,_may_create>&){
+  ASSERT(0, "Copy constructor of singleton template called");
+}
+
+/**
+ * This define allows simple instantiation of the necessary singleton functions
+ * at a chosen place.
+ */
+#define CONSTRUCT_SINGLETON(name) \
+    template name& Singleton< name , name::may_create >::getInstance(); \
+    template name* Singleton< name , name::may_create >::getPointer();  \
+    template void  Singleton< name , name::may_create >::purgeInstance(); \
+    template name& Singleton< name , name::may_create >::resetInstance(); \
+    template void  Singleton< name , name::may_create >::setInstance( name* );
+
+/************ Internal Pointer Wrapper to allow automatic purging *************/
+
+template <class T,bool _may_create>
+Singleton<T,_may_create>::ptr_t::ptr_t() :
+content(0){};
+
+template <class T,bool _may_create>
+Singleton<T,_may_create>::ptr_t::ptr_t(T* _content) :
+content(_content){};
+
+template <class T,bool _may_create>
+Singleton<T,_may_create>::ptr_t:: ~ptr_t()
+{delete content;};
+
+template <class T,bool _may_create>
+T& Singleton<T,_may_create>::ptr_t::operator*()
+{return *content;};
+
+template <class T,bool _may_create>
+T* Singleton<T,_may_create>::ptr_t::get()
+{return content;};
+
+template <class T,bool _may_create>
+void Singleton<T,_may_create>::ptr_t::reset(T* _content){
+  delete content;
+  content = _content;
+}
+
+template <class T,bool _may_create>
+void Singleton<T,_may_create>::ptr_t::reset()
+{reset(0);}
+
+template <class T,bool _may_create>
+typename Singleton<T,_may_create>::ptr_t& Singleton<T,_may_create>::ptr_t::operator=(const typename Singleton<T,_may_create>::ptr_t& rhs){
+  if(&rhs!=this){
+    delete content;
+    content = rhs.content;
+    rhs.content = 0;
+  }
+  return *this;
+}
+
+
+#endif /* SINGLETON_IMPL_HPP_ */
Index: src/Plane.cpp
===================================================================
--- src/Plane.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Plane.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,212 @@
+/*
+ * 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: src/Plane.hpp
===================================================================
--- src/Plane.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Plane.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,77 @@
+/*
+ * 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/ReMapDBondFileFromXYZ.py
===================================================================
--- src/ReMapDBondFileFromXYZ.py	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/ReMapDBondFileFromXYZ.py	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,201 @@
+#!/usr/bin/python
+#
+# Takes two pdb file and a dbond file, matches the coordinates and thus creates a mapping from old ids to new ids.
+
+import sys, random, math, re
+wrerr=sys.stderr.write
+wrout=sys.stdout.write
+
+# check arguments
+if len(sys.argv) < 5:
+	print "Usage: "+sys.argv[0]+" <srcPDBfile> <destXYZfile> <offsetID> <offsetXYZ> <srcDBONDfile> [destDBONDfile]" 
+	sys.exit(1)
+
+EPSILON=1e-3
+CUTOFF=2.
+inputsrcPDB = open(sys.argv[1], "r")
+inputdestPDB = open(sys.argv[2], "r")
+inputsrcDBOND = open(sys.argv[5], "r")
+offsetID=int(sys.argv[3])
+offsetXYZ=int(sys.argv[4])
+if len(sys.argv) > 6:
+	output = open(sys.argv[6],"w")
+else:
+	output = open(sys.argv[5]+".new", "w")
+
+# 1. first parse both PDB files into arrays (id, element, xyz) , therewhile scan BoundaryBoxes
+max = [ 0., 0., 0. ]
+min = [ 0., 0., 0. ]
+x = [ 0., 0., 0. ]
+print "Scanning source PDB file"+sys.argv[1]+"."
+srcAtoms = []
+for line in inputsrcPDB:
+	if "#" in line:
+		continue
+	if "END" in line:
+		break
+	if "ATOM" in line:
+		entries = line.split()
+		for n in range(3):
+			x[n] = float(entries[offsetXYZ+n])
+			if x[n] > max[n]:
+				max[n] = x[n]
+			if x[n] < min[n]:
+				min[n] = x[n]
+		srcAtoms.append([int(entries[offsetID]), x[0], x[1], x[2]])
+inputsrcPDB.close()
+print "Scanning destination XYZ file"+sys.argv[2]+"."
+destAtoms = []
+index = 0
+for line in inputdestPDB:
+	entries = line.split()
+	if (len(entries)<1 or (entries[0]!="O" and entries[0]!="Si" and entries[0]!="Ca")):
+		continue
+	for n in range(3):
+		x[n] = float(entries[1+n])
+		if x[n] > max[n]:
+			x[n]-=max[n]
+		if x[n] < min[n]:
+			x[n]+=max[n]
+	destAtoms.append([index, x[0], x[1], x[2]])
+	index+=1
+inputdestPDB.close()
+
+# 2. create Linked Cell with minimum distance box length
+print "Found Box bounds [%f,%f]x[%f,%f]x[%f,%f]." % (min[0],max[0],min[1],max[1],min[2],max[2])
+for i in range(3):      # shift by minimum if below zero
+  if min[i] < 0:
+    max[i]-=min[i]
+  else:
+    min[i]=0
+cells_x=int(math.ceil(float(max[0])/CUTOFF))
+cells_y=int(math.ceil(float(max[1])/CUTOFF))
+cells_z=int(math.ceil(float(max[2])/CUTOFF))
+print "Number of cells in each axis direction (%f,%f,%f)." % (cells_x, cells_y, cells_z)
+
+# 3. put each atom into its cell, lists may contain multiple atoms, mark src(0) or dest (1)
+cell=[]
+for i in range(cells_x):
+  cell.append([])
+  for j in range(cells_y):
+    cell[i].append([])
+    for k in range(cells_z):
+      cell[i][j].append([0])
+for i in range(len(srcAtoms)):
+	atom = srcAtoms[i]
+	print atom
+	for n in range(3):
+		x[n] = int(math.floor(float(atom[1+n])/CUTOFF))
+	if cells_x ==x[0]:
+		x[0]-=1
+	if cells_y ==x[1]:
+		x[1]-=1
+	if cells_z ==x[2]:
+		x[2]-=1
+	print x
+	cell[x[0]][x[1]][x[2]][0]+=1
+	cell[x[0]][x[1]][x[2]].append([0,i])	# 0 means src
+	print "Source atom "+str(i)+" goes to cell "+str(x[0])+","+str(x[1])+","+str(x[2])+"."
+for i in range(len(destAtoms)):
+	atom = destAtoms[i]
+	for n in range(3):
+		x[n] = int(math.floor(float(atom[1+n])/CUTOFF))	
+	cell[x[0]][x[1]][x[2]][0]+=1
+	cell[x[0]][x[1]][x[2]].append([1,i])	# 1 means dest
+	print "Destination atom "+str(i)+" goes to cell "+str(x[0])+","+str(x[1])+","+str(x[2])+"."
+
+# 4. go through each cell and match (src, dest)-pairs by closest distance, warn if greater than EPSILON
+srcMatches=0
+destMatches=0
+Map = {}
+i=-1
+j=-1
+k=-1
+l=-1
+e=-1
+r=-1
+t=-1
+m=-1
+for i in range(cells_x):
+	for j in range(cells_y):
+		for k in range(cells_z):
+			
+			#go through every atom in cell
+			try:
+				for l in range(1, cell[i][j][k][0]+1):
+					if cell[i][j][k][l][0] != 0:	# skip if it's not a src atom
+						continue
+					atom1=cell[i][j][k][l][1]
+					print "Current source atom is "+str(srcAtoms[atom1][0])+"."
+					currentPair=[atom1,-1]
+					oldDist=0.
+					# go through cell and all lower neighbours
+					for e in range(i-1,i+2):
+						#if on boarder continue periodic
+						#if e>cells_x-1:
+						#	e=e-cells_x
+						if (e < 0) or (e >= cells_x):
+							continue
+						for r in range(j-1,j+2):
+							#if on boarder continue periodic
+							#if r>cells_y-1:
+							#	r=r-cells_y
+							if (r < 0) or (r >= cells_y):
+								continue
+							for t in range(k-1,k+2):
+								#if on boarder continue periodic
+								#if t>cells_z-1:
+								#	t=t-cells_z
+								if (t < 0) or (t >= cells_z):
+									continue
+								#go through all atoms in cell				
+								for m in range(1, cell[e][r][t][0]+1):
+									if cell[e][r][t][m][0] != 1:		# skip if it's not a dest atom
+										continue
+									atom2=cell[e][r][t][m][1]
+									print "Current destination atom is "+str(destAtoms[atom2][0])+"."
+									dist=0
+									tmp=0
+									for n in range(3):
+										tmp = srcAtoms[atom1][1+n] - destAtoms[atom2][1+n]
+										dist += tmp*tmp
+									print "Squared distance between the two is "+str(dist)+"."
+									if ((oldDist > dist) or ((currentPair[1] == -1) and (dist<EPSILON))):
+										currentPair[1] = atom2
+										oldDist = dist
+					if currentPair[1] == -1:
+						print"Could not find a suitable partner for srcAtom (%d,%d)!\n" % (srcAtoms[currentPair[0]][0],currentPair[1])
+						Map[ srcAtoms[currentPair[0]][0] ] = currentPair[1]
+					else:
+						print "Found a suitable partner for srcAtom "+str(srcAtoms[currentPair[0]][0])+","+str(destAtoms[currentPair[1]][0])+"."
+						srcMatches+=1
+						destMatches+=1
+						Map[ srcAtoms[currentPair[0]][0] ] = destAtoms[currentPair[1]][0]
+			except IndexError:
+				wrerr("Index Error: (%d,%d,%d)[%d] and (%d,%d,%d)[%d]\n" % (i,j,k,l,e,r,t,m))
+				break
+
+# 5. print the listing
+print "We have "+str(srcMatches)+" matching atoms."
+print "Mapping is:"
+for key in Map:
+	print str(key)+" -> "+str(Map[key])
+#print Map		# work also
+
+# 6. use the listing to rewrite the dbond file, store under given filename
+for line in inputsrcDBOND:
+	if "#" in line:
+		continue
+	entries=line.split()
+	flag=0
+	for n in range(len(entries)):
+		if int(entries[n]) == 0 or Map[ int(entries[n]) ] == -1:
+			flag=1
+	if flag==1:
+		continue
+	for n in range(len(entries)):
+		output.write("%d\t" % (Map[ int(entries[n]) ]))
+	output.write("\n")
+output.close()
+print "We have "+str(srcMatches)+" matching atoms."
+# exit
Index: src/Space.cpp
===================================================================
--- src/Space.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Space.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+/*
+ * 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: src/Space.hpp
===================================================================
--- src/Space.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/Space.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -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/ThermoStatContainer.cpp
===================================================================
--- src/ThermoStatContainer.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/ThermoStatContainer.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,52 @@
+/*
+ * ThermoStatContainer.cpp
+ *
+ *  Created on: 12.06.2010
+ *      Author: heber
+ */
+
+#include <cstring>
+
+#include "ConfigFileBuffer.hpp"
+#include "config.hpp"
+#include "log.hpp"
+#include "ThermoStatContainer.hpp"
+#include "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)
+{
+  ThermostatImplemented = new int[MaxThermostats];
+  ThermostatNames = new char *[MaxThermostats];
+  for (int j=0;j<MaxThermostats;j++)
+    ThermostatNames[j] = new char[12];
+
+  strcpy(ThermostatNames[0],"None");
+  ThermostatImplemented[0] = 1;
+  strcpy(ThermostatNames[1],"Woodcock");
+  ThermostatImplemented[1] = 1;
+  strcpy(ThermostatNames[2],"Gaussian");
+  ThermostatImplemented[2] = 1;
+  strcpy(ThermostatNames[3],"Langevin");
+  ThermostatImplemented[3] = 1;
+  strcpy(ThermostatNames[4],"Berendsen");
+  ThermostatImplemented[4] = 1;
+  strcpy(ThermostatNames[5],"NoseHoover");
+  ThermostatImplemented[5] = 1;
+}
+
+/** Destructor for Class ThermoStatContainer.
+ *
+ */
+ThermoStatContainer::~ThermoStatContainer()
+{
+  delete[](ThermostatImplemented);
+  for (int j=0;j<MaxThermostats;j++)
+    delete[](ThermostatNames[j]);
+  delete[](ThermostatNames);
+}
+
+
Index: src/ThermoStatContainer.hpp
===================================================================
--- src/ThermoStatContainer.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/ThermoStatContainer.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,38 @@
+/*
+ * ThermoStatContainer.hpp
+ *
+ *  Created on: 12.06.2010
+ *      Author: heber
+ */
+
+#ifndef THERMOSTATCONTAINER_HPP_
+#define THERMOSTATCONTAINER_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+class ConfigFileBuffer;
+
+#define 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
+
+class ThermoStatContainer {
+public:
+  ThermoStatContainer();
+  ~ThermoStatContainer();
+
+  void ParseThermostats(class ConfigFileBuffer * const fb);
+
+  int Thermostat;
+  int *ThermostatImplemented;
+  char **ThermostatNames;
+  double TempFrequency;
+  double alpha;
+  double HooverMass;
+  double TargetTemp;
+  int ScaleTempStep;
+};
+
+#endif /* THERMOSTATCONTAINER_HPP_ */
Index: src/UIElements/CommandLineUI/CommandLineDialog.cpp
===================================================================
--- src/UIElements/CommandLineUI/CommandLineDialog.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/CommandLineUI/CommandLineDialog.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,293 @@
+/*
+ * CommandLineDialog.cpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include <iostream>
+#include <vector>
+
+#include <Descriptors/AtomDescriptor.hpp>
+#include <Descriptors/AtomIdDescriptor.hpp>
+#include <Descriptors/MoleculeDescriptor.hpp>
+#include <Descriptors/MoleculeIdDescriptor.hpp>
+#include "CommandLineUI/CommandLineDialog.hpp"
+
+#include "Actions/Values.hpp"
+
+#include "element.hpp"
+#include "periodentafel.hpp"
+#include "CommandLineParser.hpp"
+#include "defs.hpp"
+#include "log.hpp"
+#include "periodentafel.hpp"
+#include "verbose.hpp"
+#include "World.hpp"
+
+#include "atom.hpp"
+#include "element.hpp"
+#include "molecule.hpp"
+#include "vector.hpp"
+
+using namespace std;
+
+
+CommandLineDialog::CommandLineDialog()
+{
+}
+
+CommandLineDialog::~CommandLineDialog()
+{
+}
+
+
+void CommandLineDialog::queryEmpty(const char* title, string _description){
+  registerQuery(new EmptyCommandLineQuery(title, _description));
+}
+
+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));
+}
+
+/************************** Query Infrastructure ************************/
+
+CommandLineDialog::EmptyCommandLineQuery::EmptyCommandLineQuery(string title, string _description) :
+    Dialog::EmptyQuery(title, _description)
+{}
+
+CommandLineDialog::EmptyCommandLineQuery::~EmptyCommandLineQuery() {}
+
+bool CommandLineDialog::EmptyCommandLineQuery::handle() {
+  cout << "Message of " << getTitle() << ":\n" << getDescription() << "\n";
+  return true;
+}
+
+CommandLineDialog::IntCommandLineQuery::IntCommandLineQuery(string title,int *_target, string _description) :
+    Dialog::IntQuery(title,_target, _description)
+{}
+
+CommandLineDialog::IntCommandLineQuery::~IntCommandLineQuery() {}
+
+bool CommandLineDialog::IntCommandLineQuery::handle() {
+  if (CommandLineParser::getInstance().vm.count(getTitle())) {
+    tmp = CommandLineParser::getInstance().vm[getTitle()].as<int>();
+    return true;
+  } else {
+    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing integer for " << getTitle() << "." << endl);
+    return false;
+  }
+}
+
+CommandLineDialog::BooleanCommandLineQuery::BooleanCommandLineQuery(string title,bool *_target, string _description) :
+    Dialog::BooleanQuery(title,_target, _description)
+{}
+
+CommandLineDialog::BooleanCommandLineQuery::~BooleanCommandLineQuery() {}
+
+bool CommandLineDialog::BooleanCommandLineQuery::handle() {
+  if (CommandLineParser::getInstance().vm.count(getTitle())) {
+    tmp = CommandLineParser::getInstance().vm[getTitle()].as<bool>();
+    return true;
+  } else {
+    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing boolean for " << getTitle() << "." << endl);
+    return false;
+  }
+}
+
+CommandLineDialog::StringCommandLineQuery::StringCommandLineQuery(string title,string *_target, string _description) :
+    Dialog::StringQuery(title,_target, _description)
+{}
+
+CommandLineDialog::StringCommandLineQuery::~StringCommandLineQuery() {}
+
+bool CommandLineDialog::StringCommandLineQuery::handle() {
+  if (CommandLineParser::getInstance().vm.count(getTitle())) {
+    tmp = CommandLineParser::getInstance().vm[getTitle()].as<string>();
+    return true;
+  } else {
+    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing string for " << getTitle() << "." << endl);
+    return false;
+  }
+}
+
+CommandLineDialog::StringsCommandLineQuery::StringsCommandLineQuery(string title,vector<string> *_target, string _description) :
+    Dialog::StringsQuery(title,_target, _description)
+{}
+
+CommandLineDialog::StringsCommandLineQuery::~StringsCommandLineQuery() {}
+
+bool CommandLineDialog::StringsCommandLineQuery::handle() {
+  if (CommandLineParser::getInstance().vm.count(getTitle())) {
+    tmp = CommandLineParser::getInstance().vm[getTitle()].as< vector<string> >();
+    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)
+{}
+
+CommandLineDialog::DoubleCommandLineQuery::~DoubleCommandLineQuery() {}
+
+bool CommandLineDialog::DoubleCommandLineQuery::handle() {
+  if (CommandLineParser::getInstance().vm.count(getTitle())) {
+    tmp = CommandLineParser::getInstance().vm[getTitle()].as<double>();
+    return true;
+  } else {
+    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing double for " << getTitle() << "." << endl);
+    return false;
+  }
+}
+
+CommandLineDialog::AtomCommandLineQuery::AtomCommandLineQuery(string title, atom **_target, string _description) :
+    Dialog::AtomQuery(title,_target, _description)
+{}
+
+CommandLineDialog::AtomCommandLineQuery::~AtomCommandLineQuery() {}
+
+bool CommandLineDialog::AtomCommandLineQuery::handle() {
+  int IdxOfAtom = -1;
+  if (CommandLineParser::getInstance().vm.count(getTitle())) {
+    IdxOfAtom = CommandLineParser::getInstance().vm[getTitle()].as<int>();
+    tmp = World::getInstance().getAtom(AtomById(IdxOfAtom));
+    return true;
+  } else {
+    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing atom for " << getTitle() << "." << endl);
+    return false;
+  }
+}
+
+CommandLineDialog::MoleculeCommandLineQuery::MoleculeCommandLineQuery(string title, molecule **_target, string _description) :
+    Dialog::MoleculeQuery(title,_target, _description)
+{}
+
+CommandLineDialog::MoleculeCommandLineQuery::~MoleculeCommandLineQuery() {}
+
+bool CommandLineDialog::MoleculeCommandLineQuery::handle() {
+  int IdxOfMol = -1;
+  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;
+    return true;
+  } else {
+    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing molecule for " << getTitle() << "." << endl);
+    return false;
+  }
+}
+
+CommandLineDialog::VectorCommandLineQuery::VectorCommandLineQuery(string title, Vector *_target, const double *const _cellSize, bool _check, string _description) :
+    Dialog::VectorQuery(title,_target,_cellSize,_check, _description)
+{}
+
+CommandLineDialog::VectorCommandLineQuery::~VectorCommandLineQuery()
+{}
+
+bool CommandLineDialog::VectorCommandLineQuery::handle() {
+  VectorValue temp;
+  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;
+    return true;
+  } else {
+    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing vector for " << getTitle() << "." << endl);
+    return false;
+  }
+}
+
+
+CommandLineDialog::BoxCommandLineQuery::BoxCommandLineQuery(string title, double ** const _cellSize, string _description) :
+    Dialog::BoxQuery(title,_cellSize, _description)
+{}
+
+CommandLineDialog::BoxCommandLineQuery::~BoxCommandLineQuery()
+{}
+
+bool CommandLineDialog::BoxCommandLineQuery::handle() {
+  BoxValue temp;
+  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;
+    return true;
+  } else {
+    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing symmetric box matrix for " << getTitle() << "." << endl);
+    return false;
+  }
+}
+
+CommandLineDialog::ElementCommandLineQuery::ElementCommandLineQuery(string title, std::vector<element *> *target, string _description) :
+    Dialog::ElementQuery(title,target, _description)
+{}
+
+CommandLineDialog::ElementCommandLineQuery::~ElementCommandLineQuery()
+{}
+
+bool CommandLineDialog::ElementCommandLineQuery::handle() {
+  // 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())) {
+    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);
+    }
+    return true;
+  } else {
+    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing element for " << getTitle() << "." << endl);
+    return false;
+  }
+}
Index: src/UIElements/CommandLineUI/CommandLineDialog.hpp
===================================================================
--- src/UIElements/CommandLineUI/CommandLineDialog.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/CommandLineUI/CommandLineDialog.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,121 @@
+/*
+ * CommandLineDialog.hpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#ifndef COMMANDLINEDIALOG_HPP_
+#define COMMANDLINEDIALOG_HPP_
+
+#include <string>
+
+class atom;
+class element;
+class molecule;
+class Vector;
+
+#include "Dialog.hpp"
+
+/** CommandLineUIFactory implementation of the Dialog.
+ * The idea here is that for each query the parsed command line options are used instead.
+ */
+class CommandLineDialog : public Dialog
+{
+public:
+  CommandLineDialog();
+  virtual ~CommandLineDialog();
+
+  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 = "");
+
+protected:
+  // specialized stuff for text queries
+  class EmptyCommandLineQuery : public Dialog::EmptyQuery {
+  public:
+    EmptyCommandLineQuery(std::string title, std::string _description = "");
+    virtual ~EmptyCommandLineQuery();
+    virtual bool handle();
+  };
+
+  class IntCommandLineQuery : public Dialog::IntQuery {
+  public:
+    IntCommandLineQuery(std::string title, int *_target, std::string _description = "");
+    virtual ~IntCommandLineQuery();
+    virtual bool handle();
+  };
+
+  class BooleanCommandLineQuery : public Dialog::BooleanQuery {
+  public:
+    BooleanCommandLineQuery(std::string title, bool *_target, std::string _description = "");
+    virtual ~BooleanCommandLineQuery();
+    virtual bool handle();
+  };
+
+  class DoubleCommandLineQuery : public Dialog::DoubleQuery {
+  public:
+    DoubleCommandLineQuery(std::string title, double *_target, std::string _description = "");
+    virtual ~DoubleCommandLineQuery();
+    virtual bool handle();
+  };
+
+  class StringCommandLineQuery : public Dialog::StringQuery {
+  public:
+    StringCommandLineQuery(std::string title, std::string *_target, std::string _description = "");
+    virtual ~StringCommandLineQuery();
+    virtual bool handle();
+  };
+
+  class StringsCommandLineQuery : public Dialog::StringsQuery {
+  public:
+    StringsCommandLineQuery(std::string title, std::vector<std::string> *_target, std::string _description = "");
+    virtual ~StringsCommandLineQuery();
+    virtual bool handle();
+  };
+
+  class AtomCommandLineQuery : public Dialog::AtomQuery {
+  public:
+    AtomCommandLineQuery(std::string title, atom **_target, std::string _description = "");
+    virtual ~AtomCommandLineQuery();
+    virtual bool handle();
+  };
+
+  class MoleculeCommandLineQuery : public Dialog::MoleculeQuery {
+  public:
+    MoleculeCommandLineQuery(std::string title, molecule **_target, std::string _description = "");
+    virtual ~MoleculeCommandLineQuery();
+    virtual bool handle();
+  };
+
+  class VectorCommandLineQuery : public Dialog::VectorQuery {
+  public:
+    VectorCommandLineQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check, std::string _description = "");
+    virtual ~VectorCommandLineQuery();
+    virtual bool handle();
+  };
+
+  class BoxCommandLineQuery : public Dialog::BoxQuery {
+  public:
+    BoxCommandLineQuery(std::string title,double ** const _cellSize, std::string _description = "");
+    virtual ~BoxCommandLineQuery();
+    virtual bool handle();
+  };
+
+  class ElementCommandLineQuery : public Dialog::ElementQuery {
+  public:
+    ElementCommandLineQuery(std::string title, std::vector<element *> *_target, std::string _description = "");
+    virtual ~ElementCommandLineQuery();
+    virtual bool handle();
+  };
+};
+
+#endif /* COMMANDLINEDIALOG_HPP_ */
Index: src/UIElements/CommandLineUI/CommandLineStatusIndicator.cpp
===================================================================
--- src/UIElements/CommandLineUI/CommandLineStatusIndicator.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/CommandLineUI/CommandLineStatusIndicator.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,59 @@
+/*
+ * CommandLineStatusIndicator.cpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "CommandLineUI/CommandLineStatusIndicator.hpp"
+
+#include <iostream>
+
+#include "Actions/Process.hpp"
+
+using namespace std;
+
+CommandLineStatusIndicator::CommandLineStatusIndicator() :
+    Observer("CommandLineStatusIndicator")
+{
+  Process::AddObserver(this);
+}
+
+CommandLineStatusIndicator::~CommandLineStatusIndicator()
+{
+  Process::RemoveObserver(this);
+}
+
+void CommandLineStatusIndicator::update(Observable *subject){
+  Process *proc;
+  // we are only observing Processes
+  if((proc=dynamic_cast<Process*>(subject))){
+    // see what kind of progress we have to display
+    if(proc->getMaxSteps()>0){
+      if(!proc->doesStop()){
+        cout << "Busy (" << proc->getName() << ") ";
+        // we can show a percentage done
+        cout << (int)proc->getDoneRatio() << "% done" << endl;
+      }
+    }
+    else{
+      // we only show some kind of busy animation
+      if(proc->doesStart()){
+        cout << "Busy (" << proc->getName() << ")";
+      }
+      if(!proc->doesStop()){
+        cout << ".";
+      }
+      else {
+        cout << endl;
+      }
+    }
+  }
+}
+
+void CommandLineStatusIndicator::subjectKilled(Observable *subject){
+
+}
+
Index: src/UIElements/CommandLineUI/CommandLineStatusIndicator.hpp
===================================================================
--- src/UIElements/CommandLineUI/CommandLineStatusIndicator.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/CommandLineUI/CommandLineStatusIndicator.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,26 @@
+/*
+ * CommandLineStatusIndicator.hpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#ifndef COMMANDLINESTATUSINDICATOR_HPP_
+#define COMMANDLINESTATUSINDICATOR_HPP_
+
+#include "Patterns/Observer.hpp"
+
+class CommandLineStatusIndicator : public Observer
+{
+public:
+  CommandLineStatusIndicator();
+  virtual ~CommandLineStatusIndicator();
+
+  void update(Observable *subject);
+  void subjectKilled(Observable *subject);
+
+private:
+
+};
+
+#endif /* COMMANDLINESTATUSINDICATOR_HPP_ */
Index: src/UIElements/CommandLineUI/CommandLineUIFactory.cpp
===================================================================
--- src/UIElements/CommandLineUI/CommandLineUIFactory.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/CommandLineUI/CommandLineUIFactory.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,44 @@
+/*
+ * CommandLineUIFactory.cpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "CommandLineUI/CommandLineUIFactory.hpp"
+#include "CommandLineUI/CommandLineWindow.hpp"
+#include "CommandLineUI/CommandLineDialog.hpp"
+
+
+CommandLineUIFactory::CommandLineUIFactory()
+{
+  // TODO Auto-generated constructor stub
+
+}
+
+CommandLineUIFactory::~CommandLineUIFactory()
+{
+  // TODO Auto-generated destructor stub
+}
+
+
+Dialog* CommandLineUIFactory::makeDialog() {
+  return new CommandLineDialog();
+}
+
+MainWindow* CommandLineUIFactory::makeMainWindow() {
+  return new CommandLineWindow();
+}
+
+CommandLineUIFactory::description::description() :
+    UIFactory::factoryDescription("CommandLine")
+{}
+
+CommandLineUIFactory::description::~description()
+{}
+
+UIFactory* CommandLineUIFactory::description::makeFactory(){
+  return new CommandLineUIFactory();
+}
Index: src/UIElements/CommandLineUI/CommandLineUIFactory.hpp
===================================================================
--- src/UIElements/CommandLineUI/CommandLineUIFactory.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/CommandLineUI/CommandLineUIFactory.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,59 @@
+/*
+ * CommandLineUIFactory.hpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#ifndef COMMANDLINEUIFACTORY_HPP_
+#define COMMANDLINEUIFACTORY_HPP_
+
+#include "UIFactory.hpp"
+
+/** This class is a specialization of the UIFactory.
+ *
+ * <h2> Introduction </h2>
+ *
+ * The UIFactory is a base class for the User Interaction. There are three UI specializations:
+ * Text, GUI and CommandLine.
+ *
+ * The idea of the command line part is as follows:
+ *
+ * All actions that can be called from the command line are instantiated via populater-functions.
+ * In the constructor of an action it is automatically registered with the ActionRegistry and can
+ * henceforth be looked up there.
+ *
+ * There is a CommandLineParser which parses the command line parameters and puts all found values
+ * into a map. Then, MainWindow::Display of the CommandLineUIFactory is called, which goes through
+ * every action (by the ActionRegistry) and looks through the parsed commands whether the action is
+ * desired.
+ *
+ * In the action itself, Query's ask for user input. In the CommandLine case, we don't want direct
+ * user interaction, but the user has to have those values already delivered along with the desired
+ * action. Hence, the Query implementations just look up the desired values in the CommandLineParser
+ * vaults. When they are not found, an exception is thrown. When all are found, the action is performed.
+ *
+ */
+class CommandLineUIFactory : public UIFactory
+{
+friend class UIFactory;
+
+public:
+  virtual ~CommandLineUIFactory();
+
+  virtual Dialog* makeDialog();
+  virtual MainWindow* makeMainWindow();
+
+  struct description : public UIFactory::factoryDescription {
+    description();
+    virtual ~description();
+
+    virtual UIFactory* makeFactory();
+  };
+
+protected:
+  CommandLineUIFactory();
+};
+
+
+#endif /* COMMANDLINEUIFACTORY_HPP_ */
Index: src/UIElements/CommandLineUI/CommandLineWindow.cpp
===================================================================
--- src/UIElements/CommandLineUI/CommandLineWindow.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/CommandLineUI/CommandLineWindow.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,54 @@
+/*
+ * CommandLineWindow.cpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include <boost/bind.hpp>
+
+#include "CommandLineUI/CommandLineWindow.hpp"
+#include "CommandLineUI/CommandLineStatusIndicator.hpp"
+
+#include "Actions/Action.hpp"
+#include "Actions/MapOfActions.hpp"
+#include "Actions/ActionRegistry.hpp"
+
+#include "CommandLineParser.hpp"
+
+#include <iostream>
+
+using namespace std;
+
+// TODO: see what code can be moved to a base class for Graphic and CommandLine Windows
+CommandLineWindow::CommandLineWindow()
+{
+  // create and register all command line callable actions
+  MapOfActions::getInstance().populateActions();
+
+  // Add status indicators etc...
+  statusIndicator = new CommandLineStatusIndicator();
+}
+
+CommandLineWindow::~CommandLineWindow()
+{
+  delete statusIndicator;
+}
+
+void CommandLineWindow::display() {
+  //cout << ActionRegistry::getInstance();
+
+  // go through all possible actions
+  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)) {
+      cout << "calling " << *CommandRunner << endl;
+      ActionRegistry::getInstance().getActionByName(*CommandRunner)->call();
+    } else {
+      cout << "absent." << endl;
+    }
+  }
+}
+
Index: src/UIElements/CommandLineUI/CommandLineWindow.hpp
===================================================================
--- src/UIElements/CommandLineUI/CommandLineWindow.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/CommandLineUI/CommandLineWindow.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,38 @@
+/*
+ * CommandLineWindow.hpp
+ *
+ *  Created on: May 8, 2010
+ *      Author: heber
+ */
+
+#ifndef COMMANDLINEWINDOW_HPP_
+#define COMMANDLINEWINDOW_HPP_
+
+#include "MainWindow.hpp"
+
+class CommandLineStatusIndicator;
+
+class CommandLineWindow : public MainWindow
+{
+public:
+  CommandLineWindow();
+  virtual ~CommandLineWindow();
+
+  virtual void display();
+
+private:
+  // populaters
+  void populateAnalysisActions();
+  void populateAtomActions();
+  void populateCmdActions();
+  void populateFragmentationActions();
+  void populateMoleculeActions();
+  void populateParserActions();
+  void populateTesselationActions();
+  void populateWorldActions();
+
+  CommandLineStatusIndicator *statusIndicator;
+
+};
+
+#endif /* COMMANDLINEWINDOW_HPP_ */
Index: src/UIElements/Dialog.cpp
===================================================================
--- src/UIElements/Dialog.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Dialog.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,235 @@
+/*
+ * Dialog.cpp
+ *
+ *  Created on: Jan 5, 2010
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Dialog.hpp"
+
+#include "atom.hpp"
+#include "element.hpp"
+#include "molecule.hpp"
+#include "vector.hpp"
+
+using namespace std;
+
+Dialog::Dialog()
+{
+}
+
+Dialog::~Dialog()
+{
+  list<Query*>::iterator iter;
+  for(iter=queries.begin();iter!=queries.end();iter++){
+    delete (*iter);
+  }
+}
+
+void Dialog::registerQuery(Query *query){
+  queries.push_back(query);
+}
+
+bool Dialog::display(){
+  if(checkAll()){
+    setAll();
+    return true;
+  }
+  else{
+    return false;
+  }
+}
+
+bool Dialog::checkAll(){
+  list<Query*>::iterator iter;
+  bool retval = true;
+  for(iter=queries.begin(); iter!=queries.end(); iter++){
+    retval &= (*iter)->handle();
+    // if any query fails (is canceled), we can end the handling process
+    if(!retval) {
+      DoeLog(1) && (eLog() << Verbose(1) << "The following query failed: " << (**iter).getTitle() << "." << endl);
+      break;
+    }
+  }
+  return retval;
+}
+
+void Dialog::setAll(){
+  list<Query*>::iterator iter;
+  for(iter=queries.begin(); iter!=queries.end(); iter++) {
+    (*iter)->setResult();
+  }
+}
+
+/****************** Query types Infrastructure **************************/
+
+// Base class
+Dialog::Query::Query(string _title, string _description) :
+    title(_title),
+    description(_description)
+{}
+
+Dialog::Query::~Query() {}
+
+const std::string Dialog::Query::getTitle() const{
+  return title;
+}
+
+const std::string Dialog::Query::getDescription() const{
+  return description;
+}
+// empty Queries
+
+Dialog::EmptyQuery::EmptyQuery(string title, std::string description) :
+    Query(title, description)
+{}
+
+Dialog::EmptyQuery::~EmptyQuery() {}
+
+void Dialog::EmptyQuery::setResult() {
+}
+
+// Int Queries
+
+Dialog::IntQuery::IntQuery(string title,int *_target, std::string description) :
+    Query(title, description), target(_target)
+{}
+
+Dialog::IntQuery::~IntQuery() {}
+
+void Dialog::IntQuery::setResult() {
+  *target = tmp;
+}
+
+// Int Queries
+
+Dialog::BooleanQuery::BooleanQuery(string title,bool *_target, std::string description) :
+    Query(title, description), target(_target)
+{}
+
+Dialog::BooleanQuery::~BooleanQuery() {}
+
+void Dialog::BooleanQuery::setResult() {
+  *target = tmp;
+}
+
+// String Queries
+
+Dialog::StringQuery::StringQuery(string title,string *_target, std::string _description) :
+    Query(title, _description), target(_target)
+{}
+
+Dialog::StringQuery::~StringQuery() {};
+
+void Dialog::StringQuery::setResult() {
+  *target = tmp;
+}
+
+// Strings Queries
+
+Dialog::StringsQuery::StringsQuery(string title,vector<string> *_target, std::string _description) :
+    Query(title, _description), target(_target)
+{}
+
+Dialog::StringsQuery::~StringsQuery() {};
+
+void Dialog::StringsQuery::setResult() {
+  *target = tmp;
+}
+
+// Double Queries
+
+Dialog::DoubleQuery::DoubleQuery(string title,double *_target, std::string _description) :
+    Query(title, _description), target(_target)
+{}
+
+Dialog::DoubleQuery::~DoubleQuery() {};
+
+void Dialog::DoubleQuery::setResult() {
+  *target = tmp;
+}
+
+
+// Atom Queries
+
+Dialog::AtomQuery::AtomQuery(string title, atom **_target, std::string _description) :
+    Query(title, _description),
+    tmp(0),
+    target(_target)
+
+{}
+
+Dialog::AtomQuery::~AtomQuery() {}
+
+void Dialog::AtomQuery::setResult() {
+  *target = tmp;
+}
+
+// Molecule Queries
+
+Dialog::MoleculeQuery::MoleculeQuery(string title, molecule **_target, std::string _description) :
+    Query(title, _description),
+    tmp(0),
+    target(_target)
+
+{}
+
+Dialog::MoleculeQuery::~MoleculeQuery() {}
+
+void Dialog::MoleculeQuery::setResult() {
+  *target = tmp;
+}
+
+// Vector Queries
+
+Dialog::VectorQuery::VectorQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check, std::string _description) :
+  Query(title, _description),
+  cellSize(_cellSize),
+  check(_check),
+  target(_target)
+{
+  tmp = new Vector();
+}
+
+Dialog::VectorQuery::~VectorQuery()
+{
+  delete tmp;
+}
+
+void Dialog::VectorQuery::setResult() {
+  *target = *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()
+{
+  delete[] tmp;
+}
+
+void Dialog::BoxQuery::setResult() {
+  for (int i=0;i<6;i++) {
+    (*target)[i] = tmp[i];
+  }
+}
+
+// Element Queries
+Dialog::ElementQuery::ElementQuery(std::string title, std::vector<element *> *_target, std::string _description) :
+  Query(title, _description),
+  target(_target)
+  {}
+
+Dialog::ElementQuery::~ElementQuery(){}
+
+void Dialog::ElementQuery::setResult(){
+  *target=elements;
+}
Index: src/UIElements/Dialog.hpp
===================================================================
--- src/UIElements/Dialog.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Dialog.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,222 @@
+/*
+ * Dialog.hpp
+ *
+ *  Created on: Jan 5, 2010
+ *      Author: crueger
+ */
+
+#ifndef DIALOG_HPP_
+#define DIALOG_HPP_
+
+#include<string>
+#include<list>
+#include<vector>
+
+class atom;
+class element;
+class molecule;
+class Vector;
+
+
+/** Dialog is one of the two main classes of the UIFactory base class.
+ *
+ * The Dialog is meant for asking the user for information needed to perform actions he
+ * desires, such as asking for a position in space or a length.
+ *
+ * For this purpose there is the base class Query and numerous specializations for each
+ * of the types to be asked. There are primitives integer, doubles and string, but also
+ * advanced types such as element, molecule or Vector. There is also an empty query for
+ * displaying text.
+ */
+class Dialog
+{
+public:
+  Dialog();
+  virtual ~Dialog();
+
+  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 bool display();
+
+  virtual bool checkAll();
+  virtual void setAll();
+
+protected:
+  // methodology for handling queries
+  // all queries are stored and then performed at appropriate times
+
+  //these queries can be handled by this dialog
+
+  //TODO: Find a way to reduce complexity...
+  //needs O(N*M) query classes, where N is the number of query types and M is the number of GUIs
+  //usual approach for reducing inheritance complexity (strategy pattern) does not work,
+  //due to lack of common code for query types as well as GUI-Types (all subtypes differ a lot)
+
+  //base class for all queries
+  class Query {
+    friend class Dialog;
+  public:
+    Query(std::string _title, std::string _description = "");
+    virtual ~Query();
+    virtual bool handle()=0;
+    virtual void setResult()=0;
+  protected:
+    const std::string getTitle() const;
+    const std::string getDescription() const;
+  private:
+    std::string title;  //!< short title of the query
+    std::string description; //!< longer description for tooltips or for help
+  };
+
+  // Empty Query is just meant for showing text, such as version, help, initial message or alike
+  class EmptyQuery : public Query {
+  public:
+    EmptyQuery(std::string title, std::string _description = "");
+    virtual ~EmptyQuery();
+    virtual bool handle()=0;
+    virtual void setResult();
+  };
+
+  //Specialized classes for certain types. GUI-Types are not specialized at this time
+  class BooleanQuery : public Query {
+  public:
+    BooleanQuery(std::string title,bool *_target, std::string _description = "");
+    virtual ~BooleanQuery();
+    virtual bool handle()=0;
+    virtual void setResult();
+  protected:
+    bool tmp;
+  private:
+    bool *target;
+  };
+
+  class IntQuery : public Query {
+  public:
+    IntQuery(std::string title,int *_target, std::string _description = "");
+    virtual ~IntQuery();
+    virtual bool handle()=0;
+    virtual void setResult();
+  protected:
+    int tmp;
+  private:
+    int *target;
+  };
+
+  class DoubleQuery : public Query {
+  public:
+    DoubleQuery(std::string title,double *_target, std::string _description = "");
+    virtual ~DoubleQuery();
+    virtual bool handle()=0;
+    virtual void setResult();
+  protected:
+    double tmp;
+  private:
+    double *target;
+  };
+
+  class StringQuery : public Query {
+  public:
+    StringQuery(std::string title,std::string *_target, std::string _description = "");
+    virtual ~StringQuery();
+    virtual bool handle()=0;
+    virtual void setResult();
+  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 = "");
+    virtual ~StringsQuery();
+    virtual bool handle()=0;
+    virtual void setResult();
+  protected:
+    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 = "");
+    virtual ~MoleculeQuery();
+    virtual bool handle()=0;
+    virtual void setResult();
+  protected:
+    molecule *tmp;
+  private:
+    molecule **target;
+  };
+
+  class AtomQuery : public Query {
+  public:
+    AtomQuery(std::string title, atom **_target, std::string _description = "");
+    virtual ~AtomQuery();
+    virtual bool handle()=0;
+    virtual void setResult();
+  protected:
+    atom *tmp;
+  private:
+    atom **target;
+  };
+
+  class VectorQuery : public Query {
+  public:
+      VectorQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check, std::string _description = "");
+      virtual ~VectorQuery();
+      virtual bool handle()=0;
+      virtual void setResult();
+    protected:
+      Vector *tmp;
+      const double *const cellSize;
+      bool check;
+    private:
+      Vector *target;
+  };
+
+  class BoxQuery : public Query {
+  public:
+      BoxQuery(std::string title,double ** const _cellSize, std::string _description = "");
+      virtual ~BoxQuery();
+      virtual bool handle()=0;
+      virtual void setResult();
+    protected:
+      double *tmp;
+    private:
+      double **target;
+  };
+
+  class ElementQuery : public Query {
+  public:
+    ElementQuery(std::string title, std::vector<element *> *_target, std::string _description = "");
+    virtual ~ElementQuery();
+    virtual bool handle()=0;
+    virtual void setResult();
+  protected:
+    std::vector<element *> elements;
+  private:
+    std::vector<element *> * const target;
+  };
+
+void registerQuery(Query* query);
+
+private:
+  std::list<Query*> queries;
+
+};
+
+
+#endif /* DIALOG_HPP_ */
Index: src/UIElements/MainWindow.cpp
===================================================================
--- src/UIElements/MainWindow.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/MainWindow.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,16 @@
+/*
+ * Window.cpp
+ *
+ *  Created on: Jan 7, 2010
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "MainWindow.hpp"
+
+MainWindow::MainWindow()
+{}
+
+MainWindow::~MainWindow()
+{}
Index: src/UIElements/MainWindow.hpp
===================================================================
--- src/UIElements/MainWindow.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/MainWindow.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,28 @@
+/*
+ * Window.hpp
+ *
+ *  Created on: Jan 7, 2010
+ *      Author: crueger
+ */
+
+#ifndef MAINWINDOW_HPP_
+#define MAINWINDOW_HPP_
+
+class MoleculeListClass;
+class config;
+class periodentafel;
+
+class Menu;
+
+class MainWindow
+{
+public:
+  MainWindow();
+  virtual ~MainWindow();
+
+  virtual void display()=0;
+
+};
+
+
+#endif /* MAINWINDOW_HPP_ */
Index: src/UIElements/Makefile.am
===================================================================
--- src/UIElements/Makefile.am	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Makefile.am	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,82 @@
+# Below is all for the User Interface
+
+INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/src/UIElements
+
+AM_LDFLAGS = $(CPPUNIT_LIBS) -ldl
+AM_CXXFLAGS = $(CPPUNIT_CFLAGS)
+
+noinst_LIBRARIES = libMolecuilderUI.a
+libMolecuilderUI_a_SOURCES = ${UISOURCE} ${UIHEADER}
+
+VIEWSOURCE = \
+  Views/View.cpp \
+  Views/StringView.cpp \
+  Views/MethodStringView.cpp \
+  Views/StreamStringView.cpp
+VIEWHEADER = \
+  Views/View.hpp \
+  Views/StringView.hpp \
+  Views/MethodStringView.hpp \
+  Views/StreamStringView.hpp
+
+MENUSOURCE = \
+  Menu/Menu.cpp \
+  Menu/TextMenu.cpp \
+  Menu/MenuItem.cpp \
+  Menu/SubMenuItem.cpp \
+  Menu/ActionMenuItem.cpp \
+  Menu/SeperatorItem.cpp \
+  Menu/DisplayMenuItem.cpp
+  
+MENUHEADER = \
+  Menu/Menu.hpp \
+  Menu/TextMenu.hpp \
+  Menu/MenuItem.hpp \
+  Menu/SubMenuItem.hpp \
+  Menu/ActionMenuItem.hpp \
+  Menu/SeperatorItem.hpp \
+  Menu/DisplayMenuItem.hpp
+
+UISOURCE = \
+  ${ACTIONSSOURCE} \
+  ${COMMANDLINEUISOURCE} \
+  ${MENUSOURCE} \
+  ${TEXTUISOURCE} \
+  ${VIEWSOURCE} \
+  Dialog.cpp \
+  MainWindow.cpp \
+  UIFactory.cpp
+  
+UIHEADER = \
+  ${ACTIONSHEADER} \
+  ${COMMANDLINEUIHEADER} \
+  ${MENUHEADER} \
+  ${TEXTUIHEADER} \
+  ${VIEWHEADER} \
+  Dialog.hpp \
+  MainWindow.hpp \
+  UIFactory.hpp
+
+TEXTUISOURCE = \
+  TextUI/TextDialog.cpp \
+  TextUI/TextStatusIndicator.cpp \
+  TextUI/TextUIFactory.cpp \
+  TextUI/TextWindow.cpp
+TEXTUIHEADER = \
+  TextUI/TextDialog.hpp \
+  TextUI/TextStatusIndicator.hpp \
+  TextUI/TextUIFactory.hpp \
+  TextUI/TextWindow.hpp
+
+COMMANDLINEUISOURCE = \
+  CommandLineUI/CommandLineDialog.cpp \
+  CommandLineUI/CommandLineStatusIndicator.cpp \
+  CommandLineUI/CommandLineUIFactory.cpp \
+  CommandLineUI/CommandLineWindow.cpp
+COMMANDLINEUIHEADER = \
+  CommandLineUI/CommandLineDialog.hpp \
+  CommandLineUI/CommandLineStatusIndicator.hpp \
+  CommandLineUI/CommandLineUIFactory.hpp \
+  CommandLineUI/CommandLineWindow.hpp
+
+
Index: src/UIElements/Menu/ActionMenuItem.cpp
===================================================================
--- src/UIElements/Menu/ActionMenuItem.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Menu/ActionMenuItem.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,32 @@
+/*
+ * ActionMenuItem.cpp
+ *
+ *  Created on: Dec 11, 2009
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include <iostream>
+
+#include "Menu/ActionMenuItem.hpp"
+#include "Actions/MethodAction.hpp"
+
+using namespace std;
+
+ActionMenuItem::ActionMenuItem(char _trigger, const char* _description,Menu* _menu,Action* _action)
+: MenuItem(_trigger,_description,_menu),
+  action(_action)
+{
+}
+
+ActionMenuItem::~ActionMenuItem()
+{}
+
+void ActionMenuItem::doTrigger() {
+  action->call();
+}
+
+bool ActionMenuItem::isActive() {
+  return action->isActive();
+}
Index: src/UIElements/Menu/ActionMenuItem.hpp
===================================================================
--- src/UIElements/Menu/ActionMenuItem.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Menu/ActionMenuItem.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,34 @@
+/*
+ * ActionMenuItem.h
+ *
+ *  Created on: Dec 11, 2009
+ *      Author: crueger
+ */
+
+#ifndef ACTIONMENUITEM_H_
+#define ACTIONMENUITEM_H_
+
+#include <string>
+
+#include "Menu/MenuItem.hpp"
+
+class Action;
+
+/**
+ * Produce MenuItems that take an appropriate action when called.
+ */
+class ActionMenuItem : public MenuItem
+{
+public:
+  ActionMenuItem(char,const char*,Menu*,Action*);
+  virtual ~ActionMenuItem();
+
+  virtual void doTrigger();
+
+  virtual bool isActive();
+
+private:
+  Action* action; //!< this action will be called when the trigger matches
+};
+
+#endif /* ACTIONMENUITEM_H_ */
Index: src/UIElements/Menu/DisplayMenuItem.cpp
===================================================================
--- src/UIElements/Menu/DisplayMenuItem.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Menu/DisplayMenuItem.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,61 @@
+/*
+ * DisplayMenuItem.cpp
+ *
+ *  Created on: Dec 14, 2009
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include <sstream>
+#include <cmath>
+
+#include "Menu/DisplayMenuItem.hpp"
+#include "Views/StringView.hpp"
+
+
+DisplayMenuItem::DisplayMenuItem(Menu* _menu, StringView *_view):
+MenuItem('\0',"",_menu),
+view(_view),
+title("")
+{
+}
+
+DisplayMenuItem::DisplayMenuItem(Menu* _menu, StringView *_view, string _title, char _spacer, int _length ):
+  MenuItem('\0',"",_menu),
+  view(_view),
+  title(_title),
+  length(_length),
+  spacer(_spacer)
+{
+}
+
+DisplayMenuItem::~DisplayMenuItem()
+{}
+
+
+void DisplayMenuItem::doTrigger(){}
+bool DisplayMenuItem::checkTrigger(char c){
+  return false;
+}
+
+const string DisplayMenuItem::formatEntry(){
+  stringstream s;
+  if(title.length()>0) {
+    int pre = floor((length-title.length())/2.0);
+    int post = ceil((length-title.length())/2.0);
+    for(int i=0;i<pre;i++)
+      s << spacer;
+    s << title;
+    for(int i=0;i<post;i++)
+          s << spacer;
+    s << "\n";
+  }
+  s << view->toString();
+  return s.str();
+}
+
+
+const string DisplayMenuItem::getDescription(){
+  return string("");
+}
Index: src/UIElements/Menu/DisplayMenuItem.hpp
===================================================================
--- src/UIElements/Menu/DisplayMenuItem.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Menu/DisplayMenuItem.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,43 @@
+/*
+ * DisplayMenuItem.hpp
+ *
+ *  Created on: Dec 14, 2009
+ *      Author: crueger
+ */
+
+#ifndef DISPLAYMENUITEM_HPP_
+#define DISPLAYMENUITEM_HPP_
+
+#include "Menu/MenuItem.hpp"
+#include "defs.hpp"
+
+class StringView;
+
+/**
+ * Display any kind of StringView within a Menu
+ *
+ * Any trigger are ignored for this type of Item
+ */
+class DisplayMenuItem : public MenuItem
+{
+public:
+  DisplayMenuItem(Menu* _menu, StringView *_view);
+  DisplayMenuItem(Menu* _menu, StringView *_view, string _title,
+                  char _spacer=STD_MENU_TITLE_SPACER, int _length=STD_MENU_LENGTH);
+  virtual ~DisplayMenuItem();
+
+  virtual void doTrigger();
+  virtual bool checkTrigger(char);
+
+  virtual const string formatEntry();
+
+  virtual const string getDescription();
+
+private:
+  StringView *view;
+  string title;
+  int length;
+  char spacer;
+};
+
+#endif /* DISPLAYMENUITEM_HPP_ */
Index: src/UIElements/Menu/Menu.cpp
===================================================================
--- src/UIElements/Menu/Menu.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Menu/Menu.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,21 @@
+/*
+ * Menu.cpp
+ *
+ *  Created on: Dec 10, 2009
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Menu.hpp"
+
+Menu::Menu()
+{
+  // TODO Auto-generated constructor stub
+
+}
+
+Menu::~Menu()
+{
+  // TODO Auto-generated destructor stub
+}
Index: src/UIElements/Menu/Menu.hpp
===================================================================
--- src/UIElements/Menu/Menu.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Menu/Menu.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,41 @@
+/*
+ * Menu.h
+ *
+ *  Created on: Dec 10, 2009
+ *      Author: crueger
+ */
+
+#ifndef MENU_MENU_H_
+#define MENU_MENU_H_
+
+using namespace std;
+
+class MenuItem;
+
+/**
+ * Base class for all Types of menus
+ * contains basic abstract functionality to add Items, remove Items and display the menu
+ *
+ * TODO: Make sure all items are only added once.
+ */
+class Menu
+{
+public:
+  Menu();
+  virtual ~Menu();
+
+
+  /**
+   * Adding and removing should be handled by the items.
+   */
+  virtual void addItem(MenuItem*)=0;
+  /**
+   * Adding and removing should be handled by the items.
+   */
+  virtual void removeItem(MenuItem*)=0;
+  virtual void display()=0;
+
+private:
+};
+
+#endif /* MENU_H_ */
Index: src/UIElements/Menu/MenuItem.cpp
===================================================================
--- src/UIElements/Menu/MenuItem.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Menu/MenuItem.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,83 @@
+/*
+ * MenuItem.cpp
+ *
+ *  Created on: Dec 10, 2009
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Menu/MenuItem.hpp"
+#include "Menu/Menu.hpp"
+#include <sstream>
+#include <iostream>
+
+/**
+ * produce a new MenuItem using with a description and a trigger.
+ * The MenuItem is then added to the menu passed to it.
+ */
+MenuItem::MenuItem(char _trigger, const char* _description,Menu* menu) :
+trigger(_trigger),
+added(false)
+{
+  description = new string(_description);
+  add_to_menu(menu);
+}
+
+MenuItem::~MenuItem()
+{
+  delete description;
+}
+
+/**
+ * check if the trigger matches and call doTrigger if it does.
+ */
+bool MenuItem::checkTrigger(char key) {
+  if(key == trigger) {
+    doTrigger();
+    return true;
+  }
+  else
+    return false;
+
+}
+
+char MenuItem::getTrigger() {
+  return trigger;
+}
+
+const string MenuItem::getDescription() {
+  return *description;
+}
+
+/**
+ * Produce a formated output of this item containing trigger and description
+ * Normal format is: "<trigger> - <description>"
+ */
+const string MenuItem::formatEntry(){
+  stringstream s;
+  s << getTrigger() << " - " << getDescription();
+
+  return s.str();
+}
+
+
+/**
+ * check if this item is within a menu and add to menu if it is not yet contained anywhere
+ *
+ * TODO: include funtionality to move Items from one menu to another
+ */
+void MenuItem::add_to_menu(Menu* menu) {
+  if(!wasAdded()) {
+    menu->addItem(this);
+    added=true;
+  }
+}
+
+bool MenuItem::wasAdded(){
+  return added;
+}
+
+bool MenuItem::isActive(){
+  return true;
+}
Index: src/UIElements/Menu/MenuItem.hpp
===================================================================
--- src/UIElements/Menu/MenuItem.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Menu/MenuItem.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,49 @@
+/*
+ * MenuItem.h
+ *
+ *  Created on: Dec 10, 2009
+ *      Author: crueger
+ */
+
+#ifndef MENUITEM_H_
+#define MENUITEM_H_
+
+#include <string>
+
+using namespace std;
+
+class Menu;
+
+/**
+ * Base class for all kinds of MenuItems
+ *
+ * This class takes care of checking the triggers and performing appropriate actions.
+ */
+class MenuItem {
+public:
+  MenuItem(char,const char*,Menu*);
+  virtual ~MenuItem();
+
+  virtual void doTrigger()=0;
+  virtual bool checkTrigger(char);
+
+  virtual const string formatEntry();
+
+  virtual const string getDescription();
+  char getTrigger();
+
+  void add_to_menu(Menu*);
+  bool wasAdded();
+
+  virtual bool isActive();
+
+protected:
+  void setDescription(string);
+
+private:
+  char trigger;
+  string *description;
+  bool added;
+};
+
+#endif /* MENUITEM_H_ */
Index: src/UIElements/Menu/QT4/QTMenu.cpp
===================================================================
--- src/UIElements/Menu/QT4/QTMenu.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Menu/QT4/QTMenu.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,54 @@
+/*
+ * QTMenu.cpp
+ *
+ *  Created on: Jan 15, 2010
+ *      Author: crueger
+ */
+
+#include "Menu/QT4/QTMenu.hpp"
+
+#include <Qt/qaction.h>
+#include "Menu/MenuItem.hpp"
+
+QTMenu::QTMenu(const char * _title) :
+  QMenu(_title)
+{}
+
+QTMenu::~QTMenu()
+{
+  // yay... Just like Mario Bros.
+  for(list<QTMenuPipe*>::iterator it=plumbing.begin(); it != plumbing.end(); it++)
+    delete (*it);
+}
+
+void QTMenu::addItem(MenuItem* item) {
+  const string description = item->getDescription();
+  QAction *action = addAction(QString(description.c_str()));
+  QTMenuPipe *pipe = new QTMenuPipe(item,action);
+  QObject::connect(action, SIGNAL(triggered()),pipe,SLOT(called()));
+  plumbing.push_back(pipe);
+}
+
+void QTMenu::removeItem(MenuItem* item) {
+  list<QTMenuPipe*>::iterator iter;
+  for(iter=plumbing.begin(); iter!=plumbing.end(); iter++){
+    delete (*iter);
+  }
+}
+
+void QTMenu::display() {
+
+}
+
+QTMenuPipe::QTMenuPipe(MenuItem *_item, QAction *_action) :
+    theItem(_item), theAction(_action)
+{}
+
+QTMenuPipe::~QTMenuPipe() {
+  delete theAction;
+  delete theItem;
+}
+
+void QTMenuPipe::called() {
+  theItem->doTrigger();
+}
Index: src/UIElements/Menu/QT4/QTMenu.hpp
===================================================================
--- src/UIElements/Menu/QT4/QTMenu.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Menu/QT4/QTMenu.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,50 @@
+/*
+ * QTMenu.hpp
+ *
+ *  Created on: Jan 15, 2010
+ *      Author: crueger
+ */
+
+#ifndef QTMENU_HPP_
+#define QTMENU_HPP_
+
+#include <list>
+
+#include <QtGui/QMenu>
+#include <QtCore/QObject>
+
+#include "Menu/Menu.hpp"
+
+class QTMenuPipe;
+
+class QTMenu : public QMenu, public Menu
+{
+  Q_OBJECT
+
+public:
+  QTMenu(const char *);
+  virtual ~QTMenu();
+
+  virtual void addItem(MenuItem*);
+  virtual void removeItem(MenuItem*);
+  virtual void display();
+private:
+  list<QTMenuPipe*> plumbing;
+};
+
+// This handles the plumbing from QT to internal Items
+// Slots from QT are redirected to internal methods.
+// This way methods can be used where no QT is available
+class QTMenuPipe : public QObject {
+  Q_OBJECT
+public:
+  QTMenuPipe(MenuItem*,QAction*);
+  virtual ~QTMenuPipe();
+public slots:
+  void called();
+private:
+  MenuItem *theItem;
+  QAction *theAction;
+};
+
+#endif /* QTMENU_HPP_ */
Index: src/UIElements/Menu/SeperatorItem.cpp
===================================================================
--- src/UIElements/Menu/SeperatorItem.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Menu/SeperatorItem.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,56 @@
+/*
+ * SeperatorItem.cpp
+ *
+ *  Created on: Dec 11, 2009
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include <string>
+#include <sstream>
+
+#include "Menu/SeperatorItem.hpp"
+#include "Menu/Menu.hpp"
+#include "defs.hpp"
+
+
+SeperatorItem::SeperatorItem(Menu* menu):
+MenuItem('\0',"",menu),
+spacer(STD_SEPERATOR_SPACER),
+length(STD_MENU_LENGTH)
+{
+  // TODO Auto-generated constructor stub
+
+}
+
+SeperatorItem::SeperatorItem(Menu* menu,char _spacer, int _length):
+MenuItem('\0',"",menu),
+spacer(_spacer),
+length(_length)
+{
+  // TODO Auto-generated constructor stub
+
+}
+
+SeperatorItem::~SeperatorItem()
+{
+  // TODO Auto-generated destructor stub
+}
+
+
+void SeperatorItem::doTrigger(){}
+bool SeperatorItem::checkTrigger(char){
+  return false;
+}
+
+const string SeperatorItem::getDescription() {
+  return string("");
+}
+
+const string SeperatorItem::formatEntry(){
+  stringstream s;
+  for(int i=0; i<length;i++)
+    s << spacer;
+  return s.str();
+}
Index: src/UIElements/Menu/SeperatorItem.hpp
===================================================================
--- src/UIElements/Menu/SeperatorItem.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Menu/SeperatorItem.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,36 @@
+/*
+ * SeperatorItem.h
+ *
+ *  Created on: Dec 11, 2009
+ *      Author: crueger
+ */
+
+#ifndef SEPERATORITEM_H_
+#define SEPERATORITEM_H_
+
+#include "Menu/MenuItem.hpp"
+
+/**
+ * Produce a Seperator within a Menu.
+ *
+ * All triggers are ignored for this Item.
+ */
+class SeperatorItem : public MenuItem
+{
+public:
+  SeperatorItem(Menu*);
+  SeperatorItem(Menu*,char,int);
+  virtual ~SeperatorItem();
+
+  virtual void doTrigger();
+  virtual bool checkTrigger(char);
+
+  virtual const string getDescription();
+
+  virtual const string formatEntry();
+private:
+  char spacer;
+  int length;
+};
+
+#endif /* SEPERATORITEM_H_ */
Index: src/UIElements/Menu/SubMenuItem.cpp
===================================================================
--- src/UIElements/Menu/SubMenuItem.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Menu/SubMenuItem.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,25 @@
+/*
+ * SubMenuItem.cpp
+ *
+ *  Created on: Dec 10, 2009
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "SubMenuItem.hpp"
+
+SubMenuItem::SubMenuItem(char _trigger,const char* _description,Menu* _parent, Menu* _theMenu) :
+MenuItem(_trigger,_description,_parent),
+theMenu(_theMenu)
+{
+}
+
+SubMenuItem::~SubMenuItem()
+{
+  delete theMenu;
+}
+
+void SubMenuItem::doTrigger() {
+  theMenu->display();
+}
Index: src/UIElements/Menu/SubMenuItem.hpp
===================================================================
--- src/UIElements/Menu/SubMenuItem.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Menu/SubMenuItem.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,20 @@
+#ifndef SUBMENUITEM_H_
+#define SUBMENUITEM_H_
+
+#include "MenuItem.hpp"
+#include "TextMenu.hpp"
+
+class Menu;
+
+class SubMenuItem : public MenuItem
+{
+public:
+  SubMenuItem(char,const char*,Menu*,Menu*);
+  virtual ~SubMenuItem();
+
+  virtual void doTrigger();
+private:
+  Menu* theMenu;
+};
+
+#endif /* SUBMENUITEM_H_ */
Index: src/UIElements/Menu/TextMenu.cpp
===================================================================
--- src/UIElements/Menu/TextMenu.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Menu/TextMenu.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,143 @@
+/*
+ * TextMenu.cpp
+ *
+ *  Created on: Dec 10, 2009
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include <boost/bind.hpp>
+#include <iostream>
+#include <cmath>
+#include "Menu/TextMenu.hpp"
+#include "Menu/MenuItem.hpp"
+#include "Helpers/Assert.hpp"
+
+
+/**
+ * produce a text menu with a given title.
+ * The text will later be displayed using the stream passed to the constructor.
+ */
+TextMenu::TextMenu(ostream& _outputter, string _title, char _spacer,int _length) :
+  defaultItem(0),
+  outputter(_outputter),
+  title(_title),
+  spacer(_spacer),
+  length(_length),
+  quit(false)
+{
+}
+
+TextMenu::~TextMenu()
+{
+  for(list<MenuItem*>::iterator it=items.begin(); it != items.end(); it++)
+    delete (*it);
+}
+
+
+void TextMenu::addItem(MenuItem* item) {
+  items.push_back(item);
+}
+
+void TextMenu::removeItem(MenuItem* item) {
+  items.remove(item);
+}
+
+void TextMenu::doQuit(){
+  quit = true;
+}
+
+bool TextMenu::hasQuit(){
+  return quit;
+}
+
+void TextMenu::showEntry(MenuItem* entry){
+  if(entry->isActive()==false){
+    outputter << "(";
+  }
+  outputter << entry->formatEntry();
+  if(entry->isActive()==false){
+    outputter << ")";
+  }
+  outputter << "\n";
+}
+
+void TextMenu::display() {
+  char choice;
+  bool somethingChosen = false;
+  quit = false;
+  do {
+    int pre = floor((length - title.length()) /2.0);
+    int post = ceil((length - title.length()) /2.0);
+    for(int i=0;i<pre;i++)
+      outputter << spacer;
+    outputter << title;
+    for(int i=0;i<post;i++)
+          outputter << spacer;
+    outputter << '\n';
+    for_each(items.begin(), items.end(), boost::bind(&TextMenu::showEntry,this,_1));
+    outputter.flush();
+
+    cin >> choice;
+
+    list<MenuItem*>::iterator iter;
+    for(iter = items.begin(); iter!=items.end();iter++){
+      if((*iter)->isActive()){
+        somethingChosen |= (*iter)->checkTrigger(choice);
+      }
+    }
+    // see if something was chosen and call default Item if not
+    if(!somethingChosen) {
+      if(defaultItem){
+        defaultItem->doTrigger();
+      }
+      else{
+        outputter << "Invalid Choice!" <<  endl;
+      }
+    }
+  }while (!hasQuit());
+}
+
+string TextMenu::getTitle(){
+  return title;
+}
+
+void TextMenu::addDefault(MenuItem* _defaultItem) {
+  defaultItem = _defaultItem;
+}
+
+/****************************** Contained Actions ****************/
+
+const string TextMenu::LeaveAction::nameBase = "Leave menu: ";
+
+TextMenu::LeaveAction::LeaveAction(TextMenu* _menu) :
+Action(nameBase+_menu->getTitle()),
+menu(_menu)
+{}
+
+TextMenu::LeaveAction::~LeaveAction(){}
+
+bool TextMenu::LeaveAction::canUndo(){
+  return false;
+}
+
+bool TextMenu::LeaveAction::shouldUndo(){
+  return false;
+}
+
+Action::state_ptr TextMenu::LeaveAction::performCall(){
+  menu->doQuit();
+  return Action::success;
+}
+
+
+Action::state_ptr TextMenu::LeaveAction::performUndo(Action::state_ptr){
+  ASSERT(0,"Cannot undo leaving a menu");
+  return Action::success;
+}
+
+Action::state_ptr TextMenu::LeaveAction::performRedo(Action::state_ptr){
+  ASSERT(0,"Cannot redo leaving a menu");
+  return Action::success;
+}
Index: src/UIElements/Menu/TextMenu.hpp
===================================================================
--- src/UIElements/Menu/TextMenu.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Menu/TextMenu.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,82 @@
+/*
+ * TextMenu.h
+ *
+ *  Created on: Dec 10, 2009
+ *      Author: crueger
+ */
+
+#ifndef TEXTMENU_H_
+#define TEXTMENU_H_
+
+#include <list>
+#include <ostream>
+#include <string>
+
+#include "Menu/Menu.hpp"
+#include "Actions/Action.hpp"
+#include "defs.hpp"
+
+class MenuItem;
+
+/**
+ * Used to produce any kind of text menu
+ *
+ * All Items are displayed and user is prompted for a key. The item corresponding to that key is then activated.
+ */
+class TextMenu : public Menu
+{
+public:
+  class LeaveAction : public Action {
+  public:
+    LeaveAction(TextMenu*);
+    virtual ~LeaveAction();
+
+    bool canUndo();
+    bool shouldUndo();
+
+  private:
+    virtual Action::state_ptr performCall();
+    virtual Action::state_ptr performUndo(Action::state_ptr);
+    virtual Action::state_ptr performRedo(Action::state_ptr);
+
+    TextMenu* menu;
+
+    static const string nameBase;
+  };
+
+  TextMenu(ostream& _outputter, string _title, char _spacer=STD_MENU_TITLE_SPACER,int _length=STD_MENU_LENGTH);
+  virtual ~TextMenu();
+
+  virtual void addItem(MenuItem*);
+  virtual void removeItem(MenuItem*);
+  virtual void display();
+  virtual string getTitle();
+
+  /**
+   * Call doQuit if you want to return from this menu.
+   */
+  virtual void doQuit();
+  /**
+   * Check whether someone has chosen to quit
+   */
+  virtual bool hasQuit();
+
+  virtual void addDefault(MenuItem*);
+
+protected:
+  virtual void showEntry(MenuItem*);
+
+private:
+  list<MenuItem*> items;
+
+  MenuItem* defaultItem;
+
+  ostream& outputter;
+  string title;
+  char spacer;
+  int length;
+
+  bool quit;
+};
+
+#endif /* TEXTMENU_H_ */
Index: src/UIElements/QT4/QTDialog.cpp
===================================================================
--- src/UIElements/QT4/QTDialog.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/QT4/QTDialog.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,439 @@
+/*
+ * QTDialog.cpp
+ *
+ *  Created on: Jan 18, 2010
+ *      Author: crueger
+ */
+
+#include "UIElements/QT4/QTDialog.hpp"
+
+#include <string>
+#include <sstream>
+#include <limits>
+
+#include <Qt/qboxlayout.h>
+#include <Qt/qlabel.h>
+#include <Qt/qspinbox.h>
+#include <QtGui/QDoubleSpinBox>
+#include <Qt/qlineedit.h>
+#include <Qt/qdialogbuttonbox.h>
+#include <Qt/qpushbutton.h>
+#include <Qt/qcombobox.h>
+
+#include "Helpers/MemDebug.hpp"
+
+#include "World.hpp"
+#include "periodentafel.hpp"
+#include "atom.hpp"
+#include "element.hpp"
+#include "molecule.hpp"
+#include "Descriptors/MoleculeIdDescriptor.hpp"
+
+
+using namespace std;
+
+QTDialog::QTDialog() :
+    QDialog(0)
+{
+  // creating and filling of the Dialog window
+  mainLayout = new QVBoxLayout();
+  inputLayout = new QVBoxLayout();
+  buttonLayout = new QVBoxLayout();
+  setLayout(mainLayout);
+  mainLayout->addLayout(inputLayout);
+  mainLayout->addLayout(buttonLayout);
+  buttons = new QDialogButtonBox(QDialogButtonBox::Ok| QDialogButtonBox::Cancel);
+  buttonLayout->addWidget(buttons);
+
+  // Disable the ok button until something was entered
+  buttons->button(QDialogButtonBox::Ok)->setEnabled(false);
+
+  // connect the buttons to their appropriate slots
+  connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
+  connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
+}
+
+QTDialog::~QTDialog()
+{
+}
+
+bool QTDialog::display(){
+  // Button state might have changed by some update that
+  // was done during query construction. To make sure
+  // the state is correct, we just call update one more time.
+  update();
+  if(exec()) {
+    setAll();
+    return true;
+  }
+  else {
+    return false;
+  }
+}
+
+void QTDialog::update(){
+  buttons->button(QDialogButtonBox::Ok)->setEnabled(checkAll());
+}
+
+/************************** Query Infrastructure ************************/
+
+void QTDialog::queryEmpty(char const*, string){
+  // TODO
+  ASSERT(false, "Not implemented yet");
+}
+
+void QTDialog::queryBoolean(char const*, bool*,string){
+  // TODO
+  ASSERT(false, "Not implemented yet");
+}
+
+void QTDialog::queryAtom(char const*, atom**, string){
+  // TODO
+  ASSERT(false, "Not implemented yet");
+}
+
+void QTDialog::queryBox(char const*, double**, 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));
+}
+
+/************************** Query Objects *******************************/
+
+QTDialog::IntQTQuery::IntQTQuery(string _title,int *_target,QBoxLayout *_parent,QTDialog *_dialog) :
+    Dialog::IntQuery(_title,_target),
+    parent(_parent)
+{
+  thisLayout = new QHBoxLayout();
+  titleLabel = new QLabel(QString(getTitle().c_str()));
+  inputBox = new QSpinBox();
+  inputBox->setValue(0);
+  parent->addLayout(thisLayout);
+  thisLayout->addWidget(titleLabel);
+  thisLayout->addWidget(inputBox);
+
+  pipe = new IntQTQueryPipe(&tmp,_dialog);
+  pipe->update(inputBox->value());
+  connect(inputBox,SIGNAL(valueChanged(int)),pipe,SLOT(update(int)));
+}
+
+QTDialog::IntQTQuery::~IntQTQuery()
+{
+  delete pipe;
+}
+
+// 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),
+    parent(_parent)
+{
+  thisLayout = new QHBoxLayout();
+  titleLabel = new QLabel(QString(getTitle().c_str()));
+  inputBox = new QDoubleSpinBox();
+  inputBox->setValue(0);
+  inputBox->setRange(-numeric_limits<double>::max(),numeric_limits<double>::max());
+  inputBox->setDecimals(3);
+  parent->addLayout(thisLayout);
+  thisLayout->addWidget(titleLabel);
+  thisLayout->addWidget(inputBox);
+
+  pipe = new DoubleQTQueryPipe(&tmp,_dialog);
+  pipe->update(inputBox->value());
+  connect(inputBox,SIGNAL(valueChanged(double)),pipe,SLOT(update(double)));
+}
+
+QTDialog::DoubleQTQuery::~DoubleQTQuery()
+{
+  delete pipe;
+}
+
+bool QTDialog::DoubleQTQuery::handle() {
+  return true;
+}
+
+
+QTDialog::StringQTQuery::StringQTQuery(string _title,string *_target,QBoxLayout *_parent,QTDialog *_dialog) :
+    Dialog::StringQuery(_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(&tmp,_dialog);
+  pipe->update(inputBox->text());
+  connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(update(const QString&)));
+}
+
+QTDialog::StringQTQuery::~StringQTQuery()
+{
+  delete pipe;
+}
+
+// All values besides the empty string are valid
+bool QTDialog::StringQTQuery::handle()
+{
+  return tmp!="";
+}
+
+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()
+{
+  delete pipe;
+}
+
+// All values besides the empty string are valid
+bool QTDialog::StringsQTQuery::handle()
+{
+  // dissect by ","
+  string::iterator olditer = temp.begin();
+  for(string::iterator iter = temp.begin(); iter != temp.end(); ++iter) {
+    if (*iter == ' ') {
+      tmp.push_back(string(iter, olditer));
+      olditer = iter;
+    }
+  }
+  if (olditer != temp.begin())  // insert last part also
+    tmp.push_back(string(olditer, temp.end()));
+
+  return temp!="";
+}
+
+QTDialog::MoleculeQTQuery::MoleculeQTQuery(string _title, molecule **_target, QBoxLayout *_parent,QTDialog *_dialog) :
+    Dialog::MoleculeQuery(_title,_target),
+    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 MoleculeQTQueryPipe(&tmp,_dialog,inputBox);
+  pipe->update(inputBox->currentIndex());
+  connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int)));
+}
+
+QTDialog::MoleculeQTQuery::~MoleculeQTQuery()
+{
+  delete pipe;
+}
+
+// Handling is easy, since the GUI makes it impossible to select invalid values
+bool QTDialog::MoleculeQTQuery::handle()
+{
+  return true;
+}
+
+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:"};
+  mainLayout= new QHBoxLayout();
+  titleLabel = new QLabel(QString(getTitle().c_str()));
+  mainLayout->addWidget(titleLabel);
+  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)));
+
+  }
+  parent->addLayout(mainLayout);
+}
+
+QTDialog::VectorQTQuery::~VectorQTQuery()
+{}
+
+bool QTDialog::VectorQTQuery::handle() {
+  return true;
+}
+
+
+QTDialog::ElementQTQuery::ElementQTQuery(std::string _title, vector<element *> *_target, QBoxLayout *_parent, QTDialog *_dialog) :
+    Dialog::ElementQuery(_title,_target),
+    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->name;
+    inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter).first));
+  }
+  parent->addLayout(thisLayout);
+  thisLayout->addWidget(titleLabel);
+  thisLayout->addWidget(inputBox);
+
+  pipe = new ElementQTQueryPipe(&elements,_dialog,inputBox);
+  pipe->update(inputBox->currentIndex());
+  connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int)));
+}
+
+QTDialog::ElementQTQuery::~ElementQTQuery()
+{
+  delete pipe;
+}
+
+bool QTDialog::ElementQTQuery::handle(){
+  return true;
+}
+
+/*************************** Plumbing *******************************/
+
+StringQTQueryPipe::StringQTQueryPipe(string *_content, QTDialog *_dialog) :
+  content(_content),
+  dialog(_dialog)
+{}
+
+StringQTQueryPipe::~StringQTQueryPipe()
+{}
+
+void StringQTQueryPipe::update(const QString& newText) {
+  content->assign(newText.toStdString());
+  dialog->update();
+}
+
+IntQTQueryPipe::IntQTQueryPipe(int *_content, QTDialog *_dialog) :
+  content(_content),
+  dialog(_dialog)
+{}
+
+IntQTQueryPipe::~IntQTQueryPipe()
+{}
+
+void IntQTQueryPipe::update(int newInt) {
+  (*content) = newInt;
+  dialog->update();
+}
+
+DoubleQTQueryPipe::DoubleQTQueryPipe(double *_content, QTDialog *_dialog) :
+  content(_content),
+  dialog(_dialog)
+{}
+
+DoubleQTQueryPipe::~DoubleQTQueryPipe()
+{}
+
+void DoubleQTQueryPipe::update(double newDbl) {
+  (*content) = newDbl;
+  dialog->update();
+}
+
+MoleculeQTQueryPipe::MoleculeQTQueryPipe(molecule **_content, QTDialog *_dialog, QComboBox *_theBox) :
+  content(_content),
+  dialog(_dialog),
+  theBox(_theBox)
+{}
+
+MoleculeQTQueryPipe::~MoleculeQTQueryPipe()
+{}
+
+void MoleculeQTQueryPipe::update(int newIndex) {
+  QVariant data = theBox->itemData(newIndex);
+  int idx = data.toInt();
+  (*content) = World::getInstance().getMolecule(MoleculeById(idx));
+  dialog->update();
+}
+
+ElementQTQueryPipe::ElementQTQueryPipe(std::vector<element *> *_content, QTDialog *_dialog, QComboBox *_theBox) :
+  content(_content),
+  dialog(_dialog),
+  theBox(_theBox)
+{
+  content->resize(1);
+}
+
+ElementQTQueryPipe::~ElementQTQueryPipe()
+{}
+
+void ElementQTQueryPipe::update(int newIndex) {
+  QVariant data = theBox->itemData(newIndex);
+  int idx = data.toInt();
+  (*content)[0] = World::getInstance().getPeriode()->FindElement(idx);
+  dialog->update();
+}
+
Index: src/UIElements/QT4/QTDialog.hpp
===================================================================
--- src/UIElements/QT4/QTDialog.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/QT4/QTDialog.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,241 @@
+/*
+ * QTDialog.hpp
+ *
+ *  Created on: Jan 18, 2010
+ *      Author: crueger
+ */
+
+#ifndef QTDIALOG_HPP_
+#define QTDIALOG_HPP_
+
+#include "UIElements/Dialog.hpp"
+#include <QtGui/QDialog>
+
+class QBoxLayout;
+class QLabel;
+class QSpinBox;
+class QDoubleSpinBox;
+class QLineEdit;
+class QComboBox;
+class QDialogButtonBox;
+
+
+// Forward declarations for plumbing
+class StringQTQueryPipe;
+class IntQTQueryPipe;
+class DoubleQTQueryPipe;
+class MoleculeQTQueryPipe;
+class ElementQTQueryPipe;
+
+class QTDialog : public QDialog, public Dialog
+{
+  Q_OBJECT
+public:
+  QTDialog();
+  virtual ~QTDialog();
+
+  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 bool display();
+
+  virtual void update();
+
+protected:
+  class IntQTQuery : public Dialog::IntQuery {
+    public:
+      IntQTQuery(std::string _title, int *_target,QBoxLayout *_parent,QTDialog *_dialog);
+      virtual ~IntQTQuery();
+      virtual bool handle();
+    private:
+      QBoxLayout *parent;
+      QBoxLayout *thisLayout;
+      QLabel *titleLabel;
+      QSpinBox *inputBox;
+
+      IntQTQueryPipe *pipe;
+    };
+
+    class DoubleQTQuery : public Dialog::DoubleQuery {
+    public:
+      DoubleQTQuery(std::string title, double *_target,QBoxLayout *_parent,QTDialog *_dialog);
+      virtual ~DoubleQTQuery();
+      virtual bool handle();
+    private:
+      QBoxLayout *parent;
+      QBoxLayout *thisLayout;
+      QLabel *titleLabel;
+      QDoubleSpinBox *inputBox;
+
+      DoubleQTQueryPipe *pipe;
+    };
+
+    class StringQTQuery : public Dialog::StringQuery {
+    public:
+      StringQTQuery(std::string _title, std::string *_target, QBoxLayout *_parent,QTDialog *_dialog);
+      virtual ~StringQTQuery();
+      virtual bool handle();
+    private:
+      QBoxLayout *parent;
+      QBoxLayout *thisLayout;
+      QLabel *titleLabel;
+      QLineEdit *inputBox;
+
+      StringQTQueryPipe *pipe;
+    };
+
+    class StringsQTQuery : public Dialog::StringsQuery {
+    public:
+      StringsQTQuery(std::string _title, std::vector<std::string> *_target, QBoxLayout *_parent,QTDialog *_dialog);
+      virtual ~StringsQTQuery();
+      virtual bool handle();
+    private:
+      QBoxLayout *parent;
+      QBoxLayout *thisLayout;
+      QLabel *titleLabel;
+      QLineEdit *inputBox;
+
+      StringQTQueryPipe *pipe;
+    };
+
+    class MoleculeQTQuery : public Dialog::MoleculeQuery {
+    public:
+      MoleculeQTQuery(std::string _title, molecule **_target, QBoxLayout *_parent,QTDialog *_dialog);
+      virtual ~MoleculeQTQuery();
+      virtual bool handle();
+    private:
+      QBoxLayout *parent;
+      QBoxLayout *thisLayout;
+      QLabel *titleLabel;
+      QComboBox *inputBox;
+
+      MoleculeQTQueryPipe *pipe;
+    };
+
+    class VectorQTQuery : public Dialog::VectorQuery {
+    public:
+      VectorQTQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check,QBoxLayout *,QTDialog *);
+      virtual ~VectorQTQuery();
+      virtual bool handle();
+    private:
+      QBoxLayout *parent;
+      QBoxLayout *mainLayout;
+      QLabel *titleLabel;
+      QBoxLayout *subLayout;
+      QBoxLayout *coordLayout[3];
+      QLabel *coordLabel[3];
+      QDoubleSpinBox *coordInput[3];
+
+      DoubleQTQueryPipe *pipe[3];
+    };
+
+    class ElementQTQuery : public Dialog::ElementQuery {
+    public:
+      ElementQTQuery(std::string _title, std::vector<element *> *_target, QBoxLayout *_parent, QTDialog *_dialog);
+      virtual ~ElementQTQuery();
+      virtual bool handle();
+    private:
+      QBoxLayout *parent;
+      QBoxLayout *thisLayout;
+      QLabel *titleLabel;
+      QComboBox *inputBox;
+
+      ElementQTQueryPipe *pipe;
+    };
+
+private:
+  QBoxLayout *mainLayout;
+  QBoxLayout *inputLayout;
+  QBoxLayout *buttonLayout;
+  QDialogButtonBox *buttons;
+};
+
+// All kinds of plumbing for Queries
+// Plumbing needs to be outside of the class where it is needed,
+// since MOC doesn't like nested classes
+
+class StringQTQueryPipe : public QWidget {
+  Q_OBJECT
+public:
+  StringQTQueryPipe(std::string *_content, QTDialog *_dialog);
+  virtual ~StringQTQueryPipe();
+
+public slots:
+  void update(const QString&);
+
+private:
+  std::string *content;
+  QTDialog *dialog;
+
+};
+
+class IntQTQueryPipe : public QWidget {
+  Q_OBJECT
+public:
+  IntQTQueryPipe(int *_content, QTDialog *_dialog);
+  virtual ~IntQTQueryPipe();
+
+public slots:
+  void update(int);
+
+private:
+  int *content;
+  QTDialog *dialog;
+
+};
+
+class DoubleQTQueryPipe : public QWidget {
+  Q_OBJECT
+public:
+  DoubleQTQueryPipe(double *_content, QTDialog *_dialog);
+  virtual ~DoubleQTQueryPipe();
+
+public slots:
+  void update(double);
+
+private:
+  double *content;
+  QTDialog *dialog;
+
+};
+
+class MoleculeQTQueryPipe : public QWidget {
+  Q_OBJECT
+public:
+  MoleculeQTQueryPipe(molecule **_content, QTDialog *_dialog, QComboBox *_theBox);
+  virtual ~MoleculeQTQueryPipe();
+
+public slots:
+  void update(int);
+
+private:
+  molecule **content;
+  QTDialog *dialog;
+  QComboBox *theBox;
+
+};
+
+class ElementQTQueryPipe : public QWidget {
+  Q_OBJECT
+public:
+  ElementQTQueryPipe(std::vector<element *> *_content, QTDialog *_dialog, QComboBox *_theBox);
+  virtual ~ElementQTQueryPipe();
+
+public slots:
+  void update(int);
+
+private:
+  std::vector<element *> *content;
+  QTDialog *dialog;
+  QComboBox *theBox;
+};
+#endif /* QTDIALOG_HPP_ */
Index: src/UIElements/QT4/QTMainWindow.cpp
===================================================================
--- src/UIElements/QT4/QTMainWindow.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/QT4/QTMainWindow.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,120 @@
+/*
+ * QTMainWindow.cpp
+ *
+ *  Created on: Jan 14, 2010
+ *      Author: crueger
+ */
+
+#include "QTMainWindow.hpp"
+
+#include<Qt/qapplication.h>
+#include<Qt/qlabel.h>
+#include<Qt/qstring.h>
+#include<Qt/qmenubar.h>
+#include<Qt/qsplitter.h>
+
+#include<iostream>
+#include<map>
+
+#include<boost/bind.hpp>
+
+#include "atom.hpp"
+#include "molecule.hpp"
+#include "Actions/Action.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Actions/MapOfActions.hpp"
+#include "Menu/Menu.hpp"
+#include "Menu/QT4/QTMenu.hpp"
+#include "Menu/ActionMenuItem.hpp"
+#include "Views/QT4/QTWorldView.hpp"
+#include "Views/QT4/GLMoleculeView.hpp"
+#include "Views/QT4/QTMoleculeView.hpp"
+#include "Views/QT4/QTStatusBar.hpp"
+#include "Helpers/MemDebug.hpp"
+
+
+using namespace std;
+
+QTMainWindow::QTMainWindow(QApplication *_theApp) :
+    theApp(_theApp)
+{
+  QSplitter *splitter1 = new QSplitter (Qt::Horizontal, this );
+  QSplitter *splitter2 = new QSplitter (Qt::Vertical, splitter1 );
+
+  worldDisplay = new QTWorldView(splitter2);
+
+  moleculeDisplay = new QTMoleculeView();
+  molecule3dDisplay = new GLMoleculeView();
+
+  MenuBar = menuBar();
+
+  std::map <std::string, QTMenu *> NametoTextMenuMap;
+  // go through all menus and create them
+  QTMenu *Menu = NULL;
+  for(std::map<std::string, std::pair<std::string,std::string> >::iterator iter = MapOfActions::getInstance().MenuDescription.begin(); iter != MapOfActions::getInstance().MenuDescription.end(); ++iter) {
+    cout << "Creating menu " << iter->first << endl;
+    Menu = new QTMenu(iter->first.c_str());
+    MenuBar->addMenu(Menu);
+    NametoTextMenuMap.insert( pair <std::string, QTMenu *> (iter->first, Menu) );
+    //new SubMenuItem(getSuitableShortForm(iter->first),iter->second.first,main_menu,Menu);
+  }
+
+  // populate all actions
+  MapOfActions::getInstance().populateActions();
+
+  // go through all actions and add them to its menu
+  for (std::map <std::string, QTMenu *>::iterator MenuRunner = NametoTextMenuMap.begin(); MenuRunner != NametoTextMenuMap.end(); ++MenuRunner) {
+    cout << "Creating Action " << MenuRunner->first << " in menu " << MenuRunner->second << endl;
+    populateMenu(MenuRunner->second, MenuRunner->first);
+  }
+
+  setCentralWidget(splitter1);
+  splitter1->addWidget(splitter2);
+  splitter1->addWidget(moleculeDisplay);
+  splitter2->addWidget(molecule3dDisplay);
+  splitter2->addWidget(worldDisplay);
+
+  statusBar = new QTStatusBar(this);
+  setStatusBar(statusBar);
+
+  connect(worldDisplay,SIGNAL(moleculeSelected(molecule*)),moleculeDisplay,SLOT(moleculeSelected(molecule*)));
+  connect(worldDisplay,SIGNAL(moleculeUnSelected(molecule*)),moleculeDisplay,SLOT(moleculeUnSelected(molecule*)));
+}
+
+QTMainWindow::~QTMainWindow()
+{
+  menuBar()->clear();
+  delete editMoleculesMenu;
+}
+
+void QTMainWindow::display() {
+  this->show();
+  theApp->exec();
+}
+
+char QTMainWindow::getSuitableShortForm(set <char> &ShortcutList, const std::string name) const
+{
+  for (std::string::const_iterator CharRunner = name.begin(); CharRunner != name.end(); ++CharRunner) {
+    if (ShortcutList.find(*CharRunner) == ShortcutList.end())
+      return *CharRunner;
+  }
+  DoeLog(1) && (eLog() << Verbose(1) << "Could not find a suitable shortform for TextWindow::getSuitableShortForm()." << endl);
+  return ((char)(ShortcutList.size() % 10) + '0');
+}
+
+void QTMainWindow::populateMenu(QTMenu* Menu, const  std::string &MenuName)
+{
+  Action *ActionItem = NULL;
+  set <char> ShortcutList;
+  // through all actions for this menu
+  std::pair < std::multimap <std::string, std::string>::iterator, std::multimap <std::string, std::string>::iterator > MenuActions = MapOfActions::getInstance().MenuContainsActionMap.equal_range(MenuName);
+  for (std::multimap <std::string, std::string>::const_iterator MenuRunner = MenuActions.first; MenuRunner != MenuActions.second; ++MenuRunner) {
+    cout << " Adding " << MenuRunner->second << " to submenu " << MenuName << endl;
+    ActionItem = ActionRegistry::getInstance().getActionByName(MenuRunner->second);
+    new ActionMenuItem(getSuitableShortForm(ShortcutList, MenuRunner->second),MapOfActions::getInstance().getDescription(MenuRunner->second).c_str(),Menu,ActionItem);
+  }
+  // finally add default quit item
+  //Action *returnFromAction = new TextMenu::LeaveAction(Menu);
+  //MenuItem *returnFromItem = new ActionMenuItem('q',"return to Main menu",Menu,returnFromAction);
+  //Menu->addDefault(returnFromItem);
+}
Index: src/UIElements/QT4/QTMainWindow.hpp
===================================================================
--- src/UIElements/QT4/QTMainWindow.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/QT4/QTMainWindow.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,48 @@
+/*
+ * QTMainWindow.hpp
+ *
+ *  Created on: Jan 14, 2010
+ *      Author: crueger
+ */
+
+#ifndef QTMAINWINDOW_HPP_
+#define QTMAINWINDOW_HPP_
+
+#include "UIElements/MainWindow.hpp"
+#include <QtGui/QMainWindow>
+
+#include <set>
+
+class QTWorldView;
+class StringView;
+class QTMenu;
+class GLMoleculeView;
+class QTMoleculeView;
+class QTStatusBar;
+
+class QTMainWindow : public QMainWindow, public MainWindow
+{
+  Q_OBJECT
+
+public:
+  QTMainWindow(QApplication *_theApp);
+  virtual ~QTMainWindow();
+
+  virtual void display();
+
+  char getSuitableShortForm(std::set <char> &ShortcutList, const std::string name) const;
+  void populateMenu(QTMenu* Menu, const  std::string &MenuName);
+
+private:
+  // All kinds of QTStuff used in this window
+  QApplication *theApp;
+  QTWorldView *worldDisplay;
+  QTMenu *editMoleculesMenu;
+  GLMoleculeView *molecule3dDisplay;
+  QTMoleculeView *moleculeDisplay;
+  QTStatusBar *statusBar;
+  QMenuBar *MenuBar;
+
+};
+
+#endif /* QTMAINWINDOW_HPP_ */
Index: src/UIElements/QT4/QTUIFactory.cpp
===================================================================
--- src/UIElements/QT4/QTUIFactory.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/QT4/QTUIFactory.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,56 @@
+/*
+ * QTUIFactory.cpp
+ *
+ *  Created on: Jan 14, 2010
+ *      Author: crueger
+ */
+
+#include <iostream>
+#include <cassert>
+
+using namespace std;
+
+#include <qapplication.h>
+
+#include "UIElements/QT4/QTUIFactory.hpp"
+#include "UIElements/QT4/QTMainWindow.hpp"
+#include "UIElements/QT4/QTDialog.hpp"
+#include "version.h"
+#include "defs.hpp"
+#include "Helpers/MemDebug.hpp"
+
+QTUIFactory::QTUIFactory()
+{
+  // For now we just fake the command line parameters to make QT happy
+  argc=1;
+  argv = new char*[1];
+  argv[0] = new char[256];
+  strcpy(argv[0],ESPACKVersion);
+  app = new QApplication(argc,argv);
+}
+
+QTUIFactory::~QTUIFactory()
+{
+  delete app;
+  delete [] argv[0];
+  delete [] argv;
+}
+
+Dialog* QTUIFactory::makeDialog() {
+  return new QTDialog();
+}
+
+MainWindow* QTUIFactory::makeMainWindow() {
+  return new QTMainWindow(app);
+}
+
+QTUIFactory::description::description() :
+    UIFactory::factoryDescription("QT4")
+{}
+
+QTUIFactory::description::~description()
+{}
+
+UIFactory* QTUIFactory::description::makeFactory(){
+  return new QTUIFactory();
+}
Index: src/UIElements/QT4/QTUIFactory.hpp
===================================================================
--- src/UIElements/QT4/QTUIFactory.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/QT4/QTUIFactory.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+/*
+ * QTUIFactory.hpp
+ *
+ *  Created on: Jan 14, 2010
+ *      Author: crueger
+ */
+
+#ifndef QTUIFACTORY_HPP_
+#define QTUIFACTORY_HPP_
+
+#include "UIElements/UIFactory.hpp"
+
+class QApplication;
+
+class QTUIFactory : public UIFactory
+{
+  friend class UIFactory;
+
+public:
+  virtual ~QTUIFactory();
+
+  virtual Dialog* makeDialog();
+  virtual MainWindow* makeMainWindow();
+
+  struct description : public UIFactory::factoryDescription {
+    description();
+    virtual ~description();
+
+    virtual UIFactory* makeFactory();
+  };
+
+protected:
+  QTUIFactory();
+
+private:
+  // faked command line arguments
+  int argc;
+  char **argv;
+  QApplication *app;
+};
+
+#endif /* QTUIFACTORY_HPP_ */
Index: src/UIElements/TextUI/TextDialog.cpp
===================================================================
--- src/UIElements/TextUI/TextDialog.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/TextUI/TextDialog.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,378 @@
+/*
+ * TextDialog.cpp
+ *
+ *  Created on: Jan 5, 2010
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include <iostream>
+
+#include <Descriptors/AtomDescriptor.hpp>
+#include <Descriptors/AtomIdDescriptor.hpp>
+#include <Descriptors/MoleculeDescriptor.hpp>
+#include <Descriptors/MoleculeIdDescriptor.hpp>
+#include "TextUI/TextDialog.hpp"
+
+#include "World.hpp"
+#include "periodentafel.hpp"
+#include "log.hpp"
+#include "verbose.hpp"
+
+#include "atom.hpp"
+#include "element.hpp"
+#include "molecule.hpp"
+#include "vector.hpp"
+
+using namespace std;
+
+
+TextDialog::TextDialog()
+{
+}
+
+TextDialog::~TextDialog()
+{
+}
+
+
+void TextDialog::queryEmpty(const char* title, string description){
+  registerQuery(new EmptyTextQuery(title,description));
+}
+
+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));
+}
+
+/************************** Query Infrastructure ************************/
+
+TextDialog::EmptyTextQuery::EmptyTextQuery(string title, std::string _description) :
+    Dialog::EmptyQuery(title,_description)
+{}
+
+TextDialog::EmptyTextQuery::~EmptyTextQuery() {}
+
+bool TextDialog::EmptyTextQuery::handle() {
+  cout << "Message of " << getTitle() << ":\n" << getDescription() << "\n";
+  return true;
+}
+
+TextDialog::IntTextQuery::IntTextQuery(string title, int * _target, std::string _description) :
+    Dialog::IntQuery(title,_target,_description)
+{}
+
+TextDialog::IntTextQuery::~IntTextQuery() {}
+
+bool TextDialog::IntTextQuery::handle() {
+  bool badInput = false;
+  do{
+    badInput = false;
+    Log() << Verbose(0) << getTitle();
+    cin >> tmp;
+    if(cin.fail()){
+      badInput=true;
+      cin.clear();
+      cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
+      Log() << Verbose(0) << "Input was not a number!" << endl;
+    }
+  } while(badInput);
+  // clear the input buffer of anything still in the line
+  cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
+  return true;
+}
+
+TextDialog::BooleanTextQuery::BooleanTextQuery(string title, bool * _target, std::string _description) :
+    Dialog::BooleanQuery(title,_target,_description)
+{}
+
+TextDialog::BooleanTextQuery::~BooleanTextQuery() {}
+
+bool TextDialog::BooleanTextQuery::handle() {
+  bool badInput = false;
+  char input = ' ';
+  do{
+    badInput = false;
+    Log() << Verbose(0) << getTitle();
+    cin >> input;
+    if ((input == 'y' ) || (input == 'Y')) {
+      tmp = true;
+    } else if ((input == 'n' ) || (input == 'N')) {
+      tmp = false;
+    } else {
+      badInput=true;
+      cin.clear();
+      cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
+      Log() << Verbose(0) << "Input was not of [yYnN]!" << endl;
+    }
+  } while(badInput);
+  // clear the input buffer of anything still in the line
+  cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
+  return true;
+}
+
+TextDialog::StringTextQuery::StringTextQuery(string title,string *_target, std::string _description) :
+    Dialog::StringQuery(title,_target,_description)
+{}
+
+TextDialog::StringTextQuery::~StringTextQuery() {}
+
+bool TextDialog::StringTextQuery::handle() {
+  Log() << Verbose(0) << getTitle();
+  getline(cin,tmp);
+  return true;
+}
+
+TextDialog::StringsTextQuery::StringsTextQuery(string title,vector<string> *_target, std::string _description) :
+    Dialog::StringsQuery(title,_target,_description)
+{}
+
+TextDialog::StringsTextQuery::~StringsTextQuery() {}
+
+bool TextDialog::StringsTextQuery::handle() {
+  Log() << Verbose(0) << getTitle();
+  getline(cin,temp);
+  // dissect by ","
+  string::iterator olditer = temp.begin();
+  for(string::iterator iter = temp.begin(); iter != temp.end(); ++iter) {
+    if (*iter == ' ') {
+      tmp.push_back(string(iter, olditer));
+      olditer = iter;
+    }
+  }
+  if (olditer != temp.begin())  // insert last part also
+    tmp.push_back(string(olditer, temp.end()));
+
+  return true;
+}
+
+TextDialog::DoubleTextQuery::DoubleTextQuery(string title,double *_target, std::string _description) :
+    Dialog::DoubleQuery(title,_target,_description)
+{}
+
+TextDialog::DoubleTextQuery::~DoubleTextQuery() {}
+
+bool TextDialog::DoubleTextQuery::handle() {
+  bool badInput = false;
+  do{
+    badInput = false;
+    Log() << Verbose(0) << getTitle();
+    cin >> tmp;
+    if(cin.fail()){
+      badInput = true;
+      cin.clear();
+      cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
+      Log() << Verbose(0) << "Input was not a number!" << endl;
+    }
+  }while(badInput);
+  cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
+  return true;
+}
+
+TextDialog::AtomTextQuery::AtomTextQuery(string title, atom **_target, std::string _description) :
+    Dialog::AtomQuery(title,_target,_description)
+{}
+
+TextDialog::AtomTextQuery::~AtomTextQuery() {}
+
+bool TextDialog::AtomTextQuery::handle() {
+  int idxOfAtom=0;
+  bool badInput = false;
+  do{
+    badInput = false;
+    Log() << Verbose(0) << getTitle();
+    cin >> idxOfAtom;
+    if(cin.fail()){
+      badInput = true;
+      cin.clear();
+      cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
+      Log() << Verbose(0) << "Input was not a number!" << endl;
+      continue;
+    }
+
+    tmp = World::getInstance().getAtom(AtomById(idxOfAtom));
+    if(!tmp && idxOfAtom!=-1){
+      Log() << Verbose(0) << "Invalid Atom Index" << endl;
+      badInput = true;
+    }
+
+  } while(badInput);
+  cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
+  return (idxOfAtom!=-1);
+}
+
+TextDialog::MoleculeTextQuery::MoleculeTextQuery(string title, molecule **_target, std::string _description) :
+    Dialog::MoleculeQuery(title,_target,_description)
+{}
+
+TextDialog::MoleculeTextQuery::~MoleculeTextQuery() {}
+
+bool TextDialog::MoleculeTextQuery::handle() {
+  int idxOfMol=0;
+  bool badInput = false;
+  do{
+    badInput = false;
+    Log() << Verbose(0) << getTitle();
+    cin >> idxOfMol;
+    if(cin.fail()){
+      badInput = true;
+      cin.clear();
+      cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
+      Log() << Verbose(0) << "Input was not a number!" << endl;
+      continue;
+    }
+
+    tmp = World::getInstance().getMolecule(MoleculeById(idxOfMol));
+    if(!tmp && idxOfMol!=-1){
+      Log() << Verbose(0) << "Invalid Molecule Index" << endl;
+      badInput = true;
+    }
+
+  } while(badInput);
+  cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
+  return (idxOfMol!=-1);
+}
+
+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::VectorTextQuery::~VectorTextQuery()
+{}
+
+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)
+{}
+
+TextDialog::BoxTextQuery::~BoxTextQuery()
+{}
+
+bool TextDialog::BoxTextQuery::handle() {
+  Log() << Verbose(0) << getTitle();
+
+  std::string coords[6] = {"xx","xy","xz", "yy", "yz", "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)
+{}
+
+TextDialog::ElementTextQuery::~ElementTextQuery()
+{}
+
+bool TextDialog::ElementTextQuery::handle() {
+  bool badInput=false;
+  bool aborted = false;
+  element * tmp = NULL;
+  do{
+    badInput = false;
+    Log() << Verbose(0) << getTitle();
+
+    // try to read as Atomic number
+    int Z;
+    cin >> Z;
+    if(!cin.fail()){
+      if(Z==-1){
+        aborted = true;
+      }
+      else{
+        tmp = World::getInstance().getPeriode()->FindElement(Z);
+        if(!tmp){
+          Log() << Verbose(0) << "No element with this atomic number!" << endl;
+          badInput = true;
+        } else {
+          elements.push_back(tmp);
+        }
+      }
+      continue;
+    }
+    else{
+      cin.clear();
+    }
+
+    // Try to read as shorthand
+    // the last buffer content was not removed, so we read the
+    // same thing again, this time as a string
+    string shorthand;
+    cin >> shorthand;
+    if(!cin.fail()){
+      if(shorthand.empty()){
+        aborted = true;
+      }
+      else{
+        tmp = World::getInstance().getPeriode()->FindElement(shorthand.c_str());
+        if(!tmp){
+          Log() << Verbose(0) << "No element with this shorthand!" << endl;
+          badInput = true;
+        } else {
+          elements.push_back(tmp);
+        }
+      }
+    }
+    else{
+      Log() << Verbose(0) << "Could not read input. Try Again." << endl;
+      cin.clear();
+      cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
+      badInput = true;
+    }
+
+  }while(badInput);
+  cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
+  return !aborted;
+}
Index: src/UIElements/TextUI/TextDialog.hpp
===================================================================
--- src/UIElements/TextUI/TextDialog.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/TextUI/TextDialog.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,118 @@
+/*
+ * TextDialog.hpp
+ *
+ *  Created on: Jan 5, 2010
+ *      Author: crueger
+ */
+
+#ifndef TEXTDIALOG_HPP_
+#define TEXTDIALOG_HPP_
+
+#include <string>
+
+#include "Dialog.hpp"
+
+class atom;
+class element;
+class molecule;
+class Vector;
+
+class TextDialog : public Dialog
+{
+public:
+  TextDialog();
+  virtual ~TextDialog();
+
+  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 = "");
+
+protected:
+  // specialized stuff for text queries
+  class EmptyTextQuery : public Dialog::EmptyQuery {
+  public:
+    EmptyTextQuery(std::string title, std::string _description = NULL);
+    virtual ~EmptyTextQuery();
+    virtual bool handle();
+  };
+
+  class BooleanTextQuery : public Dialog::BooleanQuery {
+  public:
+    BooleanTextQuery(std::string title, bool *_target, std::string _description = NULL);
+    virtual ~BooleanTextQuery();
+    virtual bool handle();
+  };
+
+  class IntTextQuery : public Dialog::IntQuery {
+  public:
+    IntTextQuery(std::string title, int *_target, std::string _description = NULL);
+    virtual ~IntTextQuery();
+    virtual bool handle();
+  };
+
+  class DoubleTextQuery : public Dialog::DoubleQuery {
+  public:
+    DoubleTextQuery(std::string title, double *_target, std::string _description = NULL);
+    virtual ~DoubleTextQuery();
+    virtual bool handle();
+  };
+
+  class StringTextQuery : public Dialog::StringQuery {
+  public:
+    StringTextQuery(std::string title, std::string *_target, std::string _description = NULL);
+    virtual ~StringTextQuery();
+    virtual bool handle();
+  };
+
+  class StringsTextQuery : public Dialog::StringsQuery {
+  public:
+    StringsTextQuery(std::string title, std::vector<std::string> *_target, std::string _description = NULL);
+    virtual ~StringsTextQuery();
+    virtual bool handle();
+  };
+
+  class AtomTextQuery : public Dialog::AtomQuery {
+  public:
+    AtomTextQuery(std::string title, atom **_target, std::string _description = NULL);
+    virtual ~AtomTextQuery();
+    virtual bool handle();
+  };
+
+  class MoleculeTextQuery : public Dialog::MoleculeQuery {
+  public:
+    MoleculeTextQuery(std::string title, molecule **_target, std::string _description = NULL);
+    virtual ~MoleculeTextQuery();
+    virtual bool handle();
+  };
+
+  class VectorTextQuery : public Dialog::VectorQuery {
+  public:
+    VectorTextQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check, std::string _description = NULL);
+    virtual ~VectorTextQuery();
+    virtual bool handle();
+  };
+
+  class BoxTextQuery : public Dialog::BoxQuery {
+  public:
+    BoxTextQuery(std::string title,double ** const _cellSize, std::string _description = NULL);
+    virtual ~BoxTextQuery();
+    virtual bool handle();
+  };
+
+  class ElementTextQuery : public Dialog::ElementQuery {
+  public:
+    ElementTextQuery(std::string title, std::vector<element *> *_target, std::string _description = NULL);
+    virtual ~ElementTextQuery();
+    virtual bool handle();
+  };
+};
+
+#endif /* TEXTDIALOG_HPP_ */
Index: src/UIElements/TextUI/TextStatusIndicator.cpp
===================================================================
--- src/UIElements/TextUI/TextStatusIndicator.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/TextUI/TextStatusIndicator.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,59 @@
+/*
+ * TextStatusIndicator.cpp
+ *
+ *  Created on: Feb 18, 2010
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "TextUI/TextStatusIndicator.hpp"
+
+#include <iostream>
+
+#include "Actions/Process.hpp"
+
+using namespace std;
+
+TextStatusIndicator::TextStatusIndicator() :
+  Observer("TextStatusIndicator")
+{
+  Process::AddObserver(this);
+}
+
+TextStatusIndicator::~TextStatusIndicator()
+{
+  Process::RemoveObserver(this);
+}
+
+void TextStatusIndicator::update(Observable *subject){
+  Process *proc;
+  // we are only observing Processes
+  if((proc=dynamic_cast<Process*>(subject))){
+    // see what kind of progress we have to display
+    if(proc->getMaxSteps()>0){
+      if(!proc->doesStop()){
+        cout << "Busy (" << proc->getName() << ") ";
+        // we can show a percentage done
+        cout << (int)proc->getDoneRatio() << "% done" << endl;
+      }
+    }
+    else{
+      // we only show some kind of busy animation
+      if(proc->doesStart()){
+        cout << "Busy (" << proc->getName() << ")";
+      }
+      if(!proc->doesStop()){
+        cout << ".";
+      }
+      else {
+        cout << endl;
+      }
+    }
+  }
+}
+
+void TextStatusIndicator::subjectKilled(Observable *subject){
+
+}
+
Index: src/UIElements/TextUI/TextStatusIndicator.hpp
===================================================================
--- src/UIElements/TextUI/TextStatusIndicator.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/TextUI/TextStatusIndicator.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,26 @@
+/*
+ * TextStatusIndicator.hpp
+ *
+ *  Created on: Feb 18, 2010
+ *      Author: crueger
+ */
+
+#ifndef TEXTSTATUSINDICATOR_HPP_
+#define TEXTSTATUSINDICATOR_HPP_
+
+#include "Patterns/Observer.hpp"
+
+class TextStatusIndicator : public Observer
+{
+public:
+  TextStatusIndicator();
+  virtual ~TextStatusIndicator();
+
+  void update(Observable *subject);
+  void subjectKilled(Observable *subject);
+
+private:
+
+};
+
+#endif /* TEXTSTATUSINDICATOR_HPP_ */
Index: src/UIElements/TextUI/TextUIFactory.cpp
===================================================================
--- src/UIElements/TextUI/TextUIFactory.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/TextUI/TextUIFactory.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,37 @@
+/*
+ * TextUIFactory.cpp
+ *
+ *  Created on: Jan 5, 2010
+ *      Author: crueger
+ */
+
+#include "UIElements/TextUI/TextUIFactory.hpp"
+#include "UIElements/TextUI/TextWindow.hpp"
+#include "UIElements/TextUI/TextDialog.hpp"
+
+TextUIFactory::TextUIFactory()
+{}
+
+TextUIFactory::~TextUIFactory()
+{}
+
+
+Dialog* TextUIFactory::makeDialog() {
+  return new TextDialog();
+}
+
+MainWindow* TextUIFactory::makeMainWindow() {
+  return new TextWindow();
+}
+
+TextUIFactory::description::description() :
+    UIFactory::factoryDescription("Text")
+{}
+
+TextUIFactory::description::~description()
+{}
+
+UIFactory* TextUIFactory::description::makeFactory(){
+  return new TextUIFactory();
+}
+
Index: src/UIElements/TextUI/TextUIFactory.hpp
===================================================================
--- src/UIElements/TextUI/TextUIFactory.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/TextUI/TextUIFactory.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,34 @@
+/*
+ * TextUIFactory.h
+ *
+ *  Created on: Jan 5, 2010
+ *      Author: crueger
+ */
+
+#ifndef TEXTUIFACTORY_HPP_
+#define TEXTUIFACTORY_HPP_
+
+#include "UIFactory.hpp"
+
+class TextUIFactory : public UIFactory
+{
+  friend class UIFactory;
+
+public:
+  virtual ~TextUIFactory();
+
+  virtual Dialog* makeDialog();
+  virtual MainWindow* makeMainWindow();
+
+  struct description : public UIFactory::factoryDescription {
+    description();
+    virtual ~description();
+
+    virtual UIFactory* makeFactory();
+  };
+
+protected:
+  TextUIFactory();
+};
+
+#endif /* TEXTUIFACTORY_HPP_ */
Index: src/UIElements/TextUI/TextWindow.cpp
===================================================================
--- src/UIElements/TextUI/TextWindow.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/TextUI/TextWindow.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,134 @@
+/*
+ * TextWindow.cpp
+ *
+ *  Created on: Jan 7, 2010
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include <boost/bind.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 "TextUI/TextStatusIndicator.hpp"
+#include "TextUI/TextWindow.hpp"
+#include "Actions/MapOfActions.hpp"
+#include "Actions/MethodAction.hpp"
+#include "Actions/ErrorAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Parser/ChangeTracker.hpp"
+#include "Views/StreamStringView.hpp"
+#include "Views/MethodStringView.hpp"
+#include "Helpers/MemDebug.hpp"
+
+#include "defs.hpp"
+#include "log.hpp"
+#include "verbose.hpp"
+
+// all needed due to config::SaveAll()
+#include "config.hpp"
+#include "periodentafel.hpp"
+
+// config::SaveAll() and enumerate()
+#include "molecule.hpp"
+
+#include <iostream>
+#include <map>
+
+// TODO: see what code can be moved to a base class for Graphic and Text Windows
+TextWindow::TextWindow()
+{
+  map <std::string, TextMenu *> NametoTextMenuMap;
+
+  // populate all actions
+  MapOfActions::getInstance().populateActions();
+
+  // build the main menu
+  main_menu = new TextMenu(Log() << Verbose(0), "Main Menu");
+
+  moleculeView = new StreamStringView(boost::bind(&MoleculeListClass::Enumerate,World::getInstance().getMolecules(),_1));
+  new DisplayMenuItem(main_menu,moleculeView,"Molecule List");
+
+  new SeperatorItem(main_menu);
+
+  Action* undoAction = ActionRegistry::getInstance().getActionByName("Undo");
+  new ActionMenuItem('u',"Undo last operation",main_menu,undoAction);
+
+  Action* redoAction = ActionRegistry::getInstance().getActionByName("Redo");
+  new ActionMenuItem('r',"Redo last operation",main_menu,redoAction);
+
+  new SeperatorItem(main_menu);
+
+  Action *setMoleculeAction = new MethodAction("setMoleculeAction",boost::bind(&MoleculeListClass::flipChosen,World::getInstance().getMolecules()));
+  new ActionMenuItem('a',"set molecule (in)active",main_menu,setMoleculeAction);
+
+  TextMenu *Menu = NULL;
+  std::set <char> ShortcutList;
+  for(map<std::string, pair<std::string,std::string> >::iterator iter = MapOfActions::getInstance().MenuDescription.begin(); iter != MapOfActions::getInstance().MenuDescription.end(); ++iter) {
+    Menu = new TextMenu(Log() << Verbose(0), iter->second.second);
+    NametoTextMenuMap.insert( pair <std::string, TextMenu *> (iter->first, Menu) );
+    new SubMenuItem(getSuitableShortForm(ShortcutList,iter->first),iter->second.first.c_str(),main_menu,Menu);
+  }
+
+  new SeperatorItem(main_menu);
+
+  Action *saveConfigAction = ActionRegistry::getInstance().getActionByName("output");
+  new ActionMenuItem('s',"save current setup to config files",main_menu,saveConfigAction);
+
+  quitAction = new MethodAction("quitAction",boost::bind(&TextMenu::doQuit,main_menu),false);
+  new ActionMenuItem('q',"quit",main_menu,quitAction);
+
+  // go through all menus and create them
+  for (map <std::string, TextMenu *>::iterator MenuRunner = NametoTextMenuMap.begin(); MenuRunner != NametoTextMenuMap.end(); ++MenuRunner) {
+    cout << "Creating Menu " << MenuRunner->first << "." << endl;
+    populateMenu(MenuRunner->second, MenuRunner->first);
+  }
+
+  // Add status indicators etc...
+
+  statusIndicator = new TextStatusIndicator();
+}
+
+TextWindow::~TextWindow()
+{
+  delete quitAction;
+  delete moleculeView;
+  delete statusIndicator;
+  delete main_menu;
+}
+
+void TextWindow::display() {
+  main_menu->display();
+}
+
+char TextWindow::getSuitableShortForm(std::set <char> &ShortcutList, const std::string name) const
+{
+  for (std::string::const_iterator CharRunner = name.begin(); CharRunner != name.end(); ++CharRunner) {
+    if (ShortcutList.find(*CharRunner) == ShortcutList.end())
+      return *CharRunner;
+  }
+  DoeLog(1) && (eLog() << Verbose(1) << "Could not find a suitable shortform for TextWindow::getSuitableShortForm()." << endl);
+  return ((char)(ShortcutList.size() % 10) + '0');
+}
+
+void TextWindow::populateMenu(TextMenu* Menu, const  std::string &MenuName)
+{
+  Action *ActionItem = NULL;
+  set <char> ShortcutList;
+  // through all actions for this menu
+  pair < multimap <std::string, std::string>::iterator, multimap <std::string, std::string>::iterator > MenuActions = MapOfActions::getInstance().MenuContainsActionMap.equal_range(MenuName);
+  for (multimap <std::string, std::string>::const_iterator MenuRunner = MenuActions.first; MenuRunner != MenuActions.second; ++MenuRunner) {
+    cout << " Adding " << MenuRunner->second << " to submenu " << MenuName << endl;
+    ActionItem = ActionRegistry::getInstance().getActionByName(MenuRunner->second);
+    new ActionMenuItem(getSuitableShortForm(ShortcutList, MenuRunner->second),MapOfActions::getInstance().getDescription(MenuRunner->second).c_str(),Menu,ActionItem);
+  }
+  // finally add default quit item
+  Action *returnFromAction = new TextMenu::LeaveAction(Menu);
+  MenuItem *returnFromItem = new ActionMenuItem('q',"return to Main menu",Menu,returnFromAction);
+  Menu->addDefault(returnFromItem);
+}
Index: src/UIElements/TextUI/TextWindow.hpp
===================================================================
--- src/UIElements/TextUI/TextWindow.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/TextUI/TextWindow.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,43 @@
+/*
+ * TextWindow.hpp
+ *
+ *  Created on: Jan 7, 2010
+ *      Author: crueger
+ */
+
+#ifndef TEXTWINDOW_HPP_
+#define TEXTWINDOW_HPP_
+
+#include "MainWindow.hpp"
+
+#include <set>
+
+class TextMenu;
+class Action;
+class StringView;
+class TextStatusIndicator;
+
+
+class TextWindow : public MainWindow
+{
+public:
+  TextWindow();
+  virtual ~TextWindow();
+
+  virtual void display();
+
+private:
+  // populaters
+  char getSuitableShortForm(std::set <char> &ShortcutList, const std::string name) const;
+  void populateMenu(TextMenu* Menu, const std::string &name);
+
+  TextMenu *main_menu;
+
+  // some actions only needed in textMenus
+  Action *quitAction;
+  // all views that are contained in the main Menu
+  StringView *moleculeView;
+  TextStatusIndicator *statusIndicator;
+};
+
+#endif /* TEXTWINDOW_HPP_ */
Index: src/UIElements/UIFactory.cpp
===================================================================
--- src/UIElements/UIFactory.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/UIFactory.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,45 @@
+/*
+ * UIFactory.cpp
+ *
+ *  Created on: Jan 5, 2010
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include <utility>
+#include "Patterns/Singleton_impl.hpp"
+#include "UIElements/UIFactory.hpp"
+#include "Helpers/Assert.hpp"
+#include "Helpers/MemDebug.hpp"
+
+using namespace std;
+
+std::map<std::string,boost::shared_ptr<UIFactory::factoryDescription> > UIFactory::factories;
+
+UIFactory::UIFactory()
+{}
+
+UIFactory::~UIFactory()
+{}
+
+void UIFactory::makeUserInterface(std::string type) {
+  ASSERT(factories.count(type),"Selected factory was not registered before creation.");
+  // call the factory factory
+  setInstance(factories[type]->makeFactory());
+}
+
+void UIFactory::registerFactory(factoryDescription *factoryDesc) {
+  ASSERT(!factories.count(factoryDesc->name),"Trying to re-register an already registered factory.");
+  factories.insert(make_pair(factoryDesc->name,
+                             boost::shared_ptr<factoryDescription>(factoryDesc)));
+}
+
+CONSTRUCT_SINGLETON(UIFactory)
+
+UIFactory::factoryDescription::factoryDescription(string _name) :
+  name(_name)
+{}
+
+UIFactory::factoryDescription::~factoryDescription()
+{}
Index: src/UIElements/UIFactory.hpp
===================================================================
--- src/UIElements/UIFactory.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/UIFactory.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,78 @@
+/*
+ * UIFactory.hpp
+ *
+ *  Created on: Jan 5, 2010
+ *      Author: crueger
+ */
+
+#ifndef UIFACTORY_HPP_
+#define UIFACTORY_HPP_
+
+class MainWindow;
+class Dialog;
+class DialogDescription;
+
+#include "Patterns/Singleton.hpp"
+
+#include <string>
+#include <map>
+#include <boost/smart_ptr.hpp>
+
+/**
+ * Abstract Factory to create any kind of User interface object needed by the programm.
+ *
+ * The factory can be created and has to be set to a certain type upon creation. It will then
+ * only create UIelements of that certain type, so that all UIElements match. This way different
+ * UIs can be handled in a concise abstract way.
+ *
+ * The main functionality is the MainWindow and the Dialog.
+ *
+ * MainWindow basically is the framework if the UI. The MainWindow has a run function which is
+ * called MainWindow::Display(), which will listen for user input and react to it via actions for
+ * as long as the user desires or tells the MainWindow to quit.
+ *
+ * Within the MainWindow Dialog classes may be instantiated which ask the user for input to
+ * certain actions he wants to perform.
+ *
+ */
+class UIFactory : public Singleton<UIFactory,false>
+{
+  friend class Singleton<UIFactory,false>;
+public:
+
+  /**
+   * Produce some kind of main window, of whichever type was chosen when the factory was created
+   */
+  virtual MainWindow* makeMainWindow()=0;
+
+  /**
+   * Produce a User Interaction Dialog, that can query values from the User.
+   * Again the type is determined upon factory creation.
+   */
+  virtual Dialog* makeDialog()=0;
+
+protected:
+  UIFactory();
+  virtual ~UIFactory();
+
+public:
+  struct factoryDescription {
+    factoryDescription(std::string _name);
+    virtual ~factoryDescription();
+
+    const std::string name;
+    // yes this method really is a factory factory, to allow insertion of
+    // arbitrary factories
+    virtual UIFactory* makeFactory()=0;
+  };
+  /**
+   * create a Factory of a certain type. From that moment on only those UIElements can be produced by the factory
+   */
+  static void makeUserInterface(std::string type);
+  static void registerFactory(factoryDescription *factoryDesc);
+protected:
+private:
+  static std::map<std::string,boost::shared_ptr<factoryDescription> > factories;
+};
+
+#endif /* UIFACTORY_HPP_ */
Index: src/UIElements/Views/MethodStringView.cpp
===================================================================
--- src/UIElements/Views/MethodStringView.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Views/MethodStringView.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+/*
+ * MethodStringView.cpp
+ *
+ *  Created on: Dec 14, 2009
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "MethodStringView.hpp"
+
+using namespace std;
+
+MethodStringView::MethodStringView(boost::function<string()> _displayMethod) :
+StringView(),
+displayMethod(_displayMethod)
+{
+  // TODO Auto-generated constructor stub
+
+}
+
+MethodStringView::~MethodStringView()
+{
+  // TODO Auto-generated destructor stub
+}
+
+
+const string MethodStringView::toString() {
+  return displayMethod();
+}
Index: src/UIElements/Views/MethodStringView.hpp
===================================================================
--- src/UIElements/Views/MethodStringView.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Views/MethodStringView.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+/*
+ * MethodStringView.hpp
+ *
+ *  Created on: Dec 14, 2009
+ *      Author: crueger
+ */
+
+#ifndef METHODSTRINGVIEW_HPP_
+#define METHODSTRINGVIEW_HPP_
+
+#include <boost/function.hpp>
+
+#include "Views/StringView.hpp"
+
+/**
+ * Wrapper to produce a StringView from any method that returns a String.
+ */
+class MethodStringView : public StringView
+{
+public:
+  MethodStringView(boost::function<std::string()>);
+  virtual ~MethodStringView();
+
+  virtual const std::string toString();
+
+private:
+  boost::function<std::string()> displayMethod;
+};
+
+#endif /* METHODSTRINGVIEW_HPP_ */
Index: src/UIElements/Views/QT4/GLMoleculeView.cpp
===================================================================
--- src/UIElements/Views/QT4/GLMoleculeView.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Views/QT4/GLMoleculeView.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,15 @@
+/*
+ * GLMoleculeView.cpp
+ *
+ *  Created on: Jan 26, 2010
+ *      Author: crueger
+ */
+
+#include "GLMoleculeView.hpp"
+
+GLMoleculeView::GLMoleculeView(QWidget *parent) :
+  QGLWidget(parent)
+{}
+
+GLMoleculeView::~GLMoleculeView()
+{}
Index: src/UIElements/Views/QT4/GLMoleculeView.hpp
===================================================================
--- src/UIElements/Views/QT4/GLMoleculeView.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Views/QT4/GLMoleculeView.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,21 @@
+/*
+ * GLMoleculeView.hpp
+ *
+ *  Created on: Jan 26, 2010
+ *      Author: crueger
+ */
+
+#ifndef GLMOLECULEVIEW_HPP_
+#define GLMOLECULEVIEW_HPP_
+
+#include <QtOpenGL/QGLWidget>
+
+class GLMoleculeView :  public QGLWidget
+{
+  Q_OBJECT
+public:
+  GLMoleculeView(QWidget *parent=0);
+  virtual ~GLMoleculeView();
+};
+
+#endif /* GLMOLECULEVIEW_HPP_ */
Index: src/UIElements/Views/QT4/QTMoleculeView.cpp
===================================================================
--- src/UIElements/Views/QT4/QTMoleculeView.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Views/QT4/QTMoleculeView.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,92 @@
+/*
+ * QTMoleculeView.cpp
+ *
+ *  Created on: Mar 4, 2010
+ *      Author: crueger
+ */
+
+#include "Views/QT4/QTMoleculeView.hpp"
+
+#include <iostream>
+#include "molecule.hpp"
+
+
+using namespace std;
+
+/***************** Basic structure for tab layout ***********/
+
+QTMoleculeView::QTMoleculeView() :
+    QTabWidget()
+{
+  allPage = new QTAllMoleculePage();
+  addTab(allPage,QString("All Molecules"));
+
+  connect(this,SIGNAL(addMolecule(molecule*)),allPage,SLOT(addMolecule(molecule*)));
+  connect(this,SIGNAL(removeMolecule(molecule*)),allPage,SLOT(removeMolecule(molecule*)));
+}
+
+QTMoleculeView::~QTMoleculeView()
+{}
+
+void QTMoleculeView::moleculeSelected(molecule *mol){
+  if(!pages.count(mol)){
+    string molName = mol->GetName();
+    QTMoleculePage *molPage = new QTMoleculePage(mol,molName);
+    addTab(molPage,QString(molName.c_str()));
+    pages[mol] = molPage;
+
+    connect(molPage,SIGNAL(nameChanged(QTMoleculePage*,std::string)),this,SLOT(nameChanged(QTMoleculePage*,std::string)));
+
+    emit addMolecule(mol);
+  }
+}
+
+void QTMoleculeView::moleculeUnSelected(molecule *mol){
+  if(pages.count(mol)){
+    QTMoleculePage *molPage = pages[mol];
+    removeTab(indexOf(molPage));
+    pages.erase(mol);
+    delete molPage;
+    emit removeMolecule(mol);
+  }
+}
+
+void QTMoleculeView::nameChanged(QTMoleculePage *page, std::string name){
+  setTabText(indexOf(page),QString(name.c_str()));
+}
+
+/************************ Tab for all Molecules ********************/
+
+QTAllMoleculePage::QTAllMoleculePage() :
+  Observer("QTAllMoleculePage")
+{}
+
+void QTAllMoleculePage::addMolecule(molecule *mol){}
+
+void QTAllMoleculePage::removeMolecule(molecule *mol){}
+
+void QTAllMoleculePage::update(Observable *subject){}
+
+void QTAllMoleculePage::subjectKilled(Observable *subject){}
+
+/************************ Tab for single Molecules *****************/
+
+QTMoleculePage::QTMoleculePage(molecule *_mol, string _name) :
+    Observer("QTMoleculePage"),
+    mol(_mol), name(_name)
+{
+  mol->signOn(this);
+}
+
+QTMoleculePage::~QTMoleculePage(){
+  mol->signOff(this);
+}
+
+void QTMoleculePage::update(Observable *subject){
+  if(name != mol->GetName()){
+    name = mol->GetName();
+    emit nameChanged(this,name);
+  }
+}
+
+void QTMoleculePage::subjectKilled(Observable *subject){}
Index: src/UIElements/Views/QT4/QTMoleculeView.hpp
===================================================================
--- src/UIElements/Views/QT4/QTMoleculeView.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Views/QT4/QTMoleculeView.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,77 @@
+/*
+ * MoleculeView.hpp
+ *
+ *  Created on: Mar 4, 2010
+ *      Author: crueger
+ */
+
+#ifndef MOLECULEVIEW_HPP_
+#define MOLECULEVIEW_HPP_
+
+#include <string>
+#include <QtGui/QTabWidget>
+#include "Patterns/Observer.hpp"
+
+class molecule;
+
+// Forwarding of the Tab-Pages
+class QTAllMoleculePage;
+class QTMoleculePage;
+
+class QTMoleculeView : public QTabWidget
+{
+  Q_OBJECT
+public:
+  QTMoleculeView();
+  virtual ~QTMoleculeView();
+
+public slots:
+  void moleculeSelected(molecule *);
+  void moleculeUnSelected(molecule *);
+
+  void nameChanged(QTMoleculePage *page, std::string name);
+
+signals:
+  void addMolecule(molecule *);
+  void removeMolecule(molecule *);
+
+
+private:
+  QTAllMoleculePage *allPage; //!< contained widget to cary information of all selected molecules
+  std::map<molecule*,QTMoleculePage *> pages;//!< contained widget to cary information on a specific molecule
+};
+
+/**
+ * Widget to display the tab page for all selected molecules
+ */
+class QTAllMoleculePage : public QWidget, public Observer {
+  Q_OBJECT
+public:
+  QTAllMoleculePage();
+  void update(Observable *subject);
+  void subjectKilled(Observable *subject);
+public slots:
+  void addMolecule(molecule *mol);
+  void removeMolecule(molecule *mol);
+};
+
+/**
+ * Widget to display the tab page for a single molecule
+ */
+class QTMoleculePage : public QWidget,  public Observer {
+  Q_OBJECT
+public:
+  QTMoleculePage(molecule *_mol,std::string _name);
+  virtual ~QTMoleculePage();
+
+  void update(Observable *subject);
+  void subjectKilled(Observable *subject);
+
+signals:
+  void nameChanged(QTMoleculePage*,std::string);
+
+private:
+  molecule *mol;
+  std::string name;
+};
+#endif /* MOLECULEVIEW_HPP_ */
Index: src/UIElements/Views/QT4/QTStatusBar.cpp
===================================================================
--- src/UIElements/Views/QT4/QTStatusBar.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Views/QT4/QTStatusBar.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,113 @@
+/*
+ * QTStatusBar.cpp
+ *
+ *  Created on: Feb 17, 2010
+ *      Author: crueger
+ */
+
+#include <sstream>
+
+#include <QtGui/QLabel>
+#include <QtGui/QBoxLayout>
+#include <QtGui/QProgressBar>
+
+#include "QTStatusBar.hpp"
+#include "World.hpp"
+#include "helpers.hpp"
+#include "Actions/Process.hpp"
+
+
+QTStatusBar::QTStatusBar(QWidget *_parent) :
+  QStatusBar(_parent),
+  Observer("QTStatusBar"),
+  parent(_parent),
+  atomCount(World::getInstance().numAtoms()),
+  moleculeCount(World::getInstance().numMolecules())
+{
+  World::getInstance().signOn(this);
+  Process::AddObserver(this);
+  statusLabel = new QLabel(this);
+  statusLabel->setFrameStyle(QFrame::NoFrame | QFrame::Plain);
+  addPermanentWidget(statusLabel);
+  redrawStatus();
+}
+
+QTStatusBar::~QTStatusBar()
+{
+  Process::RemoveObserver(this);
+  World::getInstance().signOff(this);
+}
+
+void QTStatusBar::update(Observable *subject){
+  if (subject==World::getPointer()){
+    atomCount = World::getInstance().numAtoms();
+    moleculeCount = World::getInstance().numMolecules();
+    redrawStatus();
+  }
+  else {
+    // we probably have some process
+    Process *proc;
+    if((proc=dynamic_cast<Process*>(subject))){
+      redrawProcess(proc);
+    }
+  }
+}
+
+void QTStatusBar::subjectKilled(Observable *subject){
+  // Processes don't notify when they are killed
+  atomCount = World::getInstance().numAtoms();
+  moleculeCount = World::getInstance().numMolecules();
+  World::getInstance().signOn(this);
+  redrawStatus();
+}
+
+void QTStatusBar::redrawStatus(){
+  stringstream sstr;
+  sstr << "You have " << atomCount << " atom" << PLURAL_S(atomCount)
+       <<" in " << moleculeCount << " molecule" << PLURAL_S(moleculeCount);
+  statusLabel->setText(QString(sstr.str().c_str()));
+}
+
+void QTStatusBar::redrawProcess(Process *proc){
+  progressIndicator *ind=0;
+  // see what we have to do with the process
+  if(proc->doesStart()){
+    ind = new progressIndicator(proc->getName());
+    ind->bar->setMaximum(proc->getMaxSteps());
+    progressBars.insert(pair<Process*,progressIndicator*>(proc,ind));
+  }
+  else {
+    ind = progressBars[proc];
+  }
+  if(activeProcess!=proc){
+    addWidget(ind->container);
+    activeProcess = proc;
+  }
+  ind->bar->setValue(proc->getCurrStep());
+  parent->repaint();
+  if(proc->doesStop()){
+    removeWidget(ind->container);
+    activeProcess = 0;
+    progressBars.erase(proc);
+    delete ind;
+  }
+}
+
+
+
+QTStatusBar::progressIndicator::progressIndicator(string name){
+  stringstream sstr;
+  sstr << "Busy (" << name << ")";
+  container = new QWidget();
+  layout = new QHBoxLayout(container);
+  label = new QLabel(QString(sstr.str().c_str()));
+  bar = new QProgressBar();
+
+  layout->addWidget(label);
+  layout->addWidget(bar);
+  container->setLayout(layout);
+}
+
+QTStatusBar::progressIndicator::~progressIndicator(){
+  delete container;
+}
Index: src/UIElements/Views/QT4/QTStatusBar.hpp
===================================================================
--- src/UIElements/Views/QT4/QTStatusBar.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Views/QT4/QTStatusBar.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,55 @@
+/*
+ * QTStatusBar.hpp
+ *
+ *  Created on: Feb 17, 2010
+ *      Author: crueger
+ */
+
+#ifndef QTSTATUSBAR_HPP_
+#define QTSTATUSBAR_HPP_
+
+#include <map>
+#include <utility>
+#include <string>
+#include <QtGui/QStatusBar>
+
+#include "Patterns/Observer.hpp"
+
+class QLabel;
+class QProgressBar;
+class Process;
+class QBoxLayout;
+
+class QTStatusBar : public QStatusBar, public Observer
+{
+  Q_OBJECT
+
+  struct progressIndicator{
+    progressIndicator(std::string);
+    ~progressIndicator();
+    QLabel *label;
+    QProgressBar *bar;
+    QBoxLayout *layout;
+    QWidget *container;
+  };
+public:
+  QTStatusBar(QWidget *parent=0);
+  virtual ~QTStatusBar();
+
+  void update(Observable *subject);
+  void subjectKilled(Observable *subject);
+
+private:
+  void redrawStatus();
+  void redrawProcess(Process *proc);
+
+  int atomCount;
+  int moleculeCount;
+
+  QLabel *statusLabel;
+  QWidget *parent;
+  std::map<Process*,progressIndicator*> progressBars;
+  Process* activeProcess;
+};
+
+#endif /* QTSTATUSBAR_HPP_ */
Index: src/UIElements/Views/QT4/QTWorldView.cpp
===================================================================
--- src/UIElements/Views/QT4/QTWorldView.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Views/QT4/QTWorldView.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,131 @@
+/*
+ * QTWorldView.cpp
+ *
+ *  Created on: Jan 21, 2010
+ *      Author: crueger
+ */
+
+#include "Views/QT4/QTWorldView.hpp"
+
+#include <iostream>
+
+#include "atom.hpp"
+#include "molecule.hpp"
+
+using namespace std;
+
+// maybe this should go with the definition of molecules
+
+// some attributes need to be easier to find for molecules
+// these attributes are skiped so far
+const int QTWorldView::COLUMNCOUNT = COLUMNTYPES_MAX;
+const char *QTWorldView::COLUMNNAMES[QTWorldView::COLUMNCOUNT]={"Name","Atoms"/*,"Formula"*/,"Center"/*,"Size"*/};
+
+QTWorldView::QTWorldView(QWidget * _parent) :
+  QTableWidget (_parent),
+  Observer("QTWorldView")
+{
+  setRowCount(0);
+  setColumnCount(COLUMNCOUNT);
+
+  for(int i=0; i<COLUMNCOUNT;++i) {
+    QTableWidgetItem *heading = new QTableWidgetItem();
+    heading->setText(QString(COLUMNNAMES[i]));
+    setHorizontalHeaderItem(i,heading);
+  }
+
+  molecules = World::getInstance().getMolecules();
+  molecules->signOn(this);
+  update(molecules);
+
+  connect(this,SIGNAL(cellChanged(int,int)),this,SLOT(moleculeChanged(int,int)));
+  connect(this,SIGNAL(cellClicked(int,int)),this,SLOT(cellSelected(int,int)));
+
+}
+
+QTWorldView::~QTWorldView()
+{
+  molecules->signOff(this);
+}
+
+void QTWorldView::update(Observable *publisher) {
+  int numMolecules = molecules->ListOfMolecules.size();
+  setRowCount(numMolecules);
+  molSelection.resize(numMolecules);
+  int i;
+  MoleculeList::iterator iter;
+  for(iter = molecules->ListOfMolecules.begin(),i=0;
+      iter != molecules->ListOfMolecules.end();
+      ++i,++iter) {
+
+    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->setData(Qt::UserRole,QVariant(index));
+    setVerticalHeaderItem(i,indexWidget);
+
+    const string name = (*iter)->getName();
+    QTableWidgetItem *nameWidget = new QTableWidgetItem();
+    nameWidget->setText(QString(name.c_str()));
+    setItem(i,NAME,nameWidget);
+
+    const int atomCount = (*iter)->getAtomCount();
+    QTableWidgetItem *countWidget= new QTableWidgetItem();
+    stringstream countsstr;
+    countsstr << atomCount;
+    countWidget->setText(QString(countsstr.str().c_str()));
+    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);
+
+    molSelection[i]=nameWidget->isSelected();
+  }
+}
+
+void QTWorldView::subjectKilled(Observable *publisher) {
+}
+
+void QTWorldView::moleculeChanged(int row, int column) {
+  int idx = verticalHeaderItem(row)->data(Qt::UserRole).toInt();
+  molecule *mol = molecules->ReturnIndex(idx);
+  string cellValue = item(row,NAME)->text().toStdString();
+  if(mol->getName() != cellValue && cellValue !="") {
+    mol->setName(cellValue);
+  }
+  else if(cellValue==""){
+    item(row,NAME)->setText(QString(mol->getName().c_str()));
+  }
+}
+
+
+void QTWorldView::cellSelected(int row, int column){
+  bool state = item(row,column)->isSelected();
+  for(int i = 0; i<COLUMNCOUNT; i++){
+    item(row,i)->setSelected(state);
+  }
+  // figure out which rows have changed
+  for(int i=0; i<rowCount();++i){
+    state = item(i,0)->isSelected();
+    if(molSelection[i]!=state){
+      int idx = verticalHeaderItem(i)->data(Qt::UserRole).toInt();
+      molecule *mol = molecules->ReturnIndex(idx);
+      if(state){
+        emit moleculeSelected(mol);
+      }
+      else{
+        emit moleculeUnSelected(mol);
+      }
+      molSelection[i]=state;
+    }
+  }
+}
Index: src/UIElements/Views/QT4/QTWorldView.hpp
===================================================================
--- src/UIElements/Views/QT4/QTWorldView.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Views/QT4/QTWorldView.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,47 @@
+/*
+ * QTWorldView.hpp
+ *
+ *  Created on: Jan 21, 2010
+ *      Author: crueger
+ */
+
+#ifndef QTMOLECULESVIEW_HPP_
+#define QTMOLECULESVIEW_HPP_
+
+#include <QtGui/QTableWidget>
+#include "Patterns/Observer.hpp"
+
+class molecule;
+class MoleculeListClass;
+
+class QTWorldView : public QTableWidget, public Observer
+{
+  Q_OBJECT
+
+public:
+  QTWorldView(QWidget * _parent=0);
+  virtual ~QTWorldView();
+
+protected:
+  virtual void update(Observable *publisher);
+  virtual void subjectKilled(Observable *publisher);
+
+  static const int COLUMNCOUNT;
+  enum {NAME,ATOMS,CENTER,COLUMNTYPES_MAX} COLUMNTYPES;
+  static const char *COLUMNNAMES[];
+
+private slots:
+  void moleculeChanged(int row, int column);
+
+  void cellSelected(int row, int column);
+
+signals:
+  void moleculeSelected(molecule*);
+  void moleculeUnSelected(molecule*);
+
+private:
+  std::vector<bool> molSelection; //!< needed to determine when a selection changes
+  MoleculeListClass *molecules;
+};
+
+#endif /* QTMOLECULESVIEW_HPP_ */
Index: src/UIElements/Views/StreamStringView.cpp
===================================================================
--- src/UIElements/Views/StreamStringView.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Views/StreamStringView.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,29 @@
+/*
+ * StreamStringView.cpp
+ *
+ *  Created on: Dec 14, 2009
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include <sstream>
+#include <iostream>
+
+#include "StreamStringView.hpp"
+
+using namespace std;
+
+StreamStringView::StreamStringView(boost::function<void(ostream *)> _displayMethod) :
+StringView(),
+displayMethod(_displayMethod)
+{}
+
+StreamStringView::~StreamStringView()
+{}
+
+const string StreamStringView::toString() {
+  stringstream s;
+  displayMethod(dynamic_cast<ostream *>(&s));
+  return s.str();
+}
Index: src/UIElements/Views/StreamStringView.hpp
===================================================================
--- src/UIElements/Views/StreamStringView.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Views/StreamStringView.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,36 @@
+/*
+ * StreamStringView.hpp
+ *
+ *  Created on: Dec 14, 2009
+ *      Author: crueger
+ */
+
+#ifndef STREAMSTRINGVIEW_HPP_
+#define STREAMSTRINGVIEW_HPP_
+
+#include <boost/function.hpp>
+#include <iostream>
+
+#include "Views/StringView.hpp"
+
+/**
+ * Wrapper to produce a StringView from any method that uses a stream to display something.
+ *
+ * The function is called with a stringstream which then is turned into a string later.
+ *
+ * Caveat: Make sure the stream passed to the method is actually used. Some methods seem to use a stream parameter for
+ * legacy reasons. These methods internally use the "Log() << Verbose()" mechanism instead of the stream.
+ */
+class StreamStringView : public StringView
+{
+public:
+  StreamStringView(boost::function<void(std::ostream *)>);
+  virtual ~StreamStringView();
+
+  virtual const std::string toString();
+
+private:
+  boost::function<void(std::ostream *)> displayMethod;
+};
+
+#endif /* STREAMSTRINGVIEW_HPP_ */
Index: src/UIElements/Views/StringView.cpp
===================================================================
--- src/UIElements/Views/StringView.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Views/StringView.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,21 @@
+/*
+ * StringView.cpp
+ *
+ *  Created on: Dec 14, 2009
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "StringView.hpp"
+
+StringView::StringView()
+{
+  // TODO Auto-generated constructor stub
+
+}
+
+StringView::~StringView()
+{
+  // TODO Auto-generated destructor stub
+}
Index: src/UIElements/Views/StringView.hpp
===================================================================
--- src/UIElements/Views/StringView.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Views/StringView.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,29 @@
+/*
+ * StringView.hpp
+ *
+ *  Created on: Dec 14, 2009
+ *      Author: crueger
+ */
+
+#ifndef STRINGVIEW_HPP_
+#define STRINGVIEW_HPP_
+
+#include <string>
+#include "Views/View.hpp"
+
+/**
+ * View to show something as a string
+ *
+ * This View is used by calling the toString method.
+ * This View does *not* use the observer pattern.
+ */
+class StringView : public View
+{
+public:
+  StringView();
+  virtual ~StringView();
+
+  virtual const std::string toString()=0;
+};
+
+#endif /* STRINGVIEW_HPP_ */
Index: src/UIElements/Views/View.cpp
===================================================================
--- src/UIElements/Views/View.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Views/View.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,21 @@
+/*
+ * View.cpp
+ *
+ *  Created on: Dec 14, 2009
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "View.hpp"
+
+View::View()
+{
+  // TODO Auto-generated constructor stub
+
+}
+
+View::~View()
+{
+  // TODO Auto-generated destructor stub
+}
Index: src/UIElements/Views/View.hpp
===================================================================
--- src/UIElements/Views/View.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/UIElements/Views/View.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,23 @@
+/*
+ * View.h
+ *
+ *  Created on: Dec 14, 2009
+ *      Author: crueger
+ */
+
+#ifndef VIEW_H_
+#define VIEW_H_
+
+/**
+ * Base class for all Views
+ *
+ * TODO: is this really needed or helpfull at all?
+ */
+class View
+{
+public:
+  View();
+  virtual ~View();
+};
+
+#endif /* VIEW_H_ */
Index: src/VectorSet.cpp
===================================================================
--- src/VectorSet.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/VectorSet.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,19 @@
+/*
+ * 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: src/VectorSet.hpp
===================================================================
--- src/VectorSet.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/VectorSet.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,54 @@
+/*
+ * 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 ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/World.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,344 @@
+/*
+ * World.cpp
+ *
+ *  Created on: Feb 3, 2010
+ *      Author: crueger
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "World.hpp"
+
+#include "atom.hpp"
+#include "config.hpp"
+#include "molecule.hpp"
+#include "periodentafel.hpp"
+#include "ThermoStatContainer.hpp"
+#include "Descriptors/AtomDescriptor.hpp"
+#include "Descriptors/AtomDescriptor_impl.hpp"
+#include "Descriptors/MoleculeDescriptor.hpp"
+#include "Descriptors/MoleculeDescriptor_impl.hpp"
+#include "Descriptors/SelectiveIterator_impl.hpp"
+#include "Actions/ManipulateAtomsProcess.hpp"
+#include "Helpers/Assert.hpp"
+
+#include "Patterns/Singleton_impl.hpp"
+
+using namespace std;
+
+/******************************* getter and setter ************************/
+periodentafel *&World::getPeriode(){
+  return periode;
+}
+
+config *&World::getConfig(){
+  return configuration;
+}
+
+// Atoms
+
+atom* World::getAtom(AtomDescriptor descriptor){
+  return descriptor.find();
+}
+
+vector<atom*> World::getAllAtoms(AtomDescriptor descriptor){
+  return descriptor.findAll();
+}
+
+vector<atom*> World::getAllAtoms(){
+  return getAllAtoms(AllAtoms());
+}
+
+int World::numAtoms(){
+  return atoms.size();
+}
+
+// Molecules
+
+molecule *World::getMolecule(MoleculeDescriptor descriptor){
+  return descriptor.find();
+}
+
+std::vector<molecule*> World::getAllMolecules(MoleculeDescriptor descriptor){
+  return descriptor.findAll();
+}
+
+std::vector<molecule*> World::getAllMolecules(){
+  return getAllMolecules(AllMolecules());
+}
+
+int World::numMolecules(){
+  return molecules_deprecated->ListOfMolecules.size();
+}
+
+// system
+
+double * World::getDomain() {
+  return cell_size;
+}
+
+void World::setDomain(double * matrix)
+{
+  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];
+}
+
+std::string World::getDefaultName() {
+  return defaultName;
+}
+
+void World::setDefaultName(std::string name)
+{
+  defaultName = name;
+};
+
+class ThermoStatContainer * World::getThermostats()
+{
+  return Thermostats;
+}
+
+
+int World::getExitFlag() {
+  return ExitFlag;
+}
+
+void World::setExitFlag(int flag) {
+  if (ExitFlag < flag)
+    ExitFlag = flag;
+}
+
+/******************** Methods to change World state *********************/
+
+molecule* World::createMolecule(){
+  OBSERVE;
+  molecule *mol = NULL;
+  mol = NewMolecule();
+  ASSERT(!molecules.count(currMoleculeId),"currMoleculeId did not specify an unused ID");
+  mol->setId(currMoleculeId++);
+  // store the molecule by ID
+  molecules[mol->getId()] = mol;
+  mol->signOn(this);
+  return mol;
+}
+
+void World::destroyMolecule(molecule* mol){
+  OBSERVE;
+  destroyMolecule(mol->getId());
+}
+
+void World::destroyMolecule(moleculeId_t id){
+  OBSERVE;
+  molecule *mol = molecules[id];
+  ASSERT(mol,"Molecule id that was meant to be destroyed did not exist");
+  DeleteMolecule(mol);
+  molecules.erase(id);
+}
+
+double *World::cell_size = NULL;
+
+atom *World::createAtom(){
+  OBSERVE;
+  atomId_t id = getNextAtomId();
+  atom *res = NewAtom(id);
+  res->setWorld(this);
+  // store the atom by ID
+  atoms[res->getId()] = res;
+  return res;
+}
+
+
+int World::registerAtom(atom *atom){
+  OBSERVE;
+  atomId_t id = getNextAtomId();
+  atom->setId(id);
+  atom->setWorld(this);
+  atoms[atom->getId()] = atom;
+  return atom->getId();
+}
+
+void World::destroyAtom(atom* atom){
+  OBSERVE;
+  int id = atom->getId();
+  destroyAtom(id);
+}
+
+void World::destroyAtom(atomId_t id) {
+  OBSERVE;
+  atom *atom = atoms[id];
+  ASSERT(atom,"Atom ID that was meant to be destroyed did not exist");
+  DeleteAtom(atom);
+  atoms.erase(id);
+  releaseAtomId(id);
+}
+
+bool World::changeAtomId(atomId_t oldId, atomId_t newId, atom* 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 = atoms[oldId];
+    ASSERT(target,"Atom with that ID not found");
+    return target->changeId(newId);
+  }
+  else{
+    if(reserveAtomId(newId)){
+      atoms.erase(oldId);
+      atoms.insert(pair<atomId_t,atom*>(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);
+}
+
+ManipulateAtomsProcess* World::manipulateAtoms(boost::function<void(atom*)> op,std::string name){
+  return manipulateAtoms(op,name,AllAtoms());
+}
+
+/********************* Internal Change methods for double Callback and Observer mechanism ********/
+
+void World::doManipulate(ManipulateAtomsProcess *proc){
+  proc->signOn(this);
+  {
+    OBSERVE;
+    proc->doManipulate(this);
+  }
+  proc->signOff(this);
+}
+/******************************* IDManagement *****************************/
+
+// Atoms
+
+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);
+    return id;
+  }
+}
+
+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);
+  }
+}
+
+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);
+    }
+    currAtomId=id+1;
+    return true;
+  }
+  else if(atomIdPool.count(id)){
+    atomIdPool.erase(id);
+    return true;
+  }
+  else{
+    // this ID could not be reserved
+    return false;
+  }
+}
+
+// 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());
+}
+
+/******************************* Singleton Stuff **************************/
+
+World::World() :
+    Observable("World"),
+    periode(new periodentafel),
+    configuration(new config),
+    Thermostats(new ThermoStatContainer),
+    ExitFlag(0),
+    atoms(),
+    currAtomId(0),
+    molecules(),
+    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.;
+  defaultName = "none";
+  molecules_deprecated->signOn(this);
+}
+
+World::~World()
+{
+  molecules_deprecated->signOff(this);
+  delete[] cell_size;
+  delete molecules_deprecated;
+  delete periode;
+  delete configuration;
+  delete Thermostats;
+  MoleculeSet::iterator molIter;
+  for(molIter=molecules.begin();molIter!=molecules.end();++molIter){
+    DeleteMolecule((*molIter).second);
+  }
+  molecules.clear();
+  AtomSet::iterator atIter;
+  for(atIter=atoms.begin();atIter!=atoms.end();++atIter){
+    DeleteAtom((*atIter).second);
+  }
+  atoms.clear();
+}
+
+// Explicit instantiation of the singleton mechanism at this point
+
+CONSTRUCT_SINGLETON(World)
+
+/******************************* deprecated Legacy Stuff ***********************/
+
+MoleculeListClass *&World::getMolecules() {
+  return molecules_deprecated;
+}
Index: src/World.hpp
===================================================================
--- src/World.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/World.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,293 @@
+/*
+ * World.hpp
+ *
+ *  Created on: Feb 3, 2010
+ *      Author: crueger
+ */
+
+#ifndef WORLD_HPP_
+#define WORLD_HPP_
+
+/*********************************************** includes ***********************************/
+
+#include <string>
+#include <map>
+#include <vector>
+#include <set>
+#include <boost/thread.hpp>
+#include <boost/shared_ptr.hpp>
+
+#include "types.hpp"
+#include "Descriptors/SelectiveIterator.hpp"
+#include "Patterns/Observer.hpp"
+#include "Patterns/Cacheable.hpp"
+#include "Patterns/Singleton.hpp"
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+// forward declarations
+class atom;
+class AtomDescriptor;
+class AtomDescriptor_impl;
+template<typename T> class AtomsCalculation;
+class config;
+class ManipulateAtomsProcess;
+class molecule;
+class MoleculeDescriptor;
+class MoleculeDescriptor_impl;
+class MoleculeListClass;
+class periodentafel;
+class ThermoStatContainer;
+
+/****************************************** forward declarations *****************************/
+
+/********************************************** Class World *******************************/
+
+class World : public Singleton<World>, public Observable
+{
+
+// Make access to constructor and destructor possible from inside the singleton
+friend class Singleton<World>;
+
+// necessary for coupling with descriptors
+friend class AtomDescriptor_impl;
+friend class AtomDescriptor;
+friend class MoleculeDescriptor_impl;
+friend class MoleculeDescriptor;
+
+// Actions, calculations etc associated with the World
+friend class ManipulateAtomsProcess;
+template<typename> friend class AtomsCalculation;
+public:
+
+  // Types for Atom and Molecule structures
+  typedef std::map<atomId_t,atom*> AtomSet;
+  typedef std::map<moleculeId_t,molecule*> MoleculeSet;
+
+  /***** getter and setter *****/
+  // reference to pointer is used for legacy reason... reference will be removed latter to keep encapsulation of World object
+  /**
+   * returns the periodentafel for the world.
+   */
+  periodentafel *&getPeriode();
+
+  /**
+   * returns the configuration for the world.
+   */
+  config *&getConfig();
+
+  /**
+   * returns the first atom that matches a given descriptor.
+   * Do not rely on ordering for descriptors that match more than one atom.
+   */
+  atom* getAtom(AtomDescriptor descriptor);
+
+  /**
+   * returns a vector containing all atoms that match a given descriptor
+   */
+  std::vector<atom*> getAllAtoms(AtomDescriptor descriptor);
+  std::vector<atom*> getAllAtoms();
+
+  /**
+   * returns a calculation that calls a given function on all atoms matching a descriptor.
+   * the calculation is not called at this point and can be used as an action, i.e. be stored in
+   * menus, be kept around for later use etc.
+   */
+  template<typename T> AtomsCalculation<T>* calcOnAtoms(boost::function<T(atom*)>,std::string,AtomDescriptor);
+  template<typename T> AtomsCalculation<T>* calcOnAtoms(boost::function<T(atom*)>,std::string);
+
+  /**
+   * get the number of atoms in the World
+   */
+  int numAtoms();
+
+  /**
+   * returns the first molecule that matches a given descriptor.
+   * Do not rely on ordering for descriptors that match more than one molecule.
+   */
+  molecule *getMolecule(MoleculeDescriptor descriptor);
+
+  /**
+   * returns a vector containing all molecules that match a given descriptor
+   */
+  std::vector<molecule*> getAllMolecules(MoleculeDescriptor descriptor);
+  std::vector<molecule*> getAllMolecules();
+
+  /**
+   * get the number of molecules in the World
+   */
+  int numMolecules();
+
+  /**
+   * get the domain size as a symmetric matrix (6 components)
+   */
+  double * getDomain();
+
+  /**
+   * set the domain size as a symmetric matrix (6 components)
+   */
+  void setDomain(double * matrix);
+
+  /**
+   * get the default name
+   */
+  std::string getDefaultName();
+
+  /**
+   * set the default name
+   */
+  void setDefaultName(std::string name);
+
+  /**
+   * get pointer to World's ThermoStatContainer
+   */
+  ThermoStatContainer * getThermostats();
+
+  /*
+   * get the ExitFlag
+   */
+  int getExitFlag();
+
+  /*
+   * set the ExitFlag
+   */
+  void setExitFlag(int flag);
+
+  /***** Methods to work with the World *****/
+
+  /**
+   * create a new molecule. This method should be used whenever any kind of molecule is needed. Assigns a unique
+   * ID to the molecule and stores it in the World for later retrieval. Do not create molecules directly.
+   */
+  molecule *createMolecule();
+
+  void destroyMolecule(molecule*);
+  void destroyMolecule(moleculeId_t);
+
+  /**
+   * Create a new atom. This method should be used whenever any atom is needed. Assigns a unique ID and stores
+   * the atom in the World. If the atom is not destroyed it will automatically be destroyed when the world ends.
+   */
+  atom *createAtom();
+
+  /**
+   * Registers a Atom unknown to world. Needed in some rare cases, e.g. when cloning atoms, or in some unittests.
+   * Do not re-register Atoms already known to the world since this will cause double-frees.
+   */
+  int registerAtom(atom*);
+
+  /**
+     * Delete some atom and erase it from the world. Use this whenever you need to destroy any atom. Do not call delete on
+     * atom directly since this will leave the pointer inside the world.
+   */
+  void destroyAtom(atom*);
+
+  /**
+   * Delete some atom and erase it from the world. Use this whenever you need to destroy any atom. Do not call delete on
+   * atom directly since this will leave the pointer inside the world.
+   */
+  void destroyAtom(atomId_t);
+
+  /**
+   * used when changing an atom Id.
+   * Unless you are calling this method from inside an atom don't fiddle with the third parameter.
+   *
+   * Return value indicates wether the change could be done or not.
+   */
+  bool changeAtomId(atomId_t oldId, atomId_t newId, atom* 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.
+   */
+  ManipulateAtomsProcess* manipulateAtoms(boost::function<void(atom*)>,std::string,AtomDescriptor);
+  ManipulateAtomsProcess* manipulateAtoms(boost::function<void(atom*)>,std::string);
+
+protected:
+  /**** Iterators to use internal data structures */
+
+  // Atoms
+  typedef SelectiveIterator<atom*,AtomSet,AtomDescriptor> AtomIterator;
+
+  /**
+   * returns an iterator over all Atoms matching a given descriptor.
+   * used for internal purposes, like AtomProcesses and AtomCalculations.
+   */
+  AtomIterator getAtomIter(AtomDescriptor descr);
+
+  /**
+   * returns an iterator to the end of the AtomSet. Due to overloading this iterator
+   * can be compared to iterators produced by getAtomIter (see the mis-matching types).
+   * Thus it can be used to detect when such an iterator is at the end of the list.
+   * used for internal purposes, like AtomProcesses and AtomCalculations.
+   */
+  AtomIterator atomEnd();
+
+  // Molecules
+
+  typedef SelectiveIterator<molecule*,MoleculeSet,MoleculeDescriptor> MoleculeIterator;
+
+  /**
+   * returns an iterator over all Molecules matching a given descriptor.
+   * used for internal purposes, like MoleculeProcesses and MoleculeCalculations.
+   */
+  MoleculeIterator getMoleculeIter(MoleculeDescriptor descr);
+
+  /**
+   * returns an iterator to the end of the MoleculeSet. Due to overloading this iterator
+   * can be compared to iterators produced by getMoleculeIter (see the mis-matching types).
+   * Thus it can be used to detect when such an iterator is at the end of the list.
+   * used for internal purposes, like MoleculeProcesses and MoleculeCalculations.
+   */
+  MoleculeIterator moleculeEnd();
+
+
+  /******* Internal manipulation routines for double callback and Observer mechanism ******/
+  void doManipulate(ManipulateAtomsProcess *);
+
+private:
+
+  atomId_t getNextAtomId();
+  void releaseAtomId(atomId_t);
+  bool reserveAtomId(atomId_t);
+
+  periodentafel *periode;
+  config *configuration;
+  static double *cell_size;
+  std::string defaultName;
+  class ThermoStatContainer *Thermostats;
+  int ExitFlag;
+public:
+  AtomSet atoms;
+private:
+  std::set<atomId_t> atomIdPool; //<!stores the pool for all available AtomIds below currAtomId
+  atomId_t currAtomId; //!< stores the next available Id for atoms
+  MoleculeSet molecules;
+  moleculeId_t currMoleculeId;
+private:
+  /**
+   * private constructor to ensure creation of the world using
+   * the singleton pattern.
+   */
+  World();
+
+  /**
+   * private destructor to ensure destruction of the world using the
+   * singleton pattern.
+   */
+  virtual ~World();
+
+  /*****
+   * some legacy stuff that is include for now but will be removed later
+   *****/
+public:
+  MoleculeListClass *&getMolecules();
+
+private:
+  MoleculeListClass *molecules_deprecated;
+};
+
+#endif /* WORLD_HPP_ */
Index: src/World_calculations.hpp
===================================================================
--- src/World_calculations.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/World_calculations.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,25 @@
+/*
+ * World_calculations.hpp
+ *
+ *  Created on: Feb 19, 2010
+ *      Author: crueger
+ */
+
+#ifndef WORLD_CALCULATIONS_HPP_
+#define WORLD_CALCULATIONS_HPP_
+
+
+#include "World.hpp"
+#include "Actions/AtomsCalculation.hpp"
+
+template<typename T>
+AtomsCalculation<T>* World::calcOnAtoms(boost::function<T(atom*)> op,std::string name,AtomDescriptor descr){
+  return new AtomsCalculation<T>(op,name,descr);
+}
+
+template<typename T>
+AtomsCalculation<T>* World::calcOnAtoms(boost::function<T(atom*)> op,std::string name) {
+  return calcOnAtoms<T>(op,name,AllAtoms());
+}
+
+#endif /* WORLD_CALCULATIONS_HPP_ */
Index: src/analysis_bonds.cpp
===================================================================
--- src/analysis_bonds.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/analysis_bonds.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,269 @@
+/*
+ * analysis_bonds.cpp
+ *
+ *  Created on: Nov 7, 2009
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "analysis_bonds.hpp"
+#include "atom.hpp"
+#include "bond.hpp"
+#include "element.hpp"
+#include "info.hpp"
+#include "log.hpp"
+#include "molecule.hpp"
+
+/** Calculates the min, mean and maximum bond counts for the given molecule.
+ * \param *mol molecule with atoms and atom::ListOfBonds
+ * \param &Min minimum count on return
+ * \param &Mean mean count on return
+ * \param &Max maximum count on return
+ */
+void GetMaxMinMeanBondCount(const molecule * const mol, double &Min, double &Mean, double &Max)
+{
+  Min = 2e+6;
+  Max = -2e+5;
+  Mean = 0.;
+
+  int AtomCount = 0;
+  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
+    const int count = (*iter)->ListOfBonds.size();
+    if (Max < count)
+      Max = count;
+    if (Min > count)
+      Min = count;
+    Mean += count;
+    AtomCount++;
+  }
+  if (((int)Mean % 2) != 0)
+    DoeLog(1) && (eLog()<< Verbose(1) << "Something is wrong with the bond structure, the number of bonds is not even!" << endl);
+  Mean /= (double)AtomCount;
+};
+
+/** Calculates the min and max bond distance of all atoms of two given elements.
+ * \param *mol molecule with atoms
+ * \param *type1 one element
+ * \param *type2 other element
+ * \param &Min minimum distance on return, 0 if no bond between the two elements
+ * \param &Mean mean distance (i.e. sum of distance for matching element pairs, divided by number) on return, 0 if no bond between the two elements
+ * \param &Max maximum distance on return, 0 if no bond between the two elements
+ */
+void MinMeanMaxBondDistanceBetweenElements(const molecule *mol, const element *type1, const element *type2, double &Min, double &Mean, double &Max)
+{
+  Min = 2e+6;
+  Mean = 0.;
+  Max = -2e+6;
+
+  int AtomNo = 0;
+  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
+    if ((*iter)->type == type1)
+      for (BondList::const_iterator BondRunner = (*iter)->ListOfBonds.begin(); BondRunner != (*iter)->ListOfBonds.end(); BondRunner++)
+        if ((*BondRunner)->GetOtherAtom((*iter))->type == type2) {
+          const double distance = (*BondRunner)->GetDistanceSquared();
+          if (Min > distance)
+            Min = distance;
+          if (Max < distance)
+            Max = distance;
+          Mean += sqrt(distance);
+          AtomNo++;
+        }
+  }
+  if (Max < 0) {
+    Max = Min = 0.;
+  } else {
+    Max = sqrt(Max);
+    Min = sqrt(Min);
+    Mean = Mean/(double)AtomNo;
+  }
+};
+
+/** Calculate the angle between \a *first and \a *origin and \a *second and \a *origin.
+ * \param *first first Vector
+ * \param *origin origin of angle taking
+ * \param *second second Vector
+ * \return angle between \a *first and \a *second, both relative to origin at \a *origin.
+ */
+double CalculateAngle(Vector *first, Vector *central, Vector *second)
+{
+  Vector OHBond;
+  Vector OOBond;
+
+  OHBond = (*first) - (*central);
+  OOBond = (*second) - (*central);
+  const double angle = OHBond.Angle(OOBond);
+  return angle;
+};
+
+/** Checks whether the angle between \a *Oxygen and \a *Hydrogen and \a *Oxygen and \a *OtherOxygen is less than 30 degrees.
+ * Note that distance criterion is not checked.
+ * \param *Oxygen first oxygen atom, bonded to \a *Hydrogen
+ * \param *Hydrogen hydrogen bonded to \a *Oxygen
+ * \param *OtherOxygen other oxygen atom
+ * \return true - angle criteria fulfilled, false - criteria not fulfilled, angle greater than 30 degrees.
+ */
+bool CheckHydrogenBridgeBondAngle(atom *Oxygen, atom *Hydrogen, atom *OtherOxygen)
+{
+  Info FunctionInfo(__func__);
+
+  // check angle
+  if (CalculateAngle(&Hydrogen->x, &Oxygen->x, &OtherOxygen->x) < M_PI*(30./180.)) {
+    return true;
+  } else {
+    return false;
+  }
+};
+
+/** Counts the number of hydrogen bridge bonds.
+ * With \a *InterfaceElement an extra element can be specified that identifies some boundary.
+ * Then, counting is for the h-bridges that connect to interface only.
+ * \param *molecules molecules to count bonds
+ * \param *InterfaceElement or NULL
+ * \param *Interface2Element or NULL
+ */
+int CountHydrogenBridgeBonds(MoleculeListClass *molecules, const element * InterfaceElement = NULL, const element * Interface2Element = NULL)
+{
+  int count = 0;
+  int OtherHydrogens = 0;
+  double Otherangle = 0.;
+  bool InterfaceFlag = false;
+  bool Interface2Flag = false;
+  bool OtherHydrogenFlag = true;
+  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); ++MolWalker) {
+    molecule::iterator Walker = (*MolWalker)->begin();
+    for(;Walker!=(*MolWalker)->end();++Walker){
+      for (MoleculeList::const_iterator MolRunner = molecules->ListOfMolecules.begin();MolRunner != molecules->ListOfMolecules.end(); ++MolRunner) {
+        molecule::iterator Runner = (*MolRunner)->begin();
+        for(;Runner!=(*MolRunner)->end();++Runner){
+          if (((*Walker)->type->Z  == 8) && ((*Runner)->type->Z  == 8)) {
+            // check distance
+            const double distance = (*Runner)->x.DistanceSquared((*Walker)->x);
+            if ((distance > MYEPSILON) && (distance < HBRIDGEDISTANCE*HBRIDGEDISTANCE)) { // distance >0 means  different atoms
+              // on other atom(Runner) we check for bond to interface element and
+              // check that O-O line is not in between the shanks of the two connected hydrogens (Otherangle > 104.5)
+              OtherHydrogenFlag = true;
+              Otherangle = 0.;
+              OtherHydrogens = 0;
+              InterfaceFlag = (InterfaceElement == NULL);
+              Interface2Flag = (Interface2Element == NULL);
+              for (BondList::const_iterator BondRunner = (*Runner)->ListOfBonds.begin(); BondRunner != (*Runner)->ListOfBonds.end(); BondRunner++) {
+                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);
+                  OtherHydrogenFlag = OtherHydrogenFlag && (angle > M_PI*(30./180.) + MYEPSILON);
+                  Otherangle += angle;
+                  OtherHydrogens++;
+                }
+                InterfaceFlag = InterfaceFlag || (OtherAtom->type == InterfaceElement);
+                Interface2Flag = Interface2Flag || (OtherAtom->type == Interface2Element);
+              }
+              DoLog(1) && (Log() << Verbose(1) << "Otherangle is " << Otherangle << " for " << OtherHydrogens << " hydrogens." << endl);
+              switch (OtherHydrogens) {
+                case 0:
+                case 1:
+                  break;
+                case 2:
+                  OtherHydrogenFlag = OtherHydrogenFlag && (Otherangle > M_PI*(104.5/180.) + MYEPSILON);
+                  break;
+                default: // 3 or more hydrogens ...
+                  OtherHydrogenFlag = false;
+                  break;
+              }
+              if (InterfaceFlag && Interface2Flag && OtherHydrogenFlag) {
+                // on this element (Walker) we check for bond to hydrogen, i.e. part of water molecule
+                for (BondList::const_iterator BondRunner = (*Walker)->ListOfBonds.begin(); BondRunner != (*Walker)->ListOfBonds.end(); BondRunner++) {
+                  atom * const OtherAtom = (*BondRunner)->GetOtherAtom(*Walker);
+                  if (OtherAtom->type->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);
+                      count++;
+                      break;
+                    }
+                  }
+                }
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+  return count;
+}
+
+/** Counts the number of bonds between two given elements.
+ * \param *molecules list of molecules with all atoms
+ * \param *first pointer to first element
+ * \param *second pointer to second element
+ * \return number of found bonds (\a *first-\a *second)
+ */
+int CountBondsOfTwo(MoleculeListClass * const molecules, const element * const first, const element * const second)
+{
+  int count = 0;
+
+  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); MolWalker++) {
+    molecule::iterator Walker = (*MolWalker)->begin();
+    for(;Walker!=(*MolWalker)->end();++Walker){
+      atom * theAtom = *Walker;
+      if ((theAtom->type == first) || (theAtom->type == 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)) {
+            count++;
+            DoLog(1) && (Log() << Verbose(1) << first->name << "-" << second->name << " bond found between " << *Walker << " and " << *OtherAtom << "." << endl);
+          }
+        }
+      }
+    }
+  }
+  return count;
+};
+
+/** Counts the number of bonds between three given elements.
+ * Note that we do not look for arbitrary sequence of given bonds, but \a *second will be the central atom and we check
+ * whether it has bonds to both \a *first and \a *third.
+ * \param *molecules list of molecules with all atoms
+ * \param *first pointer to first element
+ * \param *second pointer to second element
+ * \param *third pointer to third element
+ * \return number of found bonds (\a *first-\a *second-\a *third, \a *third-\a *second-\a *first, respectively)
+ */
+int CountBondsOfThree(MoleculeListClass * const molecules, const element * const first, const element * const second, const element * const third)
+{
+  int count = 0;
+  bool MatchFlag[2];
+  bool result = false;
+  const element * ElementArray[2];
+  ElementArray[0] = first;
+  ElementArray[1] = third;
+
+  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); MolWalker++) {
+    molecule::iterator Walker = (*MolWalker)->begin();
+    for(;Walker!=(*MolWalker)->end();++Walker){
+      atom *theAtom = *Walker;
+      if (theAtom->type == second) {  // first element matches
+        for (int i=0;i<2;i++)
+          MatchFlag[i] = false;
+        for (BondList::const_iterator BondRunner = theAtom->ListOfBonds.begin(); BondRunner != theAtom->ListOfBonds.end(); BondRunner++) {
+          atom * const OtherAtom = (*BondRunner)->GetOtherAtom(theAtom);
+          for (int i=0;i<2;i++)
+            if ((!MatchFlag[i]) && (OtherAtom->type == ElementArray[i])) {
+              MatchFlag[i] = true;
+              break;  // each bonding atom can match at most one element we are looking for
+            }
+        }
+        result = true;
+        for (int i=0;i<2;i++) // gather results
+          result = result && MatchFlag[i];
+        if (result) { // check results
+          count++;
+          DoLog(1) && (Log() << Verbose(1) << first->name << "-" << second->name << "-" << third->name << " bond found at " << *Walker << "." << endl);
+        }
+      }
+    }
+  }
+  return count;
+};
Index: src/analysis_bonds.hpp
===================================================================
--- src/analysis_bonds.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/analysis_bonds.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,39 @@
+/*
+ * analysis_bonds.hpp
+ *
+ *  Created on: Nov 7, 2009
+ *      Author: heber
+ */
+
+#ifndef ANALYSIS_BONDS_HPP_
+#define ANALYSIS_BONDS_HPP_
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+/*********************************************** defines ***********************************/
+
+#define HBRIDGEDISTANCE 3.5   //!< HBridge distance from PCCP Vol 10. 4802-4813
+
+/****************************************** forward declarations *****************************/
+
+class element;
+class MoleculeListClass;
+class molecule;
+
+/********************************************** declarations *******************************/
+
+void GetMaxMinMeanBondCount(const molecule * const mol, double &Min, double &Mean, double &Max);
+void MinMeanMaxBondDistanceBetweenElements(const molecule *mol, const element *type1, const element *type2, double &Min, double &Mean, double &Max);
+
+int CountHydrogenBridgeBonds(MoleculeListClass * const molecules, const element * InterfaceElement, const element * Interface2Element);
+int CountBondsOfTwo(MoleculeListClass * const molecules, const element * const first, const element * const second);
+int CountBondsOfThree(MoleculeListClass * const molecules, const element * const first, const element * const second, const element * const third);
+
+#endif /* ANALYSIS_BONDS_HPP_ */
Index: src/analysis_correlation.cpp
===================================================================
--- src/analysis_correlation.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/analysis_correlation.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,458 @@
+/*
+ * analysis.cpp
+ *
+ *  Created on: Oct 13, 2009
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include <iostream>
+
+#include "analysis_correlation.hpp"
+#include "element.hpp"
+#include "info.hpp"
+#include "log.hpp"
+#include "molecule.hpp"
+#include "tesselation.hpp"
+#include "tesselationhelpers.hpp"
+#include "triangleintersectionlist.hpp"
+#include "vector.hpp"
+#include "verbose.hpp"
+#include "World.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 &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)
+{
+  Info FunctionInfo(__func__);
+  PairCorrelationMap *outmap = NULL;
+  double distance = 0.;
+  double *domain = World::getInstance().getDomain();
+
+  if (molecules->ListOfMolecules.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++)
+    (*MolWalker)->doCountAtoms();
+
+  // create all possible pairs of elements
+  set <pair<element *, 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)
+        if (type1 != type2) {
+          PairsOfElements.insert( pair<element *, element*>(*type1,*type2) );
+          DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << (*type1)->symbol << " and " << (*type2)->symbol << "." << 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) );
+  } else { // all elements valid
+    PairsOfElements.insert( pair<element *, element*>((element *)NULL, (element *)NULL) );
+  }
+
+  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)) ) );
+                  }
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+  return outmap;
+};
+
+/** 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 &elements vector of elements to correlate
+ * \param ranges[NDIM] interval boundaries for the periodic images to scan also
+ * \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] )
+{
+  Info FunctionInfo(__func__);
+  PairCorrelationMap *outmap = NULL;
+  double distance = 0.;
+  int n[NDIM];
+  Vector checkX;
+  Vector periodicX;
+  int Othern[NDIM];
+  Vector checkOtherX;
+  Vector periodicOtherX;
+
+  if (molecules->ListOfMolecules.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++)
+    (*MolWalker)->doCountAtoms();
+
+  // create all possible pairs of elements
+  set <pair<element *, 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)
+        if (type1 != type2) {
+          PairsOfElements.insert( pair<element *, element*>(*type1,*type2) );
+          DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << (*type1)->symbol << " and " << (*type2)->symbol << "." << 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) );
+  } else { // all elements valid
+    PairsOfElements.insert( pair<element *, element*>((element *)NULL, (element *)NULL) );
+  }
+
+  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)) ) );
+                              }
+                        }
+                    }
+                  }
+                }
+              }
+            }
+      }
+      delete[](FullMatrix);
+      delete[](FullInverseMatrix);
+    }
+  }
+
+  return outmap;
+};
+
+/** Calculates the distance (pair) correlation between a given element and a point.
+ * \param *molecules list of molecules structure
+ * \param &elements vector of elements to correlate with point
+ * \param *point vector to the correlation point
+ * \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 )
+{
+  Info FunctionInfo(__func__);
+  CorrelationToPointMap *outmap = NULL;
+  double distance = 0.;
+  double *cell_size = World::getInstance().getDomain();
+
+  if (molecules->ListOfMolecules.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++)
+    (*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) ) );
+          }
+      }
+    }
+
+  return outmap;
+};
+
+/** Calculates the distance (pair) correlation between a given element, all its periodic images and a point.
+ * \param *molecules list of molecules structure
+ * \param &elements vector of elements to correlate to point
+ * \param *point vector to the correlation point
+ * \param ranges[NDIM] interval boundaries for the periodic images to scan also
+ * \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] )
+{
+  Info FunctionInfo(__func__);
+  CorrelationToPointMap *outmap = NULL;
+  double distance = 0.;
+  int n[NDIM];
+  Vector periodicX;
+  Vector checkX;
+
+  if (molecules->ListOfMolecules.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++)
+    (*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);
+    }
+
+  return outmap;
+};
+
+/** Calculates the distance (pair) correlation between a given element and a surface.
+ * \param *molecules list of molecules structure
+ * \param &elements vector of elements to correlate to surface
+ * \param *Surface pointer to Tesselation class surface
+ * \param *LC LinkedCell structure to quickly find neighbouring atoms
+ * \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 )
+{
+  Info FunctionInfo(__func__);
+  CorrelationToSurfaceMap *outmap = NULL;
+  double distance = 0;
+  class BoundaryTriangleSet *triangle = NULL;
+  Vector centroid;
+
+  if ((Surface == NULL) || (LC == NULL) || (molecules->ListOfMolecules.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++)
+    (*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);
+    }
+
+  return outmap;
+};
+
+/** Calculates the distance (pair) correlation between a given element, all its periodic images and and a surface.
+ * Note that we also put all periodic images found in the cells given by [ -ranges[i], ranges[i] ] and i=0,...,NDIM-1.
+ * I.e. We multiply the atom::node with the inverse of the domain matrix, i.e. transform it to \f$[0,0^3\f$, then add per
+ * axis an integer from [ -ranges[i], ranges[i] ] onto it and multiply with the domain matrix to bring it back into
+ * the real space. Then, we Tesselation::FindClosestTriangleToPoint() and DistanceToTrianglePlane().
+ * \param *molecules list of molecules structure
+ * \param &elements vector of elements to correlate to surface
+ * \param *Surface pointer to Tesselation class surface
+ * \param *LC LinkedCell structure to quickly find neighbouring atoms
+ * \param ranges[NDIM] interval boundaries for the periodic images to scan also
+ * \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] )
+{
+  Info FunctionInfo(__func__);
+  CorrelationToSurfaceMap *outmap = NULL;
+  double distance = 0;
+  class BoundaryTriangleSet *triangle = NULL;
+  Vector centroid;
+  int n[NDIM];
+  Vector periodicX;
+  Vector checkX;
+
+  if ((Surface == NULL) || (LC == NULL) || (molecules->ListOfMolecules.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++)
+    (*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;
+                  }
+                }
+            // 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);
+    }
+
+  return outmap;
+};
+
+/** Returns the index of the bin for a given value.
+ * \param value value whose bin to look for
+ * \param BinWidth width of bin
+ * \param BinStart first bin
+ */
+int GetBin ( const double value, const double BinWidth, const double BinStart )
+{
+  Info FunctionInfo(__func__);
+  int bin =(int) (floor((value - BinStart)/BinWidth));
+  return (bin);
+};
+
+
+/** Prints correlation (double, int) pairs to file.
+ * \param *file file to write to
+ * \param *map map to write
+ */
+void OutputCorrelation( ofstream * const file, const BinPairMap * const map )
+{
+  Info FunctionInfo(__func__);
+  *file << "BinStart\tCount" << endl;
+  for (BinPairMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) {
+    *file << setprecision(8) << runner->first << "\t" << runner->second << endl;
+  }
+};
+
+/** Prints correlation (double, (atom*,atom*) ) pairs to file.
+ * \param *file file to write to
+ * \param *map map to write
+ */
+void OutputPairCorrelation( ofstream * const file, const PairCorrelationMap * const map )
+{
+  Info FunctionInfo(__func__);
+  *file << "BinStart\tAtom1\tAtom2" << endl;
+  for (PairCorrelationMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) {
+    *file << setprecision(8) << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl;
+  }
+};
+
+/** Prints correlation (double, int) pairs to file.
+ * \param *file file to write to
+ * \param *map map to write
+ */
+void OutputCorrelationToPoint( ofstream * const file, const CorrelationToPointMap * const map )
+{
+  Info FunctionInfo(__func__);
+  *file << "BinStart\tAtom::x[i]-point.x[i]" << endl;
+  for (CorrelationToPointMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) {
+    *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 << endl;
+  }
+};
+
+/** Prints correlation (double, int) pairs to file.
+ * \param *file file to write to
+ * \param *map map to write
+ */
+void OutputCorrelationToSurface( ofstream * const file, const CorrelationToSurfaceMap * const map )
+{
+  Info FunctionInfo(__func__);
+  *file << "BinStart\tTriangle" << endl;
+  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;
+    }
+};
+
Index: src/analysis_correlation.hpp
===================================================================
--- src/analysis_correlation.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/analysis_correlation.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,139 @@
+/*
+ * analysis.hpp
+ *
+ *  Created on: Oct 13, 2009
+ *      Author: heber
+ */
+
+#ifndef ANALYSIS_HPP_
+#define ANALYSIS_HPP_
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <fstream>
+
+// STL headers
+#include <map>
+
+#include "defs.hpp"
+
+#include "atom.hpp"
+
+/****************************************** forward declarations *****************************/
+
+class BoundaryTriangleSet;
+class element;
+class LinkedCell;
+class MoleculeListClass;
+class Tesselation;
+class Vector;
+
+/********************************************** definitions *********************************/
+
+typedef multimap<double, pair<atom *, atom *> > PairCorrelationMap;
+typedef multimap<double, pair<atom *, const Vector *> > CorrelationToPointMap;
+typedef multimap<double, pair<atom *, BoundaryTriangleSet *> > CorrelationToSurfaceMap;
+typedef map<double, int> BinPairMap;
+
+/********************************************** 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] );
+int GetBin ( const double value, const double BinWidth, const double BinStart );
+void OutputCorrelation( ofstream * const file, const BinPairMap * const map );
+void OutputPairCorrelation( ofstream * const file, const PairCorrelationMap * const map );
+void OutputCorrelationToPoint( ofstream * const file, const CorrelationToPointMap * const map );
+void OutputCorrelationToSurface( ofstream * const file, const CorrelationToSurfaceMap * const map );
+
+
+/** Searches for lowest and highest value in a given map of doubles.
+ * \param *map map of doubles to scan
+ * \param &min minimum on return
+ * \param &max maximum on return
+ */
+template <typename T> void GetMinMax ( T *map, double &min, double &max)
+{
+  min = 0.;
+  max = 0.;
+  bool FirstMinFound = false;
+  bool FirstMaxFound = false;
+
+  if (map == NULL) {
+    DoeLog(0) && (eLog()<< Verbose(0) << "Nothing to min/max, map is NULL!" << endl);
+    performCriticalExit();
+    return;
+  }
+
+  for (typename T::iterator runner = map->begin(); runner != map->end(); ++runner) {
+    if ((min > runner->first) || (!FirstMinFound)) {
+      min = runner->first;
+      FirstMinFound = true;
+    }
+    if ((max < runner->first) || (!FirstMaxFound)) {
+      max = runner->first;
+      FirstMaxFound = true;
+    }
+  }
+};
+
+/** Puts given correlation data into bins of given size (histogramming).
+ * Note that BinStart and BinEnd are desired to fill the complete range, even where Bins are zero. If this is
+ * not desired, give equal BinStart and BinEnd and the map will contain only Bins where the count is one or greater. If a
+ * certain start value is desired, give BinStart and a BinEnd that is smaller than BinStart, then only BinEnd will be
+ * calculated automatically, i.e. BinStart = 0. and BinEnd = -1. .
+ * Also note that the range is given inclusive, i.e. [ BinStart, BinEnd ].
+ * \param *map map of doubles to count
+ * \param BinWidth desired width of the binds
+ * \param BinStart first bin
+ * \param BinEnd last bin
+ * \return Map of doubles (the bins) with counts as values
+ */
+template <typename T> BinPairMap *BinData ( T *map, const double BinWidth, const double BinStart, const double BinEnd )
+{
+  BinPairMap *outmap = new BinPairMap;
+  int bin = 0;
+  double start = 0.;
+  double end = 0.;
+  pair <BinPairMap::iterator, bool > BinPairMapInserter;
+
+  if (map == NULL) {
+    DoeLog(0) && (eLog()<< Verbose(0) << "Nothing to bin, is NULL!" << endl);
+    performCriticalExit();
+    return outmap;
+  }
+
+  if (BinStart == BinEnd) { // if same, find range ourselves
+    GetMinMax( map, start, end);
+  } else if (BinEnd < BinStart) { // if BinEnd smaller, just look for new max
+    GetMinMax( map, start, end);
+    start = BinStart;
+  } else { // else take both values
+    start = BinStart;
+    end = BinEnd;
+  }
+  for (int runner = 0; runner <= ceil((end-start)/BinWidth); runner++)
+    outmap->insert( pair<double, int> ((double)runner*BinWidth+start, 0) );
+
+  for (typename T::iterator runner = map->begin(); runner != map->end(); ++runner) {
+    bin = GetBin (runner->first, BinWidth, start);
+    BinPairMapInserter = outmap->insert ( pair<double, int> ((double)bin*BinWidth+start, 1) );
+    if (!BinPairMapInserter.second) {  // bin already present, increase
+      BinPairMapInserter.first->second += 1;
+    }
+  }
+
+  return outmap;
+};
+
+#endif /* ANALYSIS_HPP_ */
Index: src/analyzer.cpp
===================================================================
--- src/analyzer.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/analyzer.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,567 @@
+/** \file analyzer.cpp
+ *
+ * Takes evaluated fragments (energy and forces) and does evaluation of how sensible the BOSSANOVA
+ * approach was, e.g. in the decay of the many-body-contributions.
+ *
+ */
+
+//============================ 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
+#include <config.h>
+#endif
+
+
+//============================== MAIN =============================
+
+int main(int argc, char **argv)
+{
+  periodentafel *periode = NULL; // and a period table of all elements
+  EnergyMatrix Energy;
+  EnergyMatrix EnergyFragments;
+  ForceMatrix Force;
+  ForceMatrix ForceFragments;
+  HessianMatrix Hessian;
+  HessianMatrix HessianFragments;
+  EnergyMatrix Hcorrection;
+  EnergyMatrix HcorrectionFragments;
+  ForceMatrix Shielding;
+  ForceMatrix ShieldingPAS;
+  ForceMatrix Chi;
+  ForceMatrix ChiPAS;
+  EnergyMatrix Time;
+  ForceMatrix ShieldingFragments;
+  ForceMatrix ShieldingPASFragments;
+  ForceMatrix ChiFragments;
+  ForceMatrix ChiPASFragments;
+  KeySetsContainer KeySet;
+  ofstream output;
+  ofstream output2;
+  ofstream output3;
+  ofstream output4;
+  ifstream input;
+  stringstream filename;
+  time_t t = time(NULL);
+  struct tm *ts = localtime(&t);
+  char *datum = asctime(ts);
+  stringstream Orderxrange;
+  stringstream Fragmentxrange;
+  stringstream yrange;
+  char *dir = NULL;
+  bool NoHessian = false;
+  bool NoTime = false;
+  bool NoHCorrection = true;
+  int counter = 0;
+
+  DoLog(0) && (Log() << Verbose(0) << "ANOVA Analyzer" << endl);
+  DoLog(0) && (Log() << Verbose(0) << "==============" << endl);
+
+  // Get the command line options
+  if (argc < 4) {
+    DoLog(0) && (Log() << Verbose(0) << "Usage: " << argv[0] << " <inputdir> <prefix> <outputdir> [elementsdb]" << endl);
+    DoLog(0) && (Log() << Verbose(0) << "<inputdir>\ttherein the output of a molecuilder fragmentation is expected, each fragment with a subdir containing an energy.all and a forces.all file." << endl);
+    DoLog(0) && (Log() << Verbose(0) << "<prefix>\tprefix of energy and forces file." << endl);
+    DoLog(0) && (Log() << Verbose(0) << "<outputdir>\tcreated plotfiles and datafiles are placed into this directory " << endl);
+    DoLog(0) && (Log() << Verbose(0) << "[elementsdb]\tpath to elements database, needed for shieldings." << endl);
+    return 1;
+  } else {
+    dir = new char[strlen(argv[2]) + 2];
+    strcpy(dir, "/");
+    strcat(dir, argv[2]);
+  }
+
+  if (argc > 4) {
+    DoLog(0) && (Log() << Verbose(0) << "Loading periodentafel." << endl);
+    periode = new periodentafel;
+    periode->LoadPeriodentafel(argv[4]);
+  }
+
+  // Test the given directory
+  if (!TestParams(argc, argv))
+    return 1;
+
+  // +++++++++++++++++ PARSING +++++++++++++++++++++++++++++++
+
+  // ------------- Parse through all Fragment subdirs --------
+  if (!Energy.ParseFragmentMatrix(argv[1], dir, EnergySuffix,0,0)) return 1;
+  if (!Hcorrection.ParseFragmentMatrix(argv[1], "", HCORRECTIONSUFFIX,0,0)) {
+    NoHCorrection = true;
+    DoeLog(2) && (eLog()<< Verbose(2) << "No HCorrection file found, skipping these." << endl);
+  }
+  
+  if (!Force.ParseFragmentMatrix(argv[1], dir, ForcesSuffix,0,0)) return 1;
+  if (!Hessian.ParseFragmentMatrix(argv[1], dir, HessianSuffix,0,0)) {
+    NoHessian = true;
+    DoeLog(2) && (eLog()<< Verbose(2) << "No Hessian file found, skipping these." << endl);
+  }
+  if (!Time.ParseFragmentMatrix(argv[1], dir, TimeSuffix, 10,1)) {
+    NoTime = true;
+    DoeLog(2) && (eLog()<< Verbose(2) << "No speed file found, skipping these." << endl);
+  }
+  if (periode != NULL) { // also look for PAS values
+    if (!Shielding.ParseFragmentMatrix(argv[1], dir, ShieldingSuffix, 1, 0)) return 1;
+    if (!ShieldingPAS.ParseFragmentMatrix(argv[1], dir, ShieldingPASSuffix, 1, 0)) return 1;
+    if (!Chi.ParseFragmentMatrix(argv[1], dir, ChiSuffix, 1, 0)) return 1;
+    if (!ChiPAS.ParseFragmentMatrix(argv[1], dir, ChiPASSuffix, 1, 0)) return 1;
+  }
+
+  // ---------- Parse the TE Factors into an array -----------------
+  if (!Energy.ParseIndices()) return 1;
+  if (!NoHCorrection) Hcorrection.ParseIndices();
+
+  // ---------- Parse the Force indices into an array ---------------
+  if (!Force.ParseIndices(argv[1])) return 1;
+  if (!ForceFragments.AllocateMatrix(Force.Header, Force.MatrixCounter, Force.RowCounter, Force.ColumnCounter)) return 1;
+  if (!ForceFragments.InitialiseIndices((class MatrixContainer *)&Force)) return 1;
+
+  // ---------- Parse hessian indices into an array -----------------
+  if (!NoHessian) {
+    if (!Hessian.InitialiseIndices((class MatrixContainer *)&Force)) return 1;
+    if (!HessianFragments.AllocateMatrix(Hessian.Header, Hessian.MatrixCounter, Hessian.RowCounter, Hessian.ColumnCounter)) return 1;
+    if (!HessianFragments.InitialiseIndices((class MatrixContainer *)&Force)) return 1;
+  }
+
+  // ---------- Parse the shielding indices into an array ---------------
+  if (periode != NULL) { // also look for PAS values
+    if(!Shielding.ParseIndices(argv[1])) return 1;
+    if(!ShieldingPAS.ParseIndices(argv[1])) return 1;
+    if (!ShieldingFragments.AllocateMatrix(Shielding.Header, Shielding.MatrixCounter, Shielding.RowCounter, Shielding.ColumnCounter)) return 1;
+    if (!ShieldingPASFragments.AllocateMatrix(ShieldingPAS.Header, ShieldingPAS.MatrixCounter, ShieldingPAS.RowCounter, ShieldingPAS.ColumnCounter)) return 1;
+    if(!ShieldingFragments.ParseIndices(argv[1])) return 1;
+    if(!ShieldingPASFragments.ParseIndices(argv[1])) return 1;
+    if(!Chi.ParseIndices(argv[1])) return 1;
+    if(!ChiPAS.ParseIndices(argv[1])) return 1;
+    if (!ChiFragments.AllocateMatrix(Chi.Header, Chi.MatrixCounter, Chi.RowCounter, Chi.ColumnCounter)) return 1;
+    if (!ChiPASFragments.AllocateMatrix(ChiPAS.Header, ChiPAS.MatrixCounter, ChiPAS.RowCounter, ChiPAS.ColumnCounter)) return 1;
+    if(!ChiFragments.ParseIndices(argv[1])) return 1;
+    if(!ChiPASFragments.ParseIndices(argv[1])) return 1;
+  }
+
+  // ---------- Parse the KeySets into an array ---------------
+  if (!KeySet.ParseKeySets(argv[1], Force.RowCounter, Force.MatrixCounter)) return 1;
+  if (!KeySet.ParseManyBodyTerms()) return 1;
+
+  // ---------- Parse fragment files created by 'joiner' into an array -------------
+  if (!EnergyFragments.ParseFragmentMatrix(argv[1], dir, EnergyFragmentSuffix,0,0)) return 1;
+  if (!NoHCorrection) 
+    HcorrectionFragments.ParseFragmentMatrix(argv[1], dir, HcorrectionFragmentSuffix,0,0);
+  if (!ForceFragments.ParseFragmentMatrix(argv[1], dir, ForceFragmentSuffix,0,0)) return 1;
+  if (!NoHessian)
+    if (!HessianFragments.ParseFragmentMatrix(argv[1], dir, HessianFragmentSuffix,0,0)) return 1;
+  if (periode != NULL) { // also look for PAS values
+    if (!ShieldingFragments.ParseFragmentMatrix(argv[1], dir, ShieldingFragmentSuffix, 1, 0)) return 1;
+    if (!ShieldingPASFragments.ParseFragmentMatrix(argv[1], dir, ShieldingPASFragmentSuffix, 1, 0)) return 1;
+    if (!ChiFragments.ParseFragmentMatrix(argv[1], dir, ChiFragmentSuffix, 1, 0)) return 1;
+    if (!ChiPASFragments.ParseFragmentMatrix(argv[1], dir, ChiPASFragmentSuffix, 1, 0)) return 1;
+  }
+
+  // +++++++++++++++ TESTING ++++++++++++++++++++++++++++++
+
+  // print energy and forces to file
+  filename.str("");
+  filename << argv[3] << "/" << "energy-forces.all";
+  output.open(filename.str().c_str(), ios::out);
+  output << endl << "Total Energy" << endl << "==============" << endl << Energy.Header[Energy.MatrixCounter] << endl;
+  for(int j=0;j<Energy.RowCounter[Energy.MatrixCounter];j++) {
+    for(int k=0;k<Energy.ColumnCounter[Energy.MatrixCounter];k++)
+      output << scientific << Energy.Matrix[ Energy.MatrixCounter ][j][k] << "\t";
+    output << endl;
+  }
+  output << endl;
+  
+  output << endl << "Total Forces" << endl << "===============" << endl << Force.Header[Force.MatrixCounter] << endl;
+  for(int j=0;j<Force.RowCounter[Force.MatrixCounter];j++) {
+    for(int k=0;k<Force.ColumnCounter[Force.MatrixCounter];k++)
+      output << scientific << Force.Matrix[ Force.MatrixCounter ][j][k] << "\t";
+    output << endl;
+  }
+  output << endl;
+
+  if (!NoHessian) {
+    output << endl << "Total Hessian" << endl << "===============" << endl << Hessian.Header[Hessian.MatrixCounter] << endl;
+    for(int j=0;j<Hessian.RowCounter[Hessian.MatrixCounter];j++) {
+      for(int k=0;k<Hessian.ColumnCounter[Hessian.MatrixCounter];k++)
+        output << scientific << Hessian.Matrix[ Hessian.MatrixCounter ][j][k] << "\t";
+      output << endl;
+    }
+    output << endl;
+  }
+
+  if (periode != NULL) { // also look for PAS values
+    output << endl << "Total Shieldings" << endl << "===============" << endl << Shielding.Header[Hessian.MatrixCounter] << endl;
+    for(int j=0;j<Shielding.RowCounter[Shielding.MatrixCounter];j++) {
+      for(int k=0;k<Shielding.ColumnCounter[Shielding.MatrixCounter];k++)
+        output << scientific << Shielding.Matrix[ Shielding.MatrixCounter ][j][k] << "\t";
+      output << endl;
+    }
+    output << endl;
+  
+    output << endl << "Total Shieldings PAS" << endl << "===============" << endl << ShieldingPAS.Header[ShieldingPAS.MatrixCounter] << endl;
+    for(int j=0;j<ShieldingPAS.RowCounter[ShieldingPAS.MatrixCounter];j++) {
+      for(int k=0;k<ShieldingPAS.ColumnCounter[ShieldingPAS.MatrixCounter];k++)
+        output << scientific << ShieldingPAS.Matrix[ ShieldingPAS.MatrixCounter ][j][k] << "\t";
+      output << endl;
+    }
+    output << endl;
+
+    output << endl << "Total Chis" << endl << "===============" << endl << Chi.Header[Chi.MatrixCounter] << endl;
+    for(int j=0;j<Chi.RowCounter[Chi.MatrixCounter];j++) {
+      for(int k=0;k<Chi.ColumnCounter[Chi.MatrixCounter];k++)
+        output << scientific << Chi.Matrix[ Chi.MatrixCounter ][j][k] << "\t";
+      output << endl;
+    }
+    output << endl;
+  
+    output << endl << "Total Chis PAS" << endl << "===============" << endl << ChiPAS.Header[ChiPAS.MatrixCounter] << endl;
+    for(int j=0;j<ChiPAS.RowCounter[ChiPAS.MatrixCounter];j++) {
+      for(int k=0;k<ChiPAS.ColumnCounter[ChiPAS.MatrixCounter];k++)
+        output << scientific << ChiPAS.Matrix[ ChiPAS.MatrixCounter ][j][k] << "\t";
+      output << endl;
+    }
+    output << endl;
+  }
+  
+  if (!NoTime) {
+    output << endl << "Total Times" << endl << "===============" << endl << Time.Header[Time.MatrixCounter] << endl;
+    for(int j=0;j<Time.RowCounter[Time.MatrixCounter];j++) {
+      for(int k=0;k<Time.ColumnCounter[Time.MatrixCounter];k++) {
+        output << scientific << Time.Matrix[ Time.MatrixCounter ][j][k] << "\t";
+      }
+      output << endl;
+    }
+    output << endl;
+  }
+  output.close();
+  if (!NoTime)
+    for(int k=0;k<Time.ColumnCounter[Time.MatrixCounter];k++)
+      Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k] = Time.Matrix[ Time.MatrixCounter ][Time.RowCounter[Time.MatrixCounter]-1][k];
+
+  // +++++++++++++++ ANALYZING ++++++++++++++++++++++++++++++
+
+  DoLog(0) && (Log() << Verbose(0) << "Analyzing ..." << endl);
+
+  // ======================================= Creating the data files ==============================================================
+
+  // +++++++++++++++++++++++++++++++++++++++ Plotting Simtime vs Bond Order
+  // +++++++++++++++++++++++++++++++++++++++ Plotting Delta Simtime vs Bond Order
+  if (!NoTime) {
+    if (!OpenOutputFile(output, argv[3], "SimTime-Order.dat" )) return false;
+    if (!OpenOutputFile(output2, argv[3], "DeltaSimTime-Order.dat" )) return false;
+    for(int j=Time.RowCounter[Time.MatrixCounter];j--;)
+      for(int k=Time.ColumnCounter[Time.MatrixCounter];k--;) {
+        Time.Matrix[ Time.MatrixCounter ][j][k] = 0.;
+      }
+    counter = 0;
+    output << "#Order\tFrag.No.\t" << Time.Header[Time.MatrixCounter] << endl;
+    output2 << "#Order\tFrag.No.\t" << Time.Header[Time.MatrixCounter] << endl;
+    for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
+      for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;)
+        for(int j=Time.RowCounter[Time.MatrixCounter];j--;)
+          for(int k=Time.ColumnCounter[Time.MatrixCounter];k--;) {
+            Time.Matrix[ Time.MatrixCounter ][j][k] += Time.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k];
+          }
+      counter += KeySet.FragmentsPerOrder[BondOrder];
+      output << BondOrder+1 << "\t" << counter;
+      output2 << BondOrder+1 << "\t" << counter;
+      for(int k=0;k<Time.ColumnCounter[Time.MatrixCounter];k++) {
+        output << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k];
+        if (fabs(Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k]) > MYEPSILON)
+          output2 << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k] / Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k];
+        else
+          output2 << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k];
+      }
+      output << endl;
+      output2 << endl;
+    }
+    output.close();
+    output2.close();
+  }
+
+  if (!NoHessian) {
+    // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in hessian to full QM
+    if (!CreateDataDeltaHessianOrderPerAtom(Hessian, HessianFragments, KeySet, argv[3], "DeltaHessian_xx-Order", "Plot of error between approximated hessian and full hessian versus the Bond Order", datum)) return 1;
+
+    if (!CreateDataDeltaFrobeniusOrderPerAtom(Hessian, HessianFragments, KeySet, argv[3], "DeltaFrobeniusHessian_xx-Order", "Plot of error between approximated hessian and full hessian in the frobenius norm versus the Bond Order", datum)) return 1;
+
+    // ++++++++++++++++++++++++++++++++++++++Plotting Hessian vs. Order
+    if (!CreateDataHessianOrderPerAtom(HessianFragments, KeySet, argv[3], "Hessian_xx-Order", "Plot of approximated hessian versus the Bond Order", datum)) return 1;
+    if (!AppendOutputFile(output, argv[3], "Hessian_xx-Order.dat" )) return false;
+    output << endl << "# Full" << endl;
+    for(int j=0;j<Hessian.RowCounter[Hessian.MatrixCounter];j++) {
+      output << j << "\t";
+      for(int k=0;k<Hessian.ColumnCounter[Force.MatrixCounter];k++)
+        output << scientific <<  Hessian.Matrix[ Hessian.MatrixCounter ][j][k] << "\t";
+      output << endl;
+    }
+    output.close();
+  }
+
+  // +++++++++++++++++++++++++++++++++++++++ Plotting shieldings
+  if (periode != NULL) { // also look for PAS values
+    if (!CreateDataDeltaForcesOrderPerAtom(ShieldingPAS, ShieldingPASFragments, KeySet, argv[3], "DeltaShieldingsPAS-Order", "Plot of error between approximated shieldings and full shieldings versus the Bond Order", datum)) return 1;
+    if (!CreateDataForcesOrderPerAtom(ShieldingPASFragments, KeySet, argv[3], "ShieldingsPAS-Order", "Plot of approximated shieldings versus the Bond Order", datum)) return 1;
+    if (!AppendOutputFile(output, argv[3], "ShieldingsPAS-Order.dat" )) return false;
+    output << endl << "# Full" << endl;
+    for(int j=0;j<ShieldingPAS.RowCounter[ShieldingPAS.MatrixCounter];j++) {
+      output << j << "\t";
+      for(int k=0;k<ShieldingPAS.ColumnCounter[ShieldingPAS.MatrixCounter];k++)
+        output << scientific <<  ShieldingPAS.Matrix[ ShieldingPAS.MatrixCounter ][j][k] << "\t"; //*(((k>1) && (k<6))? 1.e6 : 1.) << "\t";
+      output << endl;
+    }
+    output.close();
+    if (!CreateDataDeltaForcesOrderPerAtom(ChiPAS, ChiPASFragments, KeySet, argv[3], "DeltaChisPAS-Order", "Plot of error between approximated Chis and full Chis versus the Bond Order", datum)) return 1;
+    if (!CreateDataForcesOrderPerAtom(ChiPASFragments, KeySet, argv[3], "ChisPAS-Order", "Plot of approximated Chis versus the Bond Order", datum)) return 1;
+    if (!AppendOutputFile(output, argv[3], "ChisPAS-Order.dat" )) return false;
+    output << endl << "# Full" << endl;
+    for(int j=0;j<ChiPAS.RowCounter[ChiPAS.MatrixCounter];j++) {
+      output << j << "\t";
+      for(int k=0;k<ChiPAS.ColumnCounter[ChiPAS.MatrixCounter];k++)
+        output << scientific <<  ChiPAS.Matrix[ ChiPAS.MatrixCounter ][j][k] << "\t"; //*(((k>1) && (k<6))? 1.e6 : 1.) << "\t";
+      output << endl;
+    }
+    output.close();
+  }
+
+
+  // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in energy to full QM
+  if (!CreateDataDeltaEnergyOrder(Energy, EnergyFragments, KeySet, argv[3], "DeltaEnergies-Order", "Plot of error between approximated and full energies energies versus the Bond Order", datum)) return 1;
+
+  // +++++++++++++++++++++++++++++++++++Plotting Energies vs. Order
+  if (!CreateDataEnergyOrder(EnergyFragments, KeySet, argv[3], "Energies-Order", "Plot of approximated energies versus the Bond Order", datum)) return 1;
+
+  // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in forces to full QM
+  if (!CreateDataDeltaForcesOrderPerAtom(Force, ForceFragments, KeySet, argv[3], "DeltaForces-Order", "Plot of error between approximated forces and full forces versus the Bond Order", datum)) return 1;
+
+  // min force
+  if (!CreateDataDeltaForcesOrder(Force, ForceFragments, KeySet, argv[3], "DeltaMinForces-Order", "Plot of min error between approximated forces and full forces versus the Bond Order", datum, CreateMinimumForce)) return 1;
+
+  // mean force
+  if (!CreateDataDeltaForcesOrder(Force, ForceFragments, KeySet, argv[3], "DeltaMeanForces-Order", "Plot of mean error between approximated forces and full forces versus the Bond Order", datum, CreateMeanForce)) return 1;
+
+  // max force
+  if (!CreateDataDeltaForcesOrder(Force, ForceFragments, KeySet, argv[3], "DeltaMaxForces-Order", "Plot of max error between approximated forces and full forces versus the Bond Order", datum, CreateMaximumForce)) return 1;
+
+  // ++++++++++++++++++++++++++++++++++++++Plotting Forces vs. Order
+  if (!CreateDataForcesOrderPerAtom(ForceFragments, KeySet, argv[3], "Forces-Order", "Plot of approximated forces versus the Bond Order", datum)) return 1;
+  if (!AppendOutputFile(output, argv[3], "Forces-Order.dat" )) return false;
+  output << endl << "# Full" << endl;
+  for(int j=0;j<Force.RowCounter[Force.MatrixCounter];j++) {
+    output << j << "\t";
+    for(int k=0;k<Force.ColumnCounter[Force.MatrixCounter];k++)
+      output << scientific <<  Force.Matrix[ Force.MatrixCounter ][j][k] << "\t";
+    output << endl;
+  }
+  output.close();
+  // min force
+  if (!CreateDataForcesOrder(ForceFragments, KeySet, argv[3], "MinForces-Order", "Plot of min approximated forces versus the Bond Order", datum, CreateMinimumForce)) return 1;
+
+  // mean force
+  if (!CreateDataForcesOrder(ForceFragments, KeySet, argv[3], "MeanForces-Order", "Plot of mean approximated forces versus the Bond Order", datum, CreateMeanForce)) return 1;
+
+  // max force
+  if (!CreateDataForcesOrder(ForceFragments, KeySet, argv[3], "MaxForces-Order", "Plot of max approximated forces versus the Bond Order", datum, CreateMaximumForce)) return 1;
+
+  // ++++++++++++++++++++++++++++++++++++++Plotting vector sum (should be 0) vs. bond order
+  if (!CreateDataForcesOrder(ForceFragments, KeySet, argv[3], "VectorSum-Order", "Plot of vector sum of the approximated forces versus the Bond Order", datum, CreateVectorSumForce)) return 1;
+
+  // +++++++++++++++++++++++++++++++Plotting energyfragments vs. order
+  if (!CreateDataFragment(EnergyFragments, KeySet, argv[3], "Energies-Fragment", "Plot of fragment energy versus the Fragment No", datum, CreateEnergy)) return 1;
+  if (!CreateDataFragment(EnergyFragments, KeySet, argv[3], "Energies-FragmentOrder", "Plot of fragment energy of each Fragment No vs. Bond Order", datum, CreateEnergy)) return 1;
+  if (!CreateDataFragmentOrder(EnergyFragments, KeySet, argv[3], "MaxEnergies-FragmentOrder", "Plot of maximum of fragment energy vs. Bond Order", datum, CreateMaxFragmentOrder)) return 1;
+  if (!CreateDataFragmentOrder(EnergyFragments, KeySet, argv[3], "MinEnergies-FragmentOrder", "Plot of minimum of fragment energy vs. Bond Order", datum, CreateMinFragmentOrder)) return 1;
+
+  // +++++++++++++++++++++++++++++++Ploting min/mean/max forces for each fragment
+  // min force
+  if (!CreateDataFragment(ForceFragments, KeySet, argv[3], "MinForces-Fragment", "Plot of min approximated forces versus the Fragment No", datum, CreateMinimumForce)) return 1;
+
+  // mean force
+  if (!CreateDataFragment(ForceFragments, KeySet, argv[3], "MeanForces-Fragment", "Plot of mean approximated forces versus the Fragment No", datum, CreateMeanForce)) return 1;
+
+  // max force
+  if (!CreateDataFragment(ForceFragments, KeySet, argv[3], "MaxForces-Fragment", "Plot of max approximated forces versus the Fragment No", datum, CreateMaximumForce)) return 1;
+
+  // +++++++++++++++++++++++++++++++Ploting min/mean/max forces for each fragment per order
+  // min force
+  if (!CreateDataFragment(ForceFragments, KeySet, argv[3], "MinForces-FragmentOrder", "Plot of min approximated forces of each Fragment No vs. Bond Order", datum, CreateMinimumForce)) return 1;
+
+  // mean force
+  if (!CreateDataFragment(ForceFragments, KeySet, argv[3], "MeanForces-FragmentOrder", "Plot of mean approximated forces of each Fragment No vs. Bond Order", datum, CreateMeanForce)) return 1;
+
+  // max force
+  if (!CreateDataFragment(ForceFragments, KeySet, argv[3], "MaxForces-FragmentOrder", "Plot of max approximated forces of each Fragment No vs. Bond Order", datum, CreateMaximumForce)) return 1;
+
+  // ======================================= Creating the plot files ==============================================================
+
+  Orderxrange << "[1:" << KeySet.Order << "]";
+  Fragmentxrange << "[0:" << KeySet.FragmentCounter+1 << "]";
+  yrange.str("[1e-8:1e+1]");
+  
+  if (!NoTime) {
+    // +++++++++++++++++++++++++++++++++++++++ Plotting Simtime vs Bond Order
+    if (!CreatePlotOrder(Time, KeySet, argv[3], "SimTime-Order", 1, "below", "y", "",  1, 1, "bond order k", "Evaluation time [s]", Orderxrange.str().c_str(), "", "1" , "with linespoints", EnergyPlotLine)) return 1;
+  }
+  
+  // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in energy to full QM
+  if (!CreatePlotOrder(Energy, KeySet, argv[3], "DeltaEnergies-Order", 1, "outside", "y", "",  1, 1, "bond order k", "absolute error in energy [Ht]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with linespoints", AbsEnergyPlotLine)) return 1;
+
+  // +++++++++++++++++++++++++++++++++++Plotting Energies vs. Order
+  if (!CreatePlotOrder(Energy, KeySet, argv[3], "Energies-Order", 1, "outside", "", "",  1, 1, "bond order k", "approximate energy [Ht]", Orderxrange.str().c_str(), "", "1" , "with linespoints", EnergyPlotLine)) return 1;
+
+  // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in forces to full QM
+  yrange.str("[1e-8:1e+0]");
+  // min force
+  if (!CreatePlotOrder(Force, KeySet, argv[3], "DeltaMinForces-Order", 2, "top right", "y", "",  1, 1, "bond order k", "absolute error in min force [Ht/a.u.]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with linespoints", ForceMagnitudePlotLine)) return 1;
+
+  // mean force
+  if (!CreatePlotOrder(Force, KeySet, argv[3], "DeltaMeanForces-Order", 2, "top right", "y", "",  1, 1, "bond order k", "absolute error in mean force [Ht/a.u.]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with linespoints", AbsFirstForceValuePlotLine)) return 1;
+
+  // max force
+  if (!CreatePlotOrder(Force, KeySet, argv[3], "DeltaMaxForces-Order", 2, "top right", "y", "",  1, 1, "bond order k", "absolute error in max force [Ht/a.u.]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with linespoints", ForceMagnitudePlotLine)) return 1;
+
+  // min/mean/max comparison for total force
+  if(!OpenOutputFile(output, argv[3], "DeltaMinMeanMaxTotalForce-Order.pyx")) return 1;
+  CreatePlotHeader(output, "DeltaMinMeanMaxTotalForce-Order", 1, "bottom left", "y", NULL,  1, 1, "bond order k", "absolute error in total forces [Ht/a.u.]");
+  output << "plot " << Orderxrange.str().c_str() << " [1e-8:1e+0] \\" << endl;
+  output << "'DeltaMinForces-Order.dat' title 'minimum' using 1:(sqrt($" << 8 << "*$" << 8 << "+$" << 8+1 << "*$" << 8+1 << "+$" << 8+2 << "*$" << 8+2 << ")) with linespoints, \\" << endl;
+  output << "'DeltaMeanForces-Order.dat' title 'mean' using 1:(abs($" << 8 << ")) with linespoints, \\" << endl;
+  output << "'DeltaMaxForces-Order.dat' title 'maximum' using 1:(sqrt($" << 8 << "*$" << 8 << "+$" << 8+1 << "*$" << 8+1 << "+$" << 8+2 << "*$" << 8+2 << ")) with linespoints" << endl;
+  output.close();
+
+  // ++++++++++++++++++++++++++++++++++++++Plotting Forces vs. Order
+  // min force
+  if (!CreatePlotOrder(Force, KeySet, argv[3], "MinForces-Order", 2, "bottom right", "y", "",  1, 1, "bond order k", "absolute approximated min force [Ht/a.u.]", Orderxrange.str().c_str(), "", "1" , "with linespoints", ForceMagnitudePlotLine)) return 1;
+
+  // mean force
+  if (!CreatePlotOrder(Force, KeySet, argv[3], "MeanForces-Order", 2, "bottom right", "y", "",  1, 1, "bond order k", "absolute approximated mean force [Ht/a.u.]", Orderxrange.str().c_str(), "", "1" , "with linespoints", AbsFirstForceValuePlotLine)) return 1;
+
+  // max force
+  if (!CreatePlotOrder(Force, KeySet, argv[3], "MaxForces-Order", 2, "bottom right", "y", "",  1, 1, "bond order k", "absolute approximated max force [Ht/a.u.]", Orderxrange.str().c_str(), "", "1" , "with linespoints", ForceMagnitudePlotLine)) return 1;
+
+  // min/mean/max comparison for total force
+  if(!OpenOutputFile(output, argv[3],"MinMeanMaxTotalForce-Order.pyx")) return 1;
+  CreatePlotHeader(output, "MinMeanMaxTotalForce-Order", 1, "bottom left", "y", NULL, 1, 1, "bond order k", "absolute total force [Ht/a.u.]");
+  output << "plot "<< Orderxrange.str().c_str() << " [1e-8:1e+0] \\" << endl;
+  output << "'MinForces-Order.dat' title 'minimum' using 1:(sqrt($" << 8 << "*$" << 8 << "+$" << 8+1 << "*$" << 8+1 << "+$" << 8+2 << "*$" << 8+2 << ")) with linespoints, \\" << endl;
+  output << "'MeanForces-Order.dat' title 'mean' using 1:(abs($" << 8 << ")) with linespoints, \\" << endl;
+  output << "'MaxForces-Order.dat' title 'maximum' using 1:(sqrt($" << 8 << "*$" << 8 << "+$" << 8+1 << "*$" << 8+1 << "+$" << 8+2 << "*$" << 8+2 << ")) with linespoints" << endl;
+  output.close();
+
+  // ++++++++++++++++++++++++++++++++++++++Plotting vector sum vs. Order
+
+  if (!CreatePlotOrder(Force, KeySet, argv[3], "VectorSum-Order", 2, "bottom right", "y" ,"", 1, 1, "bond order k", "vector sum of approximated forces [Ht/a.u.]", Orderxrange.str().c_str(), "", "1" , "with linespoints", ForceMagnitudePlotLine)) return 1;
+
+  // +++++++++++++++++++++++++++++++Plotting energyfragments vs. order
+  yrange.str("");
+  yrange << "[" << EnergyFragments.FindMinValue() << ":" << EnergyFragments.FindMaxValue() << "]";
+  if (!CreatePlotOrder(EnergyFragments, KeySet, argv[3], "Energies-Fragment", 5, "below", "y", "", 1, 5, "fragment number", "Energies of each fragment [Ht]", Fragmentxrange.str().c_str(), yrange.str().c_str(), "2" , "with points", AbsEnergyPlotLine)) return 1;
+  if (!CreatePlotOrder(EnergyFragments, KeySet, argv[3], "Energies-FragmentOrder", 5, "below", "y", "", 1, 1, "bond order", "Energies of each fragment [Ht]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with points", AbsEnergyPlotLine)) return 1;
+  if (!CreatePlotOrder(EnergyFragments, KeySet, argv[3], "MaxEnergies-FragmentOrder", 5, "below", "y", "", 1, 1, "bond order", "Maximum fragment energy [Ht]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with linespoints", AbsEnergyPlotLine)) return 1;
+  if (!CreatePlotOrder(EnergyFragments, KeySet, argv[3], "MinEnergies-FragmentOrder", 5, "below", "y", "", 1, 1, "bond order", "Minimum fragment energy [Ht]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with linespoints", AbsEnergyPlotLine)) return 1;
+
+  // +++++++++++++++++++++++++++++++=Ploting min/mean/max forces for each fragment
+  yrange.str("");
+  yrange << "[" << ForceFragments.FindMinValue() << ":" << ForceFragments.FindMaxValue()<< "]";
+  // min
+  if (!CreatePlotOrder(ForceFragments, KeySet, argv[3], "MinForces-Fragment", 5, "below", "y", "set boxwidth 0.2", 1, 5, "fragment number", "minimum of approximated forces [Ht/a.u.]", Fragmentxrange.str().c_str(), yrange.str().c_str(), "2" , "with boxes fillcolor", BoxesForcePlotLine)) return 1;
+
+  // mean
+  if (!CreatePlotOrder(ForceFragments, KeySet, argv[3], "MeanForces-Fragment", 5, "below", "y", "set boxwidth 0.2", 1, 5, "fragment number", "mean of approximated forces [Ht/a.u.]", Fragmentxrange.str().c_str(), yrange.str().c_str(), "2" , "with boxes fillcolor", BoxesFirstForceValuePlotLine)) return 1;
+
+  // max
+  if (!CreatePlotOrder(ForceFragments, KeySet, argv[3], "MaxForces-Fragment", 5, "below", "y", "set boxwidth 0.2", 1, 5, "fragment number", "maximum of approximated forces [Ht/a.u.]", Fragmentxrange.str().c_str(), yrange.str().c_str(), "2" , "with boxes fillcolor", BoxesForcePlotLine)) return 1;
+
+  // +++++++++++++++++++++++++++++++=Ploting min/mean/max forces for each fragment per bond order
+  // min
+  if (!CreatePlotOrder(ForceFragments, KeySet, argv[3], "MinForces-FragmentOrder", 5, "below", "y", "set boxwidth 0.2", 1, 1, "bond order", "minimum of approximated forces [Ht/a.u.]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with boxes fillcolor", BoxesForcePlotLine)) return 1;
+
+  // mean
+  if (!CreatePlotOrder(ForceFragments, KeySet, argv[3], "MeanForces-FragmentOrder", 5, "below", "y", "set boxwidth 0.2", 1, 1, "bond order", "mean of approximated forces [Ht/a.u.]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with boxes fillcolor", BoxesFirstForceValuePlotLine)) return 1;
+
+  // max
+  if (!CreatePlotOrder(ForceFragments, KeySet, argv[3], "MaxForces-FragmentOrder", 5, "below", "y", "set boxwidth 0.2", 1, 1, "bond order", "maximum of approximated forces [Ht/a.u.]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with boxes fillcolor", BoxesForcePlotLine)) return 1;
+
+  // +++++++++++++++++++++++++++++++=Ploting approximated and true shielding for each atom
+  if (periode != NULL) { // also look for PAS values
+    if(!OpenOutputFile(output, argv[3], "ShieldingsPAS-Order.pyx")) return 1;
+    if(!OpenOutputFile(output2, argv[3], "DeltaShieldingsPAS-Order.pyx")) return 1;
+    CreatePlotHeader(output, "ShieldingsPAS-Order", 1, "top right", NULL, NULL,  1, 5, "nuclei index", "iso chemical shielding value [ppm]");
+    CreatePlotHeader(output2, "DeltaShieldingsPAS-Order", 1, "top right", NULL, NULL,  1, 5, "nuclei index", "iso chemical shielding value [ppm]");
+    double step=0.8/KeySet.Order;
+    output << "set boxwidth " << step << endl;
+    output << "plot [0:" << ShieldingPAS.RowCounter[ShieldingPAS.MatrixCounter]+10 << "]\\" << endl;
+    output2 << "plot [0:" << ShieldingPAS.RowCounter[ShieldingPAS.MatrixCounter]+10 << "]\\" << endl;
+    for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
+      output << "'ShieldingsPAS-Order.dat' index " << BondOrder << " title 'Order " << BondOrder+1 << "' using ($1+" << step*(double)BondOrder << "):7 with boxes, \\" << endl;
+      output2 << "'DeltaShieldingsPAS-Order.dat' index " << BondOrder << " title 'Order " << BondOrder+1 << "' using ($1):7 with linespoints";
+      if (BondOrder-1 != KeySet.Order)
+        output2 << ", \\" << endl;
+    }
+    output << "'ShieldingsPAS-Order.dat' index " << KeySet.Order << " title 'Full' using ($1+" << step*(double)KeySet.Order << "):7 with boxes" << endl;
+    output2.close();  
+
+    if(!OpenOutputFile(output, argv[3], "ChisPAS-Order.pyx")) return 1;
+    if(!OpenOutputFile(output2, argv[3], "DeltaChisPAS-Order.pyx")) return 1;
+    CreatePlotHeader(output, "ChisPAS-Order", 1, "top right", NULL, NULL,  1, 5, "nuclei index", "iso chemical Chi value [ppm]");
+    CreatePlotHeader(output2, "DeltaChisPAS-Order", 1, "top right", NULL, NULL,  1, 5, "nuclei index", "iso chemical Chi value [ppm]");
+    output << "set boxwidth " << step << endl;
+    output << "plot [0:" << ChiPAS.RowCounter[ChiPAS.MatrixCounter]+10 << "]\\" << endl;
+    output2 << "plot [0:" << ChiPAS.RowCounter[ChiPAS.MatrixCounter]+10 << "]\\" << endl;
+    for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
+      output << "'ChisPAS-Order.dat' index " << BondOrder << " title 'Order " << BondOrder+1 << "' using ($1+" << step*(double)BondOrder << "):7 with boxes, \\" << endl;
+      output2 << "'DeltaChisPAS-Order.dat' index " << BondOrder << " title 'Order " << BondOrder+1 << "' using ($1):7 with linespoints";
+      if (BondOrder-1 != KeySet.Order)
+        output2 << ", \\" << endl;
+    }
+    output << "'ChisPAS-Order.dat' index " << KeySet.Order << " title 'Full' using ($1+" << step*(double)KeySet.Order << "):7 with boxes" << endl;
+    output.close();  
+    output2.close();  
+
+    if(!OpenOutputFile(output, argv[3], "ChisPAS-Order.pyx")) return 1;
+    if(!OpenOutputFile(output2, argv[3], "DeltaChisPAS-Order.pyx")) return 1;
+    CreatePlotHeader(output, "ChisPAS-Order", 1, "top right", NULL, NULL,  1, 5, "nuclei index", "iso chemical Chi value [ppm]");
+    CreatePlotHeader(output2, "DeltaChisPAS-Order", 1, "top right", NULL, NULL,  1, 5, "nuclei index", "iso chemical Chi value [ppm]");
+    output << "set boxwidth " << step << endl;
+    output << "plot [0:" << ChiPAS.RowCounter[ChiPAS.MatrixCounter]+10 << "]\\" << endl;
+    output2 << "plot [0:" << ChiPAS.RowCounter[ChiPAS.MatrixCounter]+10 << "]\\" << endl;
+    for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
+      output << "'ChisPAS-Order.dat' index " << BondOrder << " title 'Order " << BondOrder+1 << "' using ($1+" << step*(double)BondOrder << "):7 with boxes, \\" << endl;
+      output2 << "'DeltaChisPAS-Order.dat' index " << BondOrder << " title 'Order " << BondOrder+1 << "' using ($1):7 with linespoints";
+      if (BondOrder-1 != KeySet.Order)
+        output2 << ", \\" << endl;
+    }
+    output << "'ChisPAS-Order.dat' index " << KeySet.Order << " title 'Full' using ($1+" << step*(double)KeySet.Order << "):7 with boxes" << endl;
+    output.close();  
+    output2.close();  
+  }
+
+  // create Makefile
+  if(!OpenOutputFile(output, argv[3], "Makefile")) return 1;
+  output << "PYX = $(shell ls *.pyx)" << endl << endl;
+  output << "EPS = $(PYX:.pyx=.eps)" << endl << endl;
+  output << "%.eps: %.pyx" << endl;
+  output << "\t~/build/pyxplot/pyxplot $<" << endl << endl;
+  output << "all: $(EPS)" << endl << endl;
+  output << ".PHONY: clean" << endl;
+  output << "clean:" << endl;
+  output << "\trm -rf $(EPS)" << endl;
+  output.close();
+
+  // ++++++++++++++++ exit ++++++++++++++++++++++++++++++++++
+  delete(periode);
+  delete[](dir);
+  DoLog(0) && (Log() << Verbose(0) << "done." << endl);
+  return 0;
+};
+
+//============================ END ===========================
Index: src/atom.cpp
===================================================================
--- src/atom.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/atom.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,348 @@
+/** \file atom.cpp
+ *
+ * Function implementations for the class atom.
+ *
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "atom.hpp"
+#include "bond.hpp"
+#include "config.hpp"
+#include "element.hpp"
+#include "lists.hpp"
+#include "memoryallocator.hpp"
+#include "parser.hpp"
+#include "vector.hpp"
+#include "World.hpp"
+#include "molecule.hpp"
+
+/************************************* Functions for class atom *************************************/
+
+
+/** Constructor of class atom.
+ */
+atom::atom() :
+  father(this), sort(&nr), mol(0)
+{
+  node = &x;  // TesselPoint::x can only be referenced from here
+};
+
+/** 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
+  FixedIon = pointer->FixedIon;
+  node = &x;
+  mol = 0;
+};
+
+atom *atom::clone(){
+  atom *res = new atom(this);
+  res->father = this;
+  res->sort = &res->nr;
+  res->type = type;
+  res->x = this->x;
+  res->v = this->v;
+  res->FixedIon = FixedIon;
+  res->node = &x;
+  res->mol = 0;
+  World::getInstance().registerAtom(res);
+  return res;
+}
+
+
+/** Destructor of class atom.
+ */
+atom::~atom()
+{
+  removeFromMolecule();
+  for(BondList::iterator iter=ListOfBonds.begin(); iter!=ListOfBonds.end();){
+    // deleting the bond will invalidate the iterator !!!
+    bond *bond =*(iter++);
+    delete(bond);
+  }
+};
+
+
+/** Climbs up the father list until NULL, last is returned.
+ * \return true father, i.e. whose father points to itself, NULL if it could not be found or has none (added hydrogen)
+ */
+atom *atom::GetTrueFather()
+{
+  if(father == this){ // top most father is the one that points on itself
+    return this;
+  }
+  else if(!father) {
+    return 0;
+  }
+  else {
+    return father->GetTrueFather();
+  }
+};
+
+/** Sets father to itself or its father in case of copying a molecule.
+ */
+void atom::CorrectFather()
+{
+  if (father->father == father)   // same atom in copy's father points to itself
+    father = this;  // set father to itself (copy of a whole molecule)
+  else
+   father = father->father;  // set father to original's father
+
+};
+
+/** Check whether father is equal to given atom.
+ * \param *ptr atom to compare father to
+ * \param **res return value (only set if atom::father is equal to \a *ptr)
+ */
+void atom::EqualsFather ( const atom *ptr, const atom **res ) const
+{
+  if ( ptr == father )
+    *res = this;
+};
+
+/** Checks whether atom is within the given box.
+ * \param offset offset to box origin
+ * \param *parallelepiped box matrix
+ * \return true - is inside, false - is not
+ */
+bool atom::IsInParallelepiped(const Vector offset, const double *parallelepiped) const
+{
+  return (node->IsInParallelepiped(offset, parallelepiped));
+};
+
+/** Counts the number of bonds weighted by bond::BondDegree.
+ * \param bonds times bond::BondDegree
+ */
+int BondedParticle::CountBonds() const
+{
+  int NoBonds = 0;
+  for (BondList::const_iterator Runner = ListOfBonds.begin(); Runner != ListOfBonds.end(); (++Runner))
+    NoBonds += (*Runner)->BondDegree;
+  return NoBonds;
+};
+
+/** Output of a single atom with given numbering.
+ * \param ElementNo cardinal number of the element
+ * \param AtomNo cardinal number among these atoms of the same element
+ * \param *out stream to output to
+ * \param *comment commentary after '#' sign
+  * \return true - \a *out present, false - \a *out is NULL
+ */
+bool atom::OutputIndexed(ofstream * const out, const int ElementNo, const int AtomNo, const char *comment) const
+{
+  if (out != NULL) {
+    *out << "Ion_Type" << ElementNo << "_" << AtomNo << "\t"  << fixed << setprecision(9) << showpoint;
+    *out << x[0] << "\t" << x[1] << "\t" << x[2];
+    *out << "\t" << FixedIon;
+    if (v.Norm() > MYEPSILON)
+      *out << "\t" << scientific << setprecision(6) << v[0] << "\t" << v[1] << "\t" << v[2] << "\t";
+    if (comment != NULL)
+      *out << " # " << comment << endl;
+    else
+      *out << " # molecule nr " << nr << endl;
+    return true;
+  } else
+    return false;
+};
+
+/** Output of a single atom with numbering from array according to atom::type.
+ * \param *ElementNo cardinal number of the element
+ * \param *AtomNo cardinal number among these atoms of the same element
+ * \param *out stream to output to
+ * \param *comment commentary after '#' sign
+  * \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];
+    *out << "\t" << FixedIon;
+    if (v.Norm() > MYEPSILON)
+      *out << "\t" << scientific << setprecision(6) << v[0] << "\t" << v[1] << "\t" << v[2] << "\t";
+    if (comment != NULL)
+      *out << " # " << comment << endl;
+    else
+      *out << " # molecule nr " << nr << endl;
+    return true;
+  } else
+    return false;
+};
+
+/** Output of a single atom as one lin in xyz file.
+ * \param *out stream to output to
+  * \return true - \a *out present, false - \a *out is NULL
+ */
+bool atom::OutputXYZLine(ofstream *out) const
+{
+  if (out != NULL) {
+    *out << type->symbol << "\t" << x[0] << "\t" << x[1] << "\t" << x[2] << "\t" << endl;
+    return true;
+  } else
+    return false;
+};
+
+/** Output of a single atom as one lin in xyz file.
+ * \param *out stream to output to
+ * \param *ElementNo array with ion type number in the config file this atom's element shall have
+ * \param *AtomNo array with atom number in the config file this atom shall have, is increase by one automatically
+ * \param step Trajectory time step to output
+  * \return true - \a *out present, false - \a *out is NULL
+ */
+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;
+    *out << Trajectory.R.at(step)[0] << "\t" << Trajectory.R.at(step)[1] << "\t" << Trajectory.R.at(step)[2];
+    *out << "\t" << FixedIon;
+    if (Trajectory.U.at(step).Norm() > MYEPSILON)
+      *out << "\t" << scientific << setprecision(6) << Trajectory.U.at(step)[0] << "\t" << Trajectory.U.at(step)[1] << "\t" << Trajectory.U.at(step)[2] << "\t";
+    if (Trajectory.F.at(step).Norm() > MYEPSILON)
+      *out << "\t" << scientific << setprecision(6) << Trajectory.F.at(step)[0] << "\t" << Trajectory.F.at(step)[1] << "\t" << Trajectory.F.at(step)[2] << "\t";
+    *out << "\t# Number in molecule " << nr << endl;
+    return true;
+  } else
+    return false;
+};
+
+/** Output of a single atom as one lin in xyz file.
+ * \param *out stream to output to
+ * \param step Trajectory time step to output
+ * \return true - \a *out present, false - \a *out is NULL
+ */
+bool atom::OutputTrajectoryXYZ(ofstream * const out, const int step) const
+{
+  if (out != NULL) {
+    *out << type->symbol << "\t";
+    *out << Trajectory.R.at(step)[0] << "\t";
+    *out << Trajectory.R.at(step)[1] << "\t";
+    *out << Trajectory.R.at(step)[2] << endl;
+    return true;
+  } else
+    return false;
+};
+
+/** Outputs the MPQC configuration line for this atom.
+ * \param *out output stream
+ * \param *center center of molecule subtracted from position
+ * \param *AtomNo pointer to atom counter that is increased by one
+ */
+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;
+  if (AtomNo != NULL)
+    *AtomNo++;
+};
+
+/** Compares the indices of \a this atom with a given \a ptr.
+ * \param ptr atom to compare index against
+ * \return true - this one's is smaller, false - not
+ */
+bool atom::Compare(const atom &ptr) const
+{
+  if (nr < ptr.nr)
+    return true;
+  else
+    return false;
+};
+
+/** Returns squared distance to a given vector.
+ * \param origin vector to calculate distance to
+ * \return distance squared
+ */
+double atom::DistanceSquaredToVector(const Vector &origin) const
+{
+  return origin.DistanceSquared(x);
+};
+
+/** Returns distance to a given vector.
+ * \param origin vector to calculate distance to
+ * \return distance
+ */
+double atom::DistanceToVector(const Vector &origin) const
+{
+  return origin.distance(x);
+};
+
+/** Initialises the component number array.
+ * Size is set to atom::ListOfBonds.size()+1 (last is th encode end by -1)
+ */
+void atom::InitComponentNr()
+{
+  if (ComponentNr != NULL)
+    delete[](ComponentNr);
+  ComponentNr = new int[ListOfBonds.size()+1];
+  for (int i=ListOfBonds.size()+1;i--;)
+    ComponentNr[i] = -1;
+};
+
+
+bool operator < (atom &a, atom &b)
+{
+  return a.Compare(b);
+};
+
+World *atom::getWorld(){
+  return world;
+}
+
+void atom::setWorld(World* _world){
+  world = _world;
+}
+
+bool atom::changeId(atomId_t newId){
+  // first we move ourselves in the world
+  // the world lets us know if that succeeded
+  if(world->changeAtomId(id,newId,this)){
+    id = newId;
+    return true;
+  }
+  else{
+    return false;
+  }
+}
+
+void atom::setId(atomId_t _id) {
+  id=_id;
+}
+
+atomId_t atom::getId() const {
+  return id;
+}
+
+void atom::setMolecule(molecule *_mol){
+  // take this atom from the old molecule
+  removeFromMolecule();
+  mol = _mol;
+  if(!mol->containsAtom(this)){
+    mol->AddAtom(this);
+  }
+}
+
+void atom::removeFromMolecule(){
+  if(mol){
+    if(mol->containsAtom(this)){
+      mol->erase(this);
+    }
+    mol=0;
+  }
+}
+
+
+atom* NewAtom(atomId_t _id){
+  atom * res =new atom();
+  res->setId(_id);
+  return res;
+}
+
+void DeleteAtom(atom* atom){
+  delete atom;
+}
Index: src/atom.hpp
===================================================================
--- src/atom.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/atom.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,133 @@
+/*
+ * atom.hpp
+ *
+ *  Created on: Aug 3, 2009
+ *      Author: heber
+ */
+
+#ifndef ATOM_HPP_
+#define ATOM_HPP_
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <iostream>
+#include <list>
+#include <vector>
+
+#include "atom_atominfo.hpp"
+#include "atom_bondedparticle.hpp"
+#include "atom_graphnode.hpp"
+#include "atom_particleinfo.hpp"
+#include "atom_trajectoryparticle.hpp"
+#include "tesselation.hpp"
+#include "types.hpp"
+
+/****************************************** forward declarations *****************************/
+
+class Vector;
+class World;
+class molecule;
+
+/********************************************** declarations *******************************/
+
+/** Single atom.
+ * Class incorporates position, type
+ */
+class atom : public TesselPoint, public TrajectoryParticle, public GraphNode, public BondedParticle, public virtual ParticleInfo, public virtual AtomInfo {
+  friend atom* NewAtom(atomId_t);
+  friend void  DeleteAtom(atom*);
+  public:
+    atom *father;   //!< In many-body bond order fragmentations points to originating atom
+    int *sort;      //!< sort criteria
+
+  virtual atom *clone();
+
+  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 OutputXYZLine(ofstream *out) const;
+  bool OutputTrajectory(ofstream * const out, const int *ElementNo, int *AtomNo, const int step) const;
+  bool OutputTrajectoryXYZ(ofstream * const out, const int step) const;
+  void OutputMPQCLine(ostream * const out, const Vector *center, int *AtomNo) const;
+
+  void InitComponentNr();
+
+  void EqualsFather ( const atom *ptr, const atom **res ) const;
+  void CorrectFather();
+  atom *GetTrueFather();
+  bool Compare(const atom &ptr) const;
+
+  double DistanceToVector(const Vector &origin) const;
+  double DistanceSquaredToVector(const Vector &origin) const;
+  bool IsInParallelepiped(const Vector offset, const double *parallelepiped) const;
+
+  // getter and setter
+
+  /**
+   * returns the World that contains this atom.
+   * Use this if you need to get the world without locking
+   * the singleton for example.
+   *
+   */
+  World *getWorld();
+  void setWorld(World*);
+
+  virtual atomId_t getId() const;
+  virtual bool changeId(atomId_t newId);
+
+  /**
+   * this function sets the Id without notifying the world. Only use it, if the world has already
+   * gotten an ID for this Atom.
+   */
+   virtual void setId(atomId_t);
+
+   void setMolecule(molecule*);
+   void removeFromMolecule();
+
+  protected:
+
+    /**
+     * Protected constructor to ensure construction of atoms through the world.
+     * see World::createAtom()
+     */
+    atom();
+
+    /**
+     * Protected copy-constructor to ensure construction of atoms by cloning.
+     * see atom::clone()
+     */
+    atom(class atom *pointer);
+
+    /**
+     * Protected destructor to ensure destruction of atoms through the world.
+     * see World::destroyAtom()
+     */
+    virtual ~atom();
+  private:
+    molecule *mol; // !< the molecule this atom belongs to
+    World* world;
+    atomId_t id;
+};
+
+/**
+ * internal method used by the world. Do not use if you don't know what you are doing.
+ * You might get burned...
+ * Use World::createAtom() instead.
+ */
+atom* NewAtom(atomId_t _id);
+
+/**
+* internal method used by the world. Do not use if you don't know what you are doing.
+ * You might get burned...
+ * Use World::destroyAtom() instead.
+ */
+void  DeleteAtom(atom*);
+
+
+#endif /* ATOM_HPP_ */
Index: src/atom_atominfo.cpp
===================================================================
--- src/atom_atominfo.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/atom_atominfo.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,35 @@
+/*
+ * atom_atominfo.cpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "periodentafel.hpp"
+#include "World.hpp"
+#include "atom_atominfo.hpp"
+
+/** Constructor of class AtomInfo.
+ */
+AtomInfo::AtomInfo() : type(NULL) {};
+
+/** Destructor of class AtomInfo.
+ */
+AtomInfo::~AtomInfo()
+{
+};
+
+const element *AtomInfo::getType(){
+  return type;
+}
+
+void AtomInfo::setType(const element* _type) {
+  type = _type;
+}
+
+void AtomInfo::setType(int Z) {
+  const element *elem = World::getInstance().getPeriode()->FindElement(Z);
+  setType(elem);
+}
Index: src/atom_atominfo.hpp
===================================================================
--- src/atom_atominfo.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/atom_atominfo.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,46 @@
+/*
+ * atom_atominfo.hpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: heber
+ */
+
+#ifndef ATOM_ATOMINFO_HPP_
+#define ATOM_ATOMINFO_HPP_
+
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "vector.hpp"
+
+/****************************************** forward declarations *****************************/
+
+class element;
+
+/********************************************** declarations *******************************/
+
+class AtomInfo {
+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
+
+  AtomInfo();
+  ~AtomInfo();
+
+  const element *getType();
+  void setType(const element *);
+  void setType(int);
+
+private:
+};
+
+#endif /* ATOM_ATOMINFO_HPP_ */
Index: src/atom_bondedparticle.cpp
===================================================================
--- src/atom_bondedparticle.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/atom_bondedparticle.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,190 @@
+/*
+ * atom_bondedparticle.cpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "atom.hpp"
+#include "atom_bondedparticle.hpp"
+#include "bond.hpp"
+#include "element.hpp"
+#include "lists.hpp"
+#include "log.hpp"
+#include "verbose.hpp"
+
+/** Constructor of class BondedParticle.
+ */
+BondedParticle::BondedParticle()
+{
+};
+
+/** Destructor of class BondedParticle.
+ */
+BondedParticle::~BondedParticle()
+{
+  BondList::const_iterator Runner;
+  while (!ListOfBonds.empty()) {
+    Runner = ListOfBonds.begin();
+    removewithoutcheck(*Runner);
+  }
+};
+
+/** Outputs the current atom::AdaptiveOrder and atom::MaxOrder to \a *file.
+ * \param *file output stream
+ */
+void BondedParticle::OutputOrder(ofstream *file) const
+{
+  *file << nr << "\t" << (int)AdaptiveOrder << "\t" << (int)MaxOrder << endl;
+  //Log() << Verbose(2) << "Storing: " << nr << "\t" << (int)AdaptiveOrder << "\t" << (int)MaxOrder << "." << endl;
+};
+
+/** Prints all bonds of this atom with total degree.
+ */
+void BondedParticle::OutputBondOfAtom() const
+{
+  DoLog(4) && (Log() << Verbose(4) << "Atom " << getName() << "/" << nr << " with " << ListOfBonds.size() << " bonds: " << endl);
+  int TotalDegree = 0;
+  for (BondList::const_iterator Runner = ListOfBonds.begin(); Runner != ListOfBonds.end(); ++Runner) {
+    DoLog(4) && (Log() << Verbose(4) << **Runner << endl);
+    TotalDegree += (*Runner)->BondDegree;
+  }
+  DoLog(4) && (Log() << Verbose(4) << " -- TotalDegree: " << TotalDegree << endl);
+};
+
+/** Output of atom::nr along with all bond partners.
+ * \param *AdjacencyFile output stream
+ */
+void BondedParticle::OutputAdjacency(ofstream * const AdjacencyFile) const
+{
+  *AdjacencyFile << nr << "\t";
+  for (BondList::const_iterator Runner = ListOfBonds.begin(); Runner != ListOfBonds.end(); (++Runner))
+    *AdjacencyFile << (*Runner)->GetOtherAtom(this)->nr << "\t";
+  *AdjacencyFile << endl;
+};
+
+/** Output of atom::nr along each bond partner per line.
+ * Only bonds are printed where atom::nr is smaller than the one of the bond partner.
+ * \param *AdjacencyFile output stream
+ */
+void BondedParticle::OutputBonds(ofstream * const BondFile) const
+{
+  for (BondList::const_iterator Runner = ListOfBonds.begin(); Runner != ListOfBonds.end(); (++Runner))
+    if (nr < (*Runner)->GetOtherAtom(this)->nr)
+      *BondFile << nr << "\t" << (*Runner)->GetOtherAtom(this)->nr << "\n";
+};
+
+/**
+ * Adds a bond between this bonded particle and another. Does nothing if this
+ * bond already exists.
+ *
+ * \param bonding partner
+ */
+void BondedParticle::addBond(BondedParticle* Partner) {
+  if (IsBondedTo(Partner)) {
+    return;
+  }
+
+  bond* newBond = new bond((atom*) this, (atom*) Partner, 1, 0);
+  RegisterBond(newBond);
+  Partner->RegisterBond(newBond);
+}
+
+/** Puts a given bond into atom::ListOfBonds.
+ * \param *Binder bond to insert
+ */
+bool BondedParticle::RegisterBond(bond *Binder)
+{
+  bool status = false;
+  if (Binder != NULL) {
+    if (Binder->Contains(this)) {
+      ListOfBonds.push_back(Binder);
+      status = true;
+    } else {
+      DoeLog(1) && (eLog()<< Verbose(1) << *Binder << " does not contain " << *this << "." << endl);
+    }
+  } else {
+    DoeLog(1) && (eLog()<< Verbose(1) << "Binder is " << Binder << "." << endl);
+  }
+  return status;
+};
+
+/** Removes a given bond from atom::ListOfBonds.
+ * \param *Binder bond to remove
+ */
+bool BondedParticle::UnregisterBond(bond *Binder)
+{
+  bool status = false;
+  if (Binder != NULL) {
+    if (Binder->Contains(this)) {
+      ListOfBonds.remove(Binder);
+      status = true;
+    } else {
+      DoeLog(1) && (eLog()<< Verbose(1) << *Binder << " does not contain " << *this << "." << endl);
+    }
+  } else {
+    DoeLog(1) && (eLog()<< Verbose(1) << "Binder is " << Binder << "." << endl);
+  }
+  return status;
+};
+
+/** Removes all bonds from atom::ListOfBonds.
+ * \note Does not do any memory de-allocation.
+ */
+void BondedParticle::UnregisterAllBond()
+{
+  ListOfBonds.clear();
+};
+
+/** Corrects the bond degree by one at most if necessary.
+ * \param *out output stream for debugging
+ */
+int BondedParticle::CorrectBondDegree()
+{
+  int NoBonds = 0;
+  int OtherNoBonds = 0;
+  int FalseBondDegree = 0;
+  atom *OtherWalker = NULL;
+  bond *CandidateBond = NULL;
+
+  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
+    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 ((CandidateBond == NULL) || (ListOfBonds.size() > OtherWalker->ListOfBonds.size())) { // pick the one with fewer number of bonds first
+          CandidateBond = (*Runner);
+          //Log() << Verbose(3) << "New candidate is " << *CandidateBond << "." << endl;
+        }
+      }
+    }
+    if ((CandidateBond != NULL)) {
+      CandidateBond->BondDegree++;
+      //Log() << Verbose(2) << "Increased bond degree for bond " << *CandidateBond << "." << endl;
+    } else {
+      DoeLog(2) && (eLog()<< Verbose(2) << "Could not find correct degree for atom " << *this << "." << endl);
+      FalseBondDegree++;
+    }
+  }
+  return FalseBondDegree;
+};
+
+/** Checks whether there is a bond between \a this atom and the given \a *BondPartner.
+ * \param *BondPartner atom to check for
+ * \return true - bond exists, false - bond does not exist
+ */
+bool BondedParticle::IsBondedTo(BondedParticle * const BondPartner)
+{
+  bool status = false;
+
+  for (BondList::iterator runner = ListOfBonds.begin(); runner != ListOfBonds.end(); runner++) {
+    status = status || ((*runner)->Contains(BondPartner));
+  }
+  return status;
+};
+
Index: src/atom_bondedparticle.hpp
===================================================================
--- src/atom_bondedparticle.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/atom_bondedparticle.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,56 @@
+/*
+ * atom_bondedparticle.hpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: heber
+ */
+
+#ifndef ATOM_BONDEDPARTICLE_HPP_
+#define ATOM_BONDEDPARTICLE_HPP_
+
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <fstream>
+#include <list>
+
+#include "atom_atominfo.hpp"
+#include "atom_bondedparticleinfo.hpp"
+#include "atom_particleinfo.hpp"
+
+/****************************************** forward declarations *****************************/
+
+class bond;
+
+/********************************************** declarations *******************************/
+
+class BondedParticle : public BondedParticleInfo, public virtual ParticleInfo, public virtual AtomInfo {
+public:
+  BondedParticle();
+  virtual ~BondedParticle();
+
+  void addBond(BondedParticle* Partner);
+  bool RegisterBond(bond *Binder);
+  bool UnregisterBond(bond *Binder);
+  bool IsBondedTo(BondedParticle * const BondPartner);
+  void UnregisterAllBond();
+  int CountBonds() const;
+  int CorrectBondDegree();
+  void OutputBondOfAtom() const;
+  void OutputAdjacency(ofstream * const AdjacencyFile) const;
+  void OutputBonds(ofstream * const BondFile) const;
+  void OutputOrder(ofstream *file) const;
+
+private:
+
+};
+
+
+#endif /* ATOM_BONDEDPARTICLE_HPP_ */
Index: src/atom_bondedparticleinfo.cpp
===================================================================
--- src/atom_bondedparticleinfo.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/atom_bondedparticleinfo.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,21 @@
+/*
+ * atom_bondedparticleinfo.cpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "atom_bondedparticleinfo.hpp"
+
+/** Constructor of class BondedParticleInfo.
+ */
+BondedParticleInfo::BondedParticleInfo() : AdaptiveOrder(0), MaxOrder(false) {};
+
+/** Destructor of class BondedParticleInfo.
+ */
+BondedParticleInfo::~BondedParticleInfo()
+{
+};
+
Index: src/atom_bondedparticleinfo.hpp
===================================================================
--- src/atom_bondedparticleinfo.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/atom_bondedparticleinfo.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,45 @@
+/*
+ * atom_bondedparticleinfo.hpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: heber
+ */
+
+#ifndef ATOM_BONDEDPARTICLEINFO_HPP_
+#define ATOM_BONDEDPARTICLEINFO_HPP_
+
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <list>
+
+/****************************************** forward declarations *****************************/
+
+class bond;
+
+#define BondList list<bond *>
+
+/********************************************** declarations *******************************/
+
+class BondedParticleInfo {
+public:
+  unsigned char AdaptiveOrder;  //!< current present bond order at site (0 means "not set")
+  bool MaxOrder;  //!< whether this atom as a root in fragmentation still creates more fragments on higher orders or not
+  BondList ListOfBonds; //!< list of all bonds
+
+  BondedParticleInfo();
+  ~BondedParticleInfo();
+
+private:
+
+};
+
+
+#endif /* ATOM_BONDEDPARTICLEINFO_HPP_ */
Index: src/atom_graphnode.cpp
===================================================================
--- src/atom_graphnode.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/atom_graphnode.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,47 @@
+/*
+ * atom_graphnode.cpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "atom_graphnode.hpp"
+#include "log.hpp"
+#include "verbose.hpp"
+
+/** Constructor of class GraphNode.
+ */
+GraphNode::GraphNode()
+{
+};
+
+/** Destructor of class GraphNode.
+ */
+GraphNode::~GraphNode()
+{
+};
+
+/** Output graph info of this atom.
+ * \param *out output stream
+ */
+void GraphNode::OutputGraphInfo() const
+{
+  DoLog(2) && (Log() << Verbose(2) << "Atom " << getName() << " is " << ((SeparationVertex) ? "a" : "not a") << " separation vertex, components are ");
+  OutputComponentNumber();
+  DoLog(3) && (Log() << Verbose(3) << " with Lowpoint " << LowpointNr << " and Graph Nr. " << GraphNr << "." << endl);
+};
+
+/** Output a list of flags, stating whether the bond was visited or not.
+ * Note, we make use of the last entry of the ComponentNr always being -1 if allocated.
+ * \param *out output stream for debugging
+ */
+void GraphNode::OutputComponentNumber() const
+{
+  if (ComponentNr != NULL) {
+    for (int i=0; ComponentNr[i] != -1; i++)
+      DoLog(2) && (Log() << Verbose(2) << ComponentNr[i] << " ");
+  }
+};
+
Index: src/atom_graphnode.hpp
===================================================================
--- src/atom_graphnode.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/atom_graphnode.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,43 @@
+/*
+ * atom_graphnode.hpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: heber
+ */
+
+#ifndef ATOM_GRAPHNODE_HPP_
+#define ATOM_GRAPHNODE_HPP_
+
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <fstream>
+
+#include "atom_graphnodeinfo.hpp"
+#include "atom_particleinfo.hpp"
+
+/****************************************** forward declarations *****************************/
+
+/********************************************** declarations *******************************/
+
+class GraphNode : public GraphNodeInfo, public virtual ParticleInfo {
+public:
+
+  GraphNode();
+  virtual ~GraphNode();
+
+  void OutputGraphInfo() const;
+  void OutputComponentNumber() const;
+
+private:
+
+};
+
+#endif /* ATOM_GRAPHNODE_HPP_ */
Index: src/atom_graphnodeinfo.cpp
===================================================================
--- src/atom_graphnodeinfo.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/atom_graphnodeinfo.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,22 @@
+/*
+ * atom_graphnodeinfo.cpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: heber
+ */
+
+#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) {};
+
+/** Destructor of class GraphNodeInfo.
+ */
+GraphNodeInfo::~GraphNodeInfo()
+{
+  delete[](ComponentNr);
+};
Index: src/atom_graphnodeinfo.hpp
===================================================================
--- src/atom_graphnodeinfo.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/atom_graphnodeinfo.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,44 @@
+/*
+ * atom_graphnodeinfo.hpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: heber
+ */
+
+#ifndef ATOM_GRAPHNODEINFO_HPP_
+#define ATOM_GRAPHNODEINFO_HPP_
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+/****************************************** forward declarations *****************************/
+
+class atom;
+
+/********************************************** declarations *******************************/
+
+class GraphNode;
+
+class GraphNodeInfo {
+public:
+
+  int GraphNr;      //!< unique number, given in DepthFirstSearchAnalysis()
+  int *ComponentNr;//!< belongs to this non-separable components, given in DepthFirstSearchAnalysis() (if more than one, then is SeparationVertex)
+  int LowpointNr; //!< needed in DepthFirstSearchAnalysis() to detect non-separable components, is the lowest possible number of an atom to reach via tree edges only followed by at most one back edge.
+  bool SeparationVertex; //!< whether this atom separates off subsets of atoms or not, determined in DepthFirstSearchAnalysis()
+  bool IsCyclic;        //!< whether atom belong to as cycle or not, determined in DepthFirstSearchAnalysis()
+  atom *Ancestor; //!< "Father" in Depth-First-Search
+
+  GraphNodeInfo();
+  ~GraphNodeInfo();
+private:
+
+};
+
+#endif /* ATOM_GRAPHNODEINFO_HPP_ */
Index: src/atom_particleinfo.cpp
===================================================================
--- src/atom_particleinfo.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/atom_particleinfo.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,48 @@
+/*
+ * atom_particleinfo.cpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "atom_particleinfo.hpp"
+#include "memoryallocator.hpp"
+
+/** Constructor of ParticleInfo.
+ */
+ParticleInfo::ParticleInfo() : nr(-1), name("Unknown") {
+};
+
+ParticleInfo::ParticleInfo(ParticleInfo *pointer) :
+    nr(pointer->nr),
+    name(pointer->name)
+    {}
+
+
+/** Destructor of ParticleInfo.
+ */
+ParticleInfo::~ParticleInfo()
+{};
+
+const string& ParticleInfo::getName() const{
+  return name;
+}
+
+void ParticleInfo::setName(const string& _name){
+  name = _name;
+}
+
+ostream & operator << (ostream &ost, const ParticleInfo &a)
+{
+  ost << "[" << a.getName() << "|" << &a << "]";
+  return ost;
+};
+
+ostream & ParticleInfo::operator << (ostream &ost) const
+{
+  ost << "[" << name << "|" << this << "]";
+  return ost;
+};
+
Index: src/atom_particleinfo.hpp
===================================================================
--- src/atom_particleinfo.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/atom_particleinfo.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,46 @@
+/*
+ * atom_particleinfo.hpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: heber
+ */
+
+#ifndef ATOM_PARTICLEINFO_HPP_
+#define ATOM_PARTICLEINFO_HPP_
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <iostream>
+
+/****************************************** forward declarations *****************************/
+
+
+/********************************************** declarations *******************************/
+
+class ParticleInfo {
+public:
+  int nr;       // index to easierly identify
+
+  ParticleInfo();
+  ParticleInfo(ParticleInfo*);
+  ~ParticleInfo();
+
+  const std::string& getName() const;
+  void setName(const std::string&);
+
+  ostream & operator << (ostream &ost) const;
+
+private:
+  std::string name;   // some name to reference to on output
+};
+
+ostream & operator << (ostream &ost, const ParticleInfo &a);
+
+#endif /* ATOM_PARTICLEINFO_HPP_ */
Index: src/atom_trajectoryparticle.cpp
===================================================================
--- src/atom_trajectoryparticle.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/atom_trajectoryparticle.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,262 @@
+/*
+ * atom_trajectoryparticle.cpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "atom.hpp"
+#include "atom_trajectoryparticle.hpp"
+#include "config.hpp"
+#include "element.hpp"
+#include "info.hpp"
+#include "log.hpp"
+#include "parser.hpp"
+#include "ThermoStatContainer.hpp"
+#include "verbose.hpp"
+
+/** Constructor of class TrajectoryParticle.
+ */
+TrajectoryParticle::TrajectoryParticle()
+{
+};
+
+/** Destructor of class TrajectoryParticle.
+ */
+TrajectoryParticle::~TrajectoryParticle()
+{
+};
+
+
+/** Adds kinetic energy of this atom to given temperature value.
+ * \param *temperature add on this value
+ * \param step given step of trajectory to add
+ */
+void TrajectoryParticle::AddKineticToTemperature(double *temperature, int step) const
+{
+  for (int i=NDIM;i--;)
+    *temperature += type->mass * Trajectory.U.at(step)[i]* Trajectory.U.at(step)[i];
+};
+
+/** Evaluates some constraint potential if atom moves from \a startstep at once to \endstep in trajectory.
+ * \param startstep trajectory begins at
+ * \param endstep trajectory ends at
+ * \param **PermutationMap if atom switches places with some other atom, there is no translation but a permutaton noted here (not in the trajectories of ea
+ * \param *Force Force matrix to store result in
+ */
+void TrajectoryParticle::EvaluateConstrainedForce(int startstep, int endstep, atom **PermutationMap, ForceMatrix *Force) const
+{
+  double constant = 10.;
+  TrajectoryParticle *Sprinter = PermutationMap[nr];
+  // set forces
+  for (int i=NDIM;i++;)
+    Force->Matrix[0][nr][5+i] += 2.*constant*sqrt(Trajectory.R.at(startstep).distance(Sprinter->Trajectory.R.at(endstep)));
+};
+
+/** Correct velocity against the summed \a CoGVelocity for \a step.
+ * \param *ActualTemp sum up actual temperature meanwhile
+ * \param Step MD step in atom::Tracjetory
+ * \param *CoGVelocity remnant velocity (i.e. vector sum of all atom velocities)
+ */
+void TrajectoryParticle::CorrectVelocity(double *ActualTemp, int Step, Vector *CoGVelocity)
+{
+  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];
+  }
+};
+
+/** Extends the trajectory STL vector to the new size.
+ * Does nothing if \a MaxSteps is smaller than current size.
+ * \param MaxSteps
+ */
+void TrajectoryParticle::ResizeTrajectory(int MaxSteps)
+{
+  Info FunctionInfo(__func__);
+  if (Trajectory.R.size() <= (unsigned int)(MaxSteps)) {
+    DoLog(0) && (Log() << Verbose(0) << "Increasing size for trajectory array of " << nr << " from " << Trajectory.R.size() << " to " << (MaxSteps+1) << "." << endl);
+    Trajectory.R.resize(MaxSteps+1);
+    Trajectory.U.resize(MaxSteps+1);
+    Trajectory.F.resize(MaxSteps+1);
+  }
+};
+
+/** Copies a given trajectory step \a src onto another \a dest
+ * \param dest index of destination step
+ * \param src index of source step
+ */
+void TrajectoryParticle::CopyStepOnStep(int dest, int src)
+{
+  if (dest == src)  // self assignment check
+    return;
+
+  for (int n=NDIM;n--;) {
+    Trajectory.R.at(dest)[n] = Trajectory.R.at(src)[n];
+    Trajectory.U.at(dest)[n] = Trajectory.U.at(src)[n];
+    Trajectory.F.at(dest)[n] = Trajectory.F.at(src)[n];
+  }
+};
+
+/** Performs a velocity verlet update of the trajectory.
+ * Parameters are according to those in configuration class.
+ * \param NextStep index of sequential step to set
+ * \param *configuration pointer to configuration with parameters
+ * \param *Force matrix with forces
+ */
+void TrajectoryParticle::VelocityVerletUpdate(int NextStep, config *configuration, ForceMatrix *Force, const size_t offset)
+{
+  //a = configuration.Deltat*0.5/walker->type->mass;        // (F+F_old)/2m = a and thus: v = (F+F_old)/2m * t = (F + F_old) * a
+  for (int d=0; d<NDIM; d++) {
+    Trajectory.F.at(NextStep)[d] = -Force->Matrix[0][nr][d+offset]*(configuration->GetIsAngstroem() ? AtomicLengthToAngstroem : 1.);
+    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 =
+  }
+  // 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
+  }
+  // Update R (and F)
+//      out << "Integrated position&velocity of step " << (NextStep) << ": (";
+//      for (int d=0;d<NDIM;d++)
+//        out << Trajectory.R.at(NextStep).x[d] << " ";          // next step
+//      out << ")\t(";
+//      for (int d=0;d<NDIM;d++)
+//        Log() << Verbose(0) << Trajectory.U.at(NextStep).x[d] << " ";          // next step
+//      out << ")" << endl;
+};
+
+/** Sums up mass and kinetics.
+ * \param Step step to sum for
+ * \param *TotalMass pointer to total mass sum
+ * \param *TotalVelocity pointer to tota velocity sum
+ */
+void TrajectoryParticle::SumUpKineticEnergy( int Step, double *TotalMass, Vector *TotalVelocity ) const
+{
+  *TotalMass += type->mass;  // sum up total mass
+  for(int d=0;d<NDIM;d++) {
+    TotalVelocity->at(d) += Trajectory.U.at(Step)[d]*type->mass;
+  }
+};
+
+/** Scales velocity of atom according to Woodcock thermostat.
+ * \param ScaleTempFactor factor to scale the velocities with (i.e. sqrt of energy scale factor)
+ * \param Step MD step to scale
+ * \param *ekin sum of kinetic energy
+ */
+void TrajectoryParticle::Thermostat_Woodcock(double ScaleTempFactor, int Step, double *ekin)
+{
+  Vector &U = Trajectory.U.at(Step);
+  if (FixedIon == 0) // even FixedIon moves, only not by other's forces
+    for (int d=0; d<NDIM; d++) {
+      U[d] *= ScaleTempFactor;
+      *ekin += 0.5*type->mass * U[d]*U[d];
+    }
+};
+
+/** Scales velocity of atom according to Gaussian thermostat.
+ * \param Step MD step to scale
+ * \param *G
+ * \param *E
+ */
+void TrajectoryParticle::Thermostat_Gaussian_init(int Step, double *G, double *E)
+{
+  Vector &U = Trajectory.U.at(Step);
+  Vector &F = Trajectory.F.at(Step);
+  if (FixedIon == 0) // even FixedIon moves, only not by other's forces
+    for (int d=0; d<NDIM; d++) {
+      *G += U[d] * F[d];
+      *E += U[d]*U[d]*type->mass;
+    }
+};
+
+/** Determines scale factors according to Gaussian thermostat.
+ * \param Step MD step to scale
+ * \param GE G over E ratio
+ * \param *ekin sum of kinetic energy
+ * \param *configuration configuration class with TempFrequency and TargetTemp
+ */
+void TrajectoryParticle::Thermostat_Gaussian_least_constraint(int Step, double G_over_E, double *ekin, config *configuration)
+{
+  Vector &U = Trajectory.U.at(Step);
+  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];
+    }
+};
+
+/** Scales velocity of atom according to Langevin thermostat.
+ * \param Step MD step to scale
+ * \param *r random number generator
+ * \param *ekin sum of kinetic energy
+ * \param *configuration configuration class with TempFrequency and TargetTemp
+ */
+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)
+  Vector &U = Trajectory.U.at(Step);
+  if (FixedIon == 0) { // even FixedIon moves, only not by other's forces
+    // throw a dice to determine whether it gets hit by a heat bath particle
+    if (((((rand()/(double)RAND_MAX))*configuration->Thermostats->TempFrequency) < 1.)) {
+      DoLog(3) && (Log() << Verbose(3) << "Particle " << *this << " was hit (sigma " << sigma << "): " << sqrt(U[0]*U[0]+U[1]*U[1]+U[2]*U[2]) << " -> ");
+      // pick three random numbers from a Boltzmann distribution around the desired temperature T for each momenta axis
+      for (int d=0; d<NDIM; d++) {
+        U[d] = gsl_ran_gaussian (r, sigma);
+      }
+      DoLog(2) && (Log() << Verbose(2) << sqrt(U[0]*U[0]+U[1]*U[1]+U[2]*U[2]) << endl);
+    }
+    for (int d=0; d<NDIM; d++)
+      *ekin += 0.5*type->mass * U[d]*U[d];
+  }
+};
+
+/** Scales velocity of atom according to Berendsen thermostat.
+ * \param Step MD step to scale
+ * \param ScaleTempFactor factor to scale energy (not velocity!) with
+ * \param *ekin sum of kinetic energy
+ * \param *configuration configuration class with TempFrequency and Deltat
+ */
+void TrajectoryParticle::Thermostat_Berendsen(int Step, double ScaleTempFactor, double *ekin, config *configuration)
+{
+  Vector &U = Trajectory.U.at(Step);
+  if (FixedIon == 0) { // even FixedIon moves, only not by other's forces
+    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];
+    }
+  }
+};
+
+/** Initializes current run of NoseHoover thermostat.
+ * \param Step MD step to scale
+ * \param *delta_alpha additional sum of kinetic energy on return
+ */
+void TrajectoryParticle::Thermostat_NoseHoover_init(int Step, double *delta_alpha)
+{
+  Vector &U = Trajectory.U.at(Step);
+  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;
+    }
+  }
+};
+
+/** Initializes current run of NoseHoover thermostat.
+ * \param Step MD step to scale
+ * \param *ekin sum of kinetic energy
+ * \param *configuration configuration class with TempFrequency and Deltat
+ */
+void TrajectoryParticle::Thermostat_NoseHoover_scale(int Step, double *ekin, config *configuration)
+{
+  Vector &U = Trajectory.U.at(Step);
+  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];
+      }
+  }
+};
Index: src/atom_trajectoryparticle.hpp
===================================================================
--- src/atom_trajectoryparticle.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/atom_trajectoryparticle.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,69 @@
+/*
+ * atom_trajectoryparticle.hpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: heber
+ */
+
+#ifndef ATOM_TRAJECTORYPARTICLE_HPP_
+#define ATOM_TRAJECTORYPARTICLE_HPP_
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <fstream>
+
+#include <gsl/gsl_randist.h>
+
+#include "atom_atominfo.hpp"
+#include "atom_particleinfo.hpp"
+#include "atom_trajectoryparticleinfo.hpp"
+
+/****************************************** forward declarations *****************************/
+
+class atom;
+class config;
+class ForceMatrix;
+class Vector;
+
+/********************************************** declarations *******************************/
+
+
+class TrajectoryParticle :  public TrajectoryParticleInfo, public virtual AtomInfo, public virtual ParticleInfo {
+public:
+
+  TrajectoryParticle();
+  virtual ~TrajectoryParticle();
+
+  // constraint potential and dynamics stuff
+  void AddKineticToTemperature(double *temperature, int step) const;
+  void EvaluateConstrainedForce(int startstep, int endstep, atom **PermutationMap, ForceMatrix *Force) const;
+  void CorrectVelocity(double *ActualTemp, int Step, Vector *CoGVelocity);
+
+  // trajectory stuff
+  void ResizeTrajectory(int MaxSteps);
+  void CopyStepOnStep(int dest, int src);
+  void VelocityVerletUpdate(int MDSteps, config *configuration, ForceMatrix *Force, const size_t offset);
+  void SumUpKineticEnergy( int Step, double *TotalMass, Vector *TotalVelocity ) const;
+
+  // thermostats
+  void Thermostat_Woodcock(double ScaleTempFactor, int Step, double *ekin);
+  void Thermostat_Gaussian_init(int Step, double *G, double *E);
+  void Thermostat_Gaussian_least_constraint(int Step, double G_over_E, double *ekin, config *configuration);
+  void Thermostat_Langevin(int Step, gsl_rng * r, double *ekin, config *configuration);
+  void Thermostat_Berendsen(int Step, double ScaleTempFactor, double *ekin, config *configuration);
+  void Thermostat_NoseHoover_init(int Step, double *delta_alpha);
+  void Thermostat_NoseHoover_scale(int Step, double *ekin, config *configuration);
+
+private:
+
+};
+
+
+#endif /* ATOM_TRAJECTORYPARTICLE_HPP_ */
Index: src/atom_trajectoryparticleinfo.cpp
===================================================================
--- src/atom_trajectoryparticleinfo.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/atom_trajectoryparticleinfo.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,23 @@
+/*
+ * atom_trajectoryparticleinfo.cpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "atom_trajectoryparticleinfo.hpp"
+
+/** Constructor of class TrajectoryParticleInfo.
+ */
+TrajectoryParticleInfo::TrajectoryParticleInfo() : FixedIon(0) {};
+
+/** Destructor of class TrajectoryParticleInfo.
+ */
+TrajectoryParticleInfo::~TrajectoryParticleInfo()
+{
+  Trajectory.R.clear();
+  Trajectory.U.clear();
+  Trajectory.F.clear();
+};
Index: src/atom_trajectoryparticleinfo.hpp
===================================================================
--- src/atom_trajectoryparticleinfo.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/atom_trajectoryparticleinfo.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,43 @@
+/*
+ * atom_trajectoryparticleinfo.hpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: heber
+ */
+
+#ifndef ATOM_TRAJECTORYPARTICLEINFO_HPP_
+#define ATOM_TRAJECTORYPARTICLEINFO_HPP_
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <vector>
+
+#include "vector.hpp"
+#include "VectorSet.hpp"
+
+/********************************************** declarations *******************************/
+
+class TrajectoryParticleInfo {
+public:
+  struct
+  {
+    VectorSet<vector<Vector> > R;  //!< position vector
+    VectorSet<vector<Vector> > U;  //!< velocity vector
+    VectorSet<vector<Vector> > F;  //!< last force vector
+  } Trajectory;
+  int FixedIon;   //!< config variable that states whether forces act on the ion or not
+
+  TrajectoryParticleInfo();
+  ~TrajectoryParticleInfo();
+
+private:
+};
+
+#endif /* ATOM_TRAJECTORYPARTICLEINFO_HPP_ */
Index: src/bond.cpp
===================================================================
--- src/bond.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/bond.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,136 @@
+/** \file bond.cpp
+ * 
+ * Function implementations for the classes BondLeaf, BondTree and bond.
+ * 
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "atom.hpp"
+#include "bond.hpp"
+#include "element.hpp"
+#include "lists.hpp"
+
+
+/***************************************** Functions for class bond ********************************/
+
+/** 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)
+{
+};
+
+/** Constructor for class bond, taking right and left bond partner
+ * \param *left left atom
+ * \param *right right atom
+ * \param degree bond degree
+ * \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)
+{
+  if ((left != NULL) && (right != NULL)) {
+    if ((left->type != NULL) && (left->type->Z == 1))
+      HydrogenBond++;
+    if ((right->type != NULL) && (right->type->Z == 1))
+      HydrogenBond++;
+  }
+};
+
+/** Empty Destructor for class bond.
+ */
+bond::~bond()
+{
+  // remove this node from the list structure
+  if (leftatom != NULL)
+    leftatom->UnregisterBond(this);
+  if (rightatom != NULL)
+  rightatom->UnregisterBond(this);
+  unlink(this);
+};
+
+ostream & operator << (ostream &ost, const bond &b)
+{
+  ost << "[" << b.leftatom->getName() << " <" << b.BondDegree << "(H" << b.HydrogenBond << ")>" << b.rightatom->getName() << "]";
+  return ost;
+};
+
+/** Get the other atom in a bond if one is specified.
+ * \param *Atom the pointer to the one atom
+ * \return pointer to the other atom in the bond, NULL if no match (indicates something's wrong with the bond) 
+ */
+atom * bond::GetOtherAtom(const ParticleInfo * const Atom) const
+{
+  if(leftatom == Atom) 
+    return rightatom;
+  if(rightatom == Atom) 
+    return leftatom;
+  DoeLog(1) && (eLog()<< Verbose(1) << "Bond " << *this << " does not contain atom " << *Atom << "!" << endl);
+  return NULL;
+};
+
+
+/** Returns whether vertex was used in DFS.
+ * \return bond::Used
+ */
+enum Shading bond::IsUsed() 
+{
+  return Used;
+};
+
+/** Checks if an atom exists in a bond.
+ * \param *ptr pointer to atom
+ * \return true if it is either bond::leftatom or bond::rightatom, false otherwise
+ */
+bool bond::Contains(const ParticleInfo * const ptr)
+{
+  return ((leftatom == ptr) || (rightatom == ptr));
+};
+
+/** Checks if an atom exists in a bond.
+ * \param nr index of atom
+ * \return true if it is either bond::leftatom or bond::rightatom, false otherwise
+ */
+bool bond::Contains(const int number)
+{
+  return ((leftatom->nr == number) || (rightatom->nr == number));
+};
+
+/** Masks vertex as used in DFS.
+ * \return bond::Used, false if bond was already marked used
+ */
+bool bond::MarkUsed(const enum Shading color) {
+  if (Used == black) {
+    DoeLog(1) && (eLog()<< Verbose(1) << "Bond " << this << " was already marked black!." << endl);
+    return false;
+  } else {
+    Used = color;
+    return true;
+  }
+};
+
+/** Resets used flag in DFS.
+ * \return bond::Used
+ */
+void bond::ResetUsed() {
+  Used = white;
+};
+
+/** Calculates the bond length.
+ * \return |a - b| with a = bond::leftatom and b = bond::rightatom.
+ */
+double bond::GetDistance() const
+{
+  return (leftatom->node->distance(*rightatom->node));
+};
+
+/** Calculates the bond length.
+ * \return |a - b|^2 with a = bond::leftatom and b = bond::rightatom.
+ */
+double bond::GetDistanceSquared() const
+{
+  return (leftatom->node->DistanceSquared(*rightatom->node));
+};
Index: src/bond.hpp
===================================================================
--- src/bond.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/bond.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,66 @@
+/*
+ * bond.hpp
+ *
+ *  Created on: Aug 3, 2009
+ *      Author: heber
+ */
+
+#ifndef BOND_HPP_
+#define BOND_HPP_
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+/****************************************** forward declarations *****************************/
+
+class atom;
+class ParticleInfo;
+
+/********************************************** declarations *******************************/
+
+/** Bonds between atoms.
+ * Class incorporates bonds between atoms in a molecule.
+ * Note that we regard bond always as something in a molecule,
+ * as it is the glue making up the connected subgrapgh and
+ * hence the molecule. Thus, bonds belong globally to the molecule
+ * (and are free'd there) and only locally to the atom classs.
+ */
+class bond {
+  public:
+    atom *leftatom;    //!< first bond partner
+    atom *rightatom;  //!< second bond partner
+    bond *previous; //!< previous atom in molecule list
+    bond *next;     //!< next atom in molecule list
+    int HydrogenBond;  //!< Number of hydrogen atoms in the bond
+    int BondDegree;    //!< single, double, triple, ... bond
+    int nr;           //!< unique number in a molecule, updated by molecule::CreateAdjacencyList()
+    bool Cyclic;      //!< flag whether bond is part of a cycle or not, given in DepthFirstSearchAnalysis()
+    enum EdgeType Type;//!< whether this is a tree or back edge
+
+  atom * GetOtherAtom(const ParticleInfo * const Atom) const;
+
+  bool MarkUsed(const enum Shading color);
+  enum Shading IsUsed();
+  void ResetUsed();
+  bool Contains(const ParticleInfo * const ptr);
+  bool Contains(const int nr);
+  double GetDistance() const;
+  double GetDistanceSquared() const;
+
+  bond();
+  bond(atom *left, atom *right, const int degree=1, const int number=0);
+  ~bond();
+
+  private:
+    enum Shading Used;        //!< marker in depth-first search, DepthFirstSearchAnalysis()
+};
+
+ostream & operator << (ostream &ost, const bond &b);
+
+#endif /* BOND_HPP_ */
Index: src/bondgraph.cpp
===================================================================
--- src/bondgraph.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/bondgraph.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,172 @@
+/*
+ * bondgraph.cpp
+ *
+ *  Created on: Oct 29, 2009
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include <iostream>
+
+#include "atom.hpp"
+#include "bond.hpp"
+#include "bondgraph.hpp"
+#include "element.hpp"
+#include "info.hpp"
+#include "log.hpp"
+#include "molecule.hpp"
+#include "parser.hpp"
+#include "periodentafel.hpp"
+#include "vector.hpp"
+
+/** 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)
+{
+};
+
+/** Destructor of class BondGraph.
+ */
+BondGraph::~BondGraph()
+{
+  if (BondLengthMatrix != NULL) {
+    delete(BondLengthMatrix);
+  }
+};
+
+/** Parses the bond lengths in a given file and puts them int a matrix form.
+ * Allocates \a MatrixContainer for BondGraph::BondLengthMatrix, using MatrixContainer::ParseMatrix(),
+ * but only if parsing is successful. Otherwise variable is left as NULL.
+ * \param *out output stream for debugging
+ * \param filename file with bond lengths to parse
+ * \return true - success in parsing file, false - failed to parse the file
+ */
+bool BondGraph::LoadBondLengthTable(const string &filename)
+{
+  Info FunctionInfo(__func__);
+  bool status = true;
+  MatrixContainer *TempContainer = NULL;
+
+  // allocate MatrixContainer
+  if (BondLengthMatrix != NULL) {
+    DoLog(1) && (Log() << Verbose(1) << "MatrixContainer for Bond length already present, removing." << endl);
+    delete(BondLengthMatrix);
+  }
+  TempContainer = new MatrixContainer;
+
+  // parse in matrix
+  if ((status = TempContainer->ParseMatrix(filename.c_str(), 0, 1, 0))) {
+    DoLog(1) && (Log() << Verbose(1) << "Parsing bond length matrix successful." << endl);
+  } else {
+    DoeLog(1) && (eLog()<< Verbose(1) << "Parsing bond length matrix failed." << endl);
+  }
+
+  // find greatest distance
+  max_distance=0;
+  if (status) {
+    for(int i=0;i<TempContainer->RowCounter[0];i++)
+      for(int j=i;j<TempContainer->ColumnCounter[0];j++)
+        if (TempContainer->Matrix[0][i][j] > max_distance)
+          max_distance = TempContainer->Matrix[0][i][j];
+  }
+
+  if (status) // set to not NULL only if matrix was parsed
+    BondLengthMatrix = TempContainer;
+  else {
+    BondLengthMatrix = NULL;
+    delete(TempContainer);
+  }
+  return status;
+};
+
+/** Parses the bond lengths in a given file and puts them int a matrix form.
+ * \param *out output stream for debugging
+ * \param *mol molecule with atoms
+ * \return true - success, false - failed to construct bond structure
+ */
+bool BondGraph::ConstructBondGraph(molecule * const mol)
+{
+  Info FunctionInfo(__func__);
+  bool status = true;
+
+  if (mol->empty()) // only construct if molecule is not empty
+    return false;
+
+  if (BondLengthMatrix == NULL) { // no bond length matrix parsed?
+    SetMaxDistanceToMaxOfCovalentRadii(mol);
+    mol->CreateAdjacencyList(max_distance, IsAngstroem, &BondGraph::CovalentMinMaxDistance, this);
+  } else
+    mol->CreateAdjacencyList(max_distance, IsAngstroem, &BondGraph::BondLengthMatrixMinMaxDistance, this);
+
+  return status;
+};
+
+/** Returns the entry for a given index pair.
+ * \param firstelement index/atom number of first element (row index)
+ * \param secondelement index/atom number of second element (column index)
+ * \note matrix is of course symmetric.
+ */
+double BondGraph::GetBondLength(int firstZ, int secondZ)
+{
+  if (BondLengthMatrix == NULL)
+    return( -1. );
+  else
+    return (BondLengthMatrix->Matrix[0][firstZ][secondZ]);
+};
+
+/** Determines the maximum of all element::CovalentRadius for elements present in \a *mol.
+ * \param *out output stream for debugging
+ * \param *mol molecule with all atoms and their respective elements.
+ */
+double BondGraph::SetMaxDistanceToMaxOfCovalentRadii(const molecule * const mol)
+{
+  Info FunctionInfo(__func__);
+  max_distance = 0.;
+
+  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
+    if ((*iter)->type->CovalentRadius > max_distance)
+      max_distance = (*iter)->type->CovalentRadius;
+  }
+  max_distance *= 2.;
+
+  return max_distance;
+};
+
+/** Returns bond criterion for given pair based on covalent radius.
+ * \param *Walker first BondedParticle
+ * \param *OtherWalker second BondedParticle
+ * \param &MinDistance lower bond bound on return
+ * \param &MaxDistance upper bond bound on return
+ * \param IsAngstroem whether units are in angstroem or bohr radii
+ */
+void BondGraph::CovalentMinMaxDistance(BondedParticle * const Walker, BondedParticle * const OtherWalker, double &MinDistance, double &MaxDistance, bool IsAngstroem)
+{
+  MinDistance = OtherWalker->type->CovalentRadius + Walker->type->CovalentRadius;
+  MinDistance *= (IsAngstroem) ? 1. : 1. / AtomicLengthToAngstroem;
+  MaxDistance = MinDistance + BONDTHRESHOLD;
+  MinDistance -= BONDTHRESHOLD;
+};
+
+/** Returns bond criterion for given pair based on a bond length matrix.
+ * The matrix should be contained in \a this BondGraph and contain an element-
+ * to-element length.
+ * \param *Walker first BondedParticle
+ * \param *OtherWalker second BondedParticle
+ * \param &MinDistance lower bond bound on return
+ * \param &MaxDistance upper bond bound on return
+ * \param IsAngstroem whether units are in angstroem or bohr radii
+ */
+void BondGraph::BondLengthMatrixMinMaxDistance(BondedParticle * const Walker, BondedParticle * const OtherWalker, double &MinDistance, double &MaxDistance, bool IsAngstroem)
+{
+  if (BondLengthMatrix == NULL) {// safety measure if no matrix has been parsed yet
+    DoeLog(2) && (eLog()<< Verbose(2) << "BondLengthMatrixMinMaxDistance() called without having parsed the bond length matrix yet!" << endl);
+    CovalentMinMaxDistance(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem);
+  } else {
+    MinDistance = GetBondLength(Walker->type->Z-1, OtherWalker->type->Z-1);
+    MinDistance *= (IsAngstroem) ? 1. : 1. / AtomicLengthToAngstroem;
+    MaxDistance = MinDistance + BONDTHRESHOLD;
+    MinDistance -= BONDTHRESHOLD;
+  }
+};
Index: src/bondgraph.hpp
===================================================================
--- src/bondgraph.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/bondgraph.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,55 @@
+/*
+ * bondgraph.hpp
+ *
+ *  Created on: Oct 29, 2009
+ *      Author: heber
+ */
+
+#ifndef BONDGRAPH_HPP_
+#define BONDGRAPH_HPP_
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <iostream>
+
+/*********************************************** 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 *****************************/
+
+class molecule;
+class BondedParticle;
+class MatrixContainer;
+
+/********************************************** definitions *********************************/
+
+/********************************************** declarations *******************************/
+
+
+class BondGraph {
+public:
+  BondGraph(bool IsA);
+  ~BondGraph();
+  bool LoadBondLengthTable(const string &filename);
+  bool ConstructBondGraph(molecule * const mol);
+  double GetBondLength(int firstelement, int secondelement);
+  double SetMaxDistanceToMaxOfCovalentRadii(const molecule * const mol);
+
+  void BondLengthMatrixMinMaxDistance(BondedParticle * const Walker, BondedParticle * const OtherWalker, double &MinDistance, double &MaxDistance, bool IsAngstroem);
+  void CovalentMinMaxDistance(BondedParticle * const Walker, BondedParticle * const OtherWalker, double &MinDistance, double &MaxDistance, bool IsAngstroem);
+
+private:
+  MatrixContainer *BondLengthMatrix;
+  double max_distance;
+  bool IsAngstroem;
+};
+
+#endif /* BONDGRAPH_HPP_ */
Index: src/boundary.cpp
===================================================================
--- src/boundary.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/boundary.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,1062 @@
+/** \file boundary.cpp
+ *
+ * Implementations and super-function for envelopes
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "World.hpp"
+#include "atom.hpp"
+#include "bond.hpp"
+#include "boundary.hpp"
+#include "config.hpp"
+#include "element.hpp"
+#include "helpers.hpp"
+#include "info.hpp"
+#include "linkedcell.hpp"
+#include "log.hpp"
+#include "memoryallocator.hpp"
+#include "molecule.hpp"
+#include "tesselation.hpp"
+#include "tesselationhelpers.hpp"
+#include "World.hpp"
+#include "Plane.hpp"
+
+#include<gsl/gsl_poly.h>
+#include<time.h>
+
+// ========================================== F U N C T I O N S =================================
+
+
+/** Determines greatest diameters of a cluster defined by its convex envelope.
+ * Looks at lines parallel to one axis and where they intersect on the projected planes
+ * \param *out output stream for debugging
+ * \param *BoundaryPoints NDIM set of boundary points defining the convex envelope on each projected plane
+ * \param *mol molecule structure representing the cluster
+ * \param *&TesselStruct Tesselation structure with triangles
+ * \param IsAngstroem whether we have angstroem or atomic units
+ * \return NDIM array of the diameters
+ */
+double *GetDiametersOfCluster(const Boundaries *BoundaryPtr, const molecule *mol, Tesselation *&TesselStruct, const bool IsAngstroem)
+{
+	Info FunctionInfo(__func__);
+  // get points on boundary of NULL was given as parameter
+  bool BoundaryFreeFlag = false;
+  double OldComponent = 0.;
+  double tmp = 0.;
+  double w1 = 0.;
+  double w2 = 0.;
+  Vector DistanceVector;
+  Vector OtherVector;
+  int component = 0;
+  int Othercomponent = 0;
+  Boundaries::const_iterator Neighbour;
+  Boundaries::const_iterator OtherNeighbour;
+  double *GreatestDiameter = new double[NDIM];
+
+  const Boundaries *BoundaryPoints;
+  if (BoundaryPtr == NULL) {
+    BoundaryFreeFlag = true;
+    BoundaryPoints = GetBoundaryPoints(mol, TesselStruct);
+  } else {
+    BoundaryPoints = BoundaryPtr;
+    DoLog(0) && (Log() << Verbose(0) << "Using given boundary points set." << endl);
+  }
+  // determine biggest "diameter" of cluster for each axis
+  for (int i = 0; i < NDIM; i++)
+    GreatestDiameter[i] = 0.;
+  for (int axis = 0; axis < NDIM; axis++)
+    { // regard each projected plane
+      //Log() << Verbose(1) << "Current axis is " << axis << "." << endl;
+      for (int j = 0; j < 2; j++)
+        { // and for both axis on the current plane
+          component = (axis + j + 1) % NDIM;
+          Othercomponent = (axis + 1 + ((j + 1) & 1)) % NDIM;
+          //Log() << Verbose(1) << "Current component is " << component << ", Othercomponent is " << Othercomponent << "." << endl;
+          for (Boundaries::const_iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) {
+              //Log() << Verbose(1) << "Current runner is " << *(runner->second.second) << "." << endl;
+              // seek for the neighbours pair where the Othercomponent sign flips
+              Neighbour = runner;
+              Neighbour++;
+              if (Neighbour == BoundaryPoints[axis].end()) // make it wrap around
+                Neighbour = BoundaryPoints[axis].begin();
+              DistanceVector = runner->second.second->x - Neighbour->second.second->x;
+              do { // seek for neighbour pair where it flips
+                  OldComponent = DistanceVector[Othercomponent];
+                  Neighbour++;
+                  if (Neighbour == BoundaryPoints[axis].end()) // make it wrap around
+                    Neighbour = BoundaryPoints[axis].begin();
+                  DistanceVector = runner->second.second->x - Neighbour->second.second->x;
+                  //Log() << Verbose(2) << "OldComponent is " << OldComponent << ", new one is " << DistanceVector.x[Othercomponent] << "." << endl;
+                } while ((runner != Neighbour) && (fabs(OldComponent / fabs(
+                  OldComponent) - DistanceVector[Othercomponent] / fabs(
+                  DistanceVector[Othercomponent])) < MYEPSILON)); // as long as sign does not flip
+              if (runner != Neighbour) {
+                  OtherNeighbour = Neighbour;
+                  if (OtherNeighbour == BoundaryPoints[axis].begin()) // make it wrap around
+                    OtherNeighbour = BoundaryPoints[axis].end();
+                  OtherNeighbour--;
+                  //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;
+                  //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;
+                  // do linear interpolation between points (is exact) to extract exact intersection between Neighbour and OtherNeighbour
+                  w1 = fabs(OtherVector[Othercomponent]);
+                  w2 = fabs(DistanceVector[Othercomponent]);
+                  tmp = fabs((w1 * DistanceVector[component] + w2
+                      * OtherVector[component]) / (w1 + w2));
+                  // mark if it has greater diameter
+                  //Log() << Verbose(1) << "Comparing current greatest " << GreatestDiameter[component] << " to new " << tmp << "." << endl;
+                  GreatestDiameter[component] = (GreatestDiameter[component]
+                      > tmp) ? GreatestDiameter[component] : tmp;
+                } //else
+              //Log() << Verbose(1) << "Saw no sign flip, probably top or bottom node." << endl;
+            }
+        }
+    }
+  Log() << Verbose(0) << "RESULT: The biggest diameters are "
+      << GreatestDiameter[0] << " and " << GreatestDiameter[1] << " and "
+      << GreatestDiameter[2] << " " << (IsAngstroem ? "angstrom"
+      : "atomiclength") << "." << endl;
+
+  // free reference lists
+  if (BoundaryFreeFlag)
+    delete[] (BoundaryPoints);
+
+  return GreatestDiameter;
+}
+;
+
+
+/** Determines the boundary points of a cluster.
+ * Does a projection per axis onto the orthogonal plane, transforms into spherical coordinates, sorts them by the angle
+ * and looks at triples: if the middle has less a distance than the allowed maximum height of the triangle formed by the plane's
+ * center and first and last point in the triple, it is thrown out.
+ * \param *out output stream for debugging
+ * \param *mol molecule structure representing the cluster
+ * \param *&TesselStruct pointer to Tesselation structure
+ */
+Boundaries *GetBoundaryPoints(const molecule *mol, Tesselation *&TesselStruct)
+{
+	Info FunctionInfo(__func__);
+  PointMap PointsOnBoundary;
+  LineMap LinesOnBoundary;
+  TriangleMap TrianglesOnBoundary;
+  Vector *MolCenter = mol->DetermineCenterOfAll();
+  Vector helper;
+  BoundariesTestPair BoundaryTestPair;
+  Vector AxisVector;
+  Vector AngleReferenceVector;
+  Vector AngleReferenceNormalVector;
+  Vector ProjectedVector;
+  Boundaries *BoundaryPoints = new Boundaries[NDIM]; // first is alpha, second is (r, nr)
+  double angle = 0.;
+
+  // 3a. Go through every axis
+  for (int axis = 0; axis < NDIM; axis++) {
+    AxisVector.Zero();
+    AngleReferenceVector.Zero();
+    AngleReferenceNormalVector.Zero();
+    AxisVector[axis] = 1.;
+    AngleReferenceVector[(axis + 1) % NDIM] = 1.;
+    AngleReferenceNormalVector[(axis + 2) % NDIM] = 1.;
+
+    DoLog(1) && (Log() << Verbose(1) << "Axisvector is " << AxisVector << " and AngleReferenceVector is " << AngleReferenceVector << ", and AngleReferenceNormalVector is " << AngleReferenceNormalVector << "." << endl);
+
+    // 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.ProjectOntoPlane(AxisVector);
+
+      // correct for negative side
+      const double radius = ProjectedVector.NormSquared();
+      if (fabs(radius) > MYEPSILON)
+        angle = ProjectedVector.Angle(AngleReferenceVector);
+      else
+        angle = 0.; // otherwise it's a vector in Axis Direction and unimportant for boundary issues
+
+      //Log() << Verbose(1) << "Checking sign in quadrant : " << ProjectedVector.Projection(&AngleReferenceNormalVector) << "." << endl;
+      if (ProjectedVector.ScalarProduct(AngleReferenceNormalVector) > 0) {
+        angle = 2. * M_PI - angle;
+      }
+    DoLog(1) && (Log() << Verbose(1) << "Inserting " << **iter << ": (r, alpha) = (" << radius << "," << angle << "): " << ProjectedVector << endl);
+      BoundaryTestPair = BoundaryPoints[axis].insert(BoundariesPair(angle, DistancePair (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);
+        DoLog(2) && (Log() << Verbose(2) << "Present vector: " << *BoundaryTestPair.first->second.second << endl);
+        DoLog(2) && (Log() << Verbose(2) << "New vector: " << **iter << endl);
+        const double ProjectedVectorNorm = ProjectedVector.NormSquared();
+        if ((ProjectedVectorNorm - BoundaryTestPair.first->second.first) > MYEPSILON) {
+          BoundaryTestPair.first->second.first = ProjectedVectorNorm;
+          BoundaryTestPair.first->second.second = (*iter);
+          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;
+          const double oldhelperNorm = helper.NormSquared();
+          helper = BoundaryTestPair.first->second.second->x - (*MolCenter);
+          if (helper.NormSquared() < oldhelperNorm) {
+            BoundaryTestPair.first->second.second = (*iter);
+            DoLog(2) && (Log() << Verbose(2) << "Keeping new vector due to larger distance to molecule center " << helper.NormSquared() << "." << endl);
+          } else {
+            DoLog(2) && (Log() << Verbose(2) << "Keeping present vector due to larger distance to molecule center " << oldhelperNorm << "." << endl);
+          }
+        } else {
+          DoLog(2) && (Log() << Verbose(2) << "Keeping present vector due to larger projected distance " << ProjectedVectorNorm << "." << endl);
+        }
+      }
+    }
+    // printing all inserted for debugging
+    //    {
+    //      Log() << Verbose(1) << "Printing list of candidates for axis " << axis << " which we have inserted so far." << endl;
+    //      int i=0;
+    //      for(Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) {
+    //        if (runner != BoundaryPoints[axis].begin())
+    //          Log() << Verbose(0) << ", " << i << ": " << *runner->second.second;
+    //        else
+    //          Log() << Verbose(0) << i << ": " << *runner->second.second;
+    //        i++;
+    //      }
+    //      Log() << Verbose(0) << endl;
+    //    }
+    // 3c. throw out points whose distance is less than the mean of left and right neighbours
+    bool flag = false;
+    DoLog(1) && (Log() << Verbose(1) << "Looking for candidates to kick out by convex condition ... " << endl);
+    do { // do as long as we still throw one out per round
+      flag = false;
+      Boundaries::iterator left = BoundaryPoints[axis].begin();
+      Boundaries::iterator right = BoundaryPoints[axis].begin();
+      Boundaries::iterator runner = BoundaryPoints[axis].begin();
+      bool LoopOnceDone = false;
+      while (!LoopOnceDone) {
+	runner = right;
+	right++;
+        // set neighbours correctly
+        if (runner == BoundaryPoints[axis].begin()) {
+          left = BoundaryPoints[axis].end();
+        } else {
+          left = runner;
+        }
+        left--;
+        if (right == BoundaryPoints[axis].end()) {
+          right = BoundaryPoints[axis].begin();
+          LoopOnceDone = true;
+        }
+        // check distance
+
+        // construct the vector of each side of the triangle on the projected plane (defined by normal vector AxisVector)
+        {
+          Vector SideA, SideB, SideC, SideH;
+          SideA = left->second.second->x - (*MolCenter);
+          SideA.ProjectOntoPlane(AxisVector);
+          //          Log() << Verbose(1) << "SideA: " << SideA << endl;
+
+          SideB = right->second.second->x -(*MolCenter);
+          SideB.ProjectOntoPlane(AxisVector);
+          //          Log() << Verbose(1) << "SideB: " << SideB << endl;
+
+          SideC = left->second.second->x - right->second.second->x;
+          SideC.ProjectOntoPlane(AxisVector);
+          //          Log() << Verbose(1) << "SideC: " << SideC << endl;
+
+          SideH = runner->second.second->x -(*MolCenter);
+          SideH.ProjectOntoPlane(AxisVector);
+          //          Log() << Verbose(1) << "SideH: " << SideH << endl;
+
+          // calculate each length
+          const double a = SideA.Norm();
+          //const double b = SideB.Norm();
+          //const double c = SideC.Norm();
+          const double h = SideH.Norm();
+          // calculate the angles
+          const double alpha = SideA.Angle(SideH);
+          const double beta = SideA.Angle(SideC);
+          const double gamma = SideB.Angle(SideH);
+          const double delta = SideC.Angle(SideH);
+          const double MinDistance = a * sin(beta) / (sin(delta)) * (((alpha < M_PI / 2.) || (gamma < M_PI / 2.)) ? 1. : -1.);
+          //Log() << Verbose(1) << " I calculated: a = " << a << ", h = " << h << ", beta(" << left->second.second->Name << "," << left->second.second->Name << "-" << right->second.second->Name << ") = " << beta << ", delta(" << left->second.second->Name << "," << runner->second.second->Name << ") = " << delta << ", Min = " << MinDistance << "." << endl;
+          DoLog(1) && (Log() << Verbose(1) << "Checking CoG distance of runner " << *runner->second.second << " " << h << " against triangle's side length spanned by (" << *left->second.second << "," << *right->second.second << ") of " << MinDistance << "." << endl);
+          if ((fabs(h / fabs(h) - MinDistance / fabs(MinDistance)) < MYEPSILON) && ((h - MinDistance)) < -MYEPSILON) {
+            // throw out point
+            DoLog(1) && (Log() << Verbose(1) << "Throwing out " << *runner->second.second << "." << endl);
+            BoundaryPoints[axis].erase(runner);
+            runner = right;
+            flag = true;
+          }
+        }
+      }
+    } while (flag);
+  }
+  delete(MolCenter);
+  return BoundaryPoints;
+};
+
+/** Tesselates the convex boundary by finding all boundary points.
+ * \param *out output stream for debugging
+ * \param *mol molecule structure with Atom's and Bond's.
+ * \param *BoundaryPts set of boundary points to use or NULL
+ * \param *TesselStruct Tesselation filled with points, lines and triangles on boundary on return
+ * \param *LCList atoms in LinkedCell list
+ * \param *filename filename prefix for output of vertex data
+ * \return *TesselStruct is filled with convex boundary and tesselation is stored under \a *filename.
+ */
+void FindConvexBorder(const molecule* mol, Boundaries *BoundaryPts, Tesselation *&TesselStruct, const LinkedCell *LCList, const char *filename)
+{
+	Info FunctionInfo(__func__);
+  bool BoundaryFreeFlag = false;
+  Boundaries *BoundaryPoints = NULL;
+
+  if (TesselStruct != NULL) // free if allocated
+    delete(TesselStruct);
+  TesselStruct = new class Tesselation;
+
+  // 1. Find all points on the boundary
+  if (BoundaryPts == NULL) {
+    BoundaryFreeFlag = true;
+    BoundaryPoints = GetBoundaryPoints(mol, TesselStruct);
+  } else {
+    BoundaryPoints = BoundaryPts;
+    DoLog(0) && (Log() << Verbose(0) << "Using given boundary points set." << endl);
+  }
+
+// printing all inserted for debugging
+  for (int axis=0; axis < NDIM; axis++) {
+    DoLog(1) && (Log() << Verbose(1) << "Printing list of candidates for axis " << axis << " which we have inserted so far." << endl);
+    int i=0;
+    for(Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) {
+      if (runner != BoundaryPoints[axis].begin())
+        DoLog(0) && (Log() << Verbose(0) << ", " << i << ": " << *runner->second.second);
+      else
+        DoLog(0) && (Log() << Verbose(0) << i << ": " << *runner->second.second);
+      i++;
+    }
+    DoLog(0) && (Log() << Verbose(0) << endl);
+  }
+
+  // 2. fill the boundary point list
+  for (int axis = 0; axis < NDIM; axis++)
+    for (Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++)
+        if (!TesselStruct->AddBoundaryPoint(runner->second.second, 0))
+          DoLog(2) && (Log()<< Verbose(2) << "Point " << *(runner->second.second) << " is already present." << endl);
+
+  DoLog(0) && (Log() << Verbose(0) << "I found " << TesselStruct->PointsOnBoundaryCount << " points on the convex boundary." << endl);
+  // now we have the whole set of edge points in the BoundaryList
+
+  // listing for debugging
+  //  Log() << Verbose(1) << "Listing PointsOnBoundary:";
+  //  for(PointMap::iterator runner = PointsOnBoundary.begin(); runner != PointsOnBoundary.end(); runner++) {
+  //    Log() << Verbose(0) << " " << *runner->second;
+  //  }
+  //  Log() << Verbose(0) << endl;
+
+  // 3a. guess starting triangle
+  TesselStruct->GuessStartingTriangle();
+
+  // 3b. go through all lines, that are not yet part of two triangles (only of one so far)
+  TesselStruct->TesselateOnBoundary(mol);
+
+  // 3c. check whether all atoms lay inside the boundary, if not, add to boundary points, segment triangle into three with the new point
+  if (!TesselStruct->InsertStraddlingPoints(mol, LCList))
+    DoeLog(1) && (eLog()<< Verbose(1) << "Insertion of straddling points failed!" << endl);
+
+  DoLog(0) && (Log() << Verbose(0) << "I created " << TesselStruct->TrianglesOnBoundary.size() << " intermediate triangles with " << TesselStruct->LinesOnBoundary.size() << " lines and " << TesselStruct->PointsOnBoundary.size() << " points." << endl);
+
+  // 4. Store triangles in tecplot file
+  StoreTrianglesinFile(mol, TesselStruct, filename, "_intermed");
+
+  // 3d. check all baselines whether the peaks of the two adjacent triangles with respect to center of baseline are convex, if not, make the baseline between the two peaks and baseline endpoints become the new peaks
+  bool AllConvex = true;
+  class BoundaryLineSet *line = NULL;
+  do {
+    AllConvex = true;
+    for (LineMap::iterator LineRunner = TesselStruct->LinesOnBoundary.begin(); LineRunner != TesselStruct->LinesOnBoundary.end(); LineRunner++) {
+      line = LineRunner->second;
+      DoLog(1) && (Log() << Verbose(1) << "INFO: Current line is " << *line << "." << endl);
+      if (!line->CheckConvexityCriterion()) {
+        DoLog(1) && (Log() << Verbose(1) << "... line " << *line << " is concave, flipping it." << endl);
+
+        // flip the line
+        if (TesselStruct->PickFarthestofTwoBaselines(line) == 0.)
+          DoeLog(1) && (eLog()<< Verbose(1) << "Correction of concave baselines failed!" << endl);
+        else {
+          TesselStruct->FlipBaseline(line);
+          DoLog(1) && (Log() << Verbose(1) << "INFO: Correction of concave baselines worked." << endl);
+          LineRunner = TesselStruct->LinesOnBoundary.begin(); // LineRunner may have been erase if line was deleted from LinesOnBoundary
+        }
+      }
+    }
+  } while (!AllConvex);
+
+  // 3e. we need another correction here, for TesselPoints that are below the surface (i.e. have an odd number of concave triangles surrounding it)
+//  if (!TesselStruct->CorrectConcaveTesselPoints(out))
+//    Log() << Verbose(1) << "Correction of concave tesselpoints failed!" << endl;
+
+  DoLog(0) && (Log() << Verbose(0) << "I created " << TesselStruct->TrianglesOnBoundary.size() << " triangles with " << TesselStruct->LinesOnBoundary.size() << " lines and " << TesselStruct->PointsOnBoundary.size() << " points." << endl);
+
+  // 4. Store triangles in tecplot file
+  StoreTrianglesinFile(mol, TesselStruct, filename, "");
+
+  // free reference lists
+  if (BoundaryFreeFlag)
+    delete[] (BoundaryPoints);
+};
+
+/** For testing removes one boundary point after another to check for leaks.
+ * \param *out output stream for debugging
+ * \param *TesselStruct Tesselation containing envelope with boundary points
+ * \param *mol molecule
+ * \param *filename name of file
+ * \return true - all removed, false - something went wrong
+ */
+bool RemoveAllBoundaryPoints(class Tesselation *&TesselStruct, const molecule * const mol, const char * const filename)
+{
+	Info FunctionInfo(__func__);
+  int i=0;
+  char number[MAXSTRINGSIZE];
+
+  if ((TesselStruct == NULL) || (TesselStruct->PointsOnBoundary.empty())) {
+    DoeLog(1) && (eLog()<< Verbose(1) << "TesselStruct is empty." << endl);
+    return false;
+  }
+
+  PointMap::iterator PointRunner;
+  while (!TesselStruct->PointsOnBoundary.empty()) {
+    DoLog(1) && (Log() << Verbose(1) << "Remaining points are: ");
+    for (PointMap::iterator PointSprinter = TesselStruct->PointsOnBoundary.begin(); PointSprinter != TesselStruct->PointsOnBoundary.end(); PointSprinter++)
+      DoLog(0) && (Log() << Verbose(0) << *(PointSprinter->second) << "\t");
+    DoLog(0) && (Log() << Verbose(0) << endl);
+
+    PointRunner = TesselStruct->PointsOnBoundary.begin();
+    // remove point
+    TesselStruct->RemovePointFromTesselatedSurface(PointRunner->second);
+
+    // store envelope
+    sprintf(number, "-%04d", i++);
+    StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, number);
+  }
+
+  return true;
+};
+
+/** Creates a convex envelope from a given non-convex one.
+ * -# First step, remove concave spots, i.e. singular "dents"
+ *   -# We go through all PointsOnBoundary.
+ *   -# We CheckConvexityCriterion() for all its lines.
+ *   -# If all its lines are concave, it cannot be on the convex envelope.
+ *   -# Hence, we remove it and re-create all its triangles from its getCircleOfConnectedPoints()
+ *   -# We calculate the additional volume.
+ *   -# We go over all lines until none yields a concavity anymore.
+ * -# Second step, remove concave lines, i.e. line-shape "dents"
+ *   -# We go through all LinesOnBoundary
+ *   -# We CheckConvexityCriterion()
+ *   -# If it returns concave, we flip the line in this quadrupel of points (abusing the degeneracy of the tesselation)
+ *   -# We CheckConvexityCriterion(),
+ *   -# if it's concave, we continue
+ *   -# if not, we mark an error and stop
+ * Note: This routine - for free - calculates the difference in volume between convex and
+ * non-convex envelope, as the former is easy to calculate - VolumeOfConvexEnvelope() - it
+ * can be used to compute volumes of arbitrary shapes.
+ * \param *out output stream for debugging
+ * \param *TesselStruct non-convex envelope, is changed in return!
+ * \param *mol molecule
+ * \param *filename name of file
+ * \return volume difference between the non- and the created convex envelope
+ */
+double ConvexizeNonconvexEnvelope(class Tesselation *&TesselStruct, const molecule * const mol, const char * const filename)
+{
+	Info FunctionInfo(__func__);
+  double volume = 0;
+  class BoundaryPointSet *point = NULL;
+  class BoundaryLineSet *line = NULL;
+  bool Concavity = false;
+  char dummy[MAXSTRINGSIZE];
+  PointMap::iterator PointRunner;
+  PointMap::iterator PointAdvance;
+  LineMap::iterator LineRunner;
+  LineMap::iterator LineAdvance;
+  TriangleMap::iterator TriangleRunner;
+  TriangleMap::iterator TriangleAdvance;
+  int run = 0;
+
+  // check whether there is something to work on
+  if (TesselStruct == NULL) {
+    DoeLog(1) && (eLog()<< Verbose(1) << "TesselStruct is empty!" << endl);
+    return volume;
+  }
+
+  // First step: RemovePointFromTesselatedSurface
+  do {
+    Concavity = false;
+    sprintf(dummy, "-first-%d", run);
+    //CalculateConcavityPerBoundaryPoint(TesselStruct);
+    StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, dummy);
+
+    PointRunner = TesselStruct->PointsOnBoundary.begin();
+    PointAdvance = PointRunner; // we need an advanced point, as the PointRunner might get removed
+    while (PointRunner != TesselStruct->PointsOnBoundary.end()) {
+      PointAdvance++;
+      point = PointRunner->second;
+      DoLog(1) && (Log() << Verbose(1) << "INFO: Current point is " << *point << "." << endl);
+      for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++) {
+        line = LineRunner->second;
+        DoLog(1) && (Log() << Verbose(1) << "INFO: Current line of point " << *point << " is " << *line << "." << endl);
+        if (!line->CheckConvexityCriterion()) {
+          // remove the point if needed
+          DoLog(1) && (Log() << Verbose(1) << "... point " << *point << " cannot be on convex envelope." << endl);
+          volume += TesselStruct->RemovePointFromTesselatedSurface(point);
+          sprintf(dummy, "-first-%d", ++run);
+          StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, dummy);
+          Concavity = true;
+          break;
+        }
+      }
+      PointRunner = PointAdvance;
+    }
+
+    sprintf(dummy, "-second-%d", run);
+    //CalculateConcavityPerBoundaryPoint(TesselStruct);
+    StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, dummy);
+
+    // second step: PickFarthestofTwoBaselines
+    LineRunner = TesselStruct->LinesOnBoundary.begin();
+    LineAdvance = LineRunner;  // we need an advanced line, as the LineRunner might get removed
+    while (LineRunner != TesselStruct->LinesOnBoundary.end()) {
+      LineAdvance++;
+      line = LineRunner->second;
+      DoLog(1) && (Log() << Verbose(1) << "INFO: Picking farthest baseline for line is " << *line << "." << endl);
+      // take highest of both lines
+      if (TesselStruct->IsConvexRectangle(line) == NULL) {
+        const double tmp = TesselStruct->PickFarthestofTwoBaselines(line);
+        volume += tmp;
+        if (tmp != 0.) {
+          TesselStruct->FlipBaseline(line);
+          Concavity = true;
+        }
+      }
+      LineRunner = LineAdvance;
+    }
+    run++;
+  } while (Concavity);
+  //CalculateConcavityPerBoundaryPoint(TesselStruct);
+  //StoreTrianglesinFile(mol, filename, "-third");
+
+  // third step: IsConvexRectangle
+//  LineRunner = TesselStruct->LinesOnBoundary.begin();
+//  LineAdvance = LineRunner;  // we need an advanced line, as the LineRunner might get removed
+//  while (LineRunner != TesselStruct->LinesOnBoundary.end()) {
+//    LineAdvance++;
+//    line = LineRunner->second;
+//    Log() << Verbose(1) << "INFO: Current line is " << *line << "." << endl;
+//    //if (LineAdvance != TesselStruct->LinesOnBoundary.end())
+//      //Log() << Verbose(1) << "INFO: Next line will be " << *(LineAdvance->second) << "." << endl;
+//    if (!line->CheckConvexityCriterion(out)) {
+//      Log() << Verbose(1) << "... line " << *line << " is concave, flipping it." << endl;
+//
+//      // take highest of both lines
+//      point = TesselStruct->IsConvexRectangle(line);
+//      if (point != NULL)
+//        volume += TesselStruct->RemovePointFromTesselatedSurface(point);
+//    }
+//    LineRunner = LineAdvance;
+//  }
+
+  CalculateConcavityPerBoundaryPoint(TesselStruct);
+  StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, "");
+
+  // end
+  DoLog(0) && (Log() << Verbose(0) << "Volume is " << volume << "." << endl);
+  return volume;
+};
+
+
+/** Determines the volume of a cluster.
+ * Determines first the convex envelope, then tesselates it and calculates its volume.
+ * \param *out output stream for debugging
+ * \param *TesselStruct Tesselation filled with points, lines and triangles on boundary on return
+ * \param *configuration needed for path to store convex envelope file
+ * \return determined volume of the cluster in cubed config:GetIsAngstroem()
+ */
+double VolumeOfConvexEnvelope(class Tesselation *TesselStruct, class config *configuration)
+{
+	Info FunctionInfo(__func__);
+  bool IsAngstroem = configuration->GetIsAngstroem();
+  double volume = 0.;
+  Vector x;
+  Vector y;
+
+  // 6a. Every triangle forms a pyramid with the center of gravity as its peak, sum up the volumes
+  for (TriangleMap::iterator runner = TesselStruct->TrianglesOnBoundary.begin(); runner != TesselStruct->TrianglesOnBoundary.end(); runner++)
+    { // go through every triangle, calculate volume of its pyramid with CoG as peak
+      x = runner->second->getEndpoint(0) - runner->second->getEndpoint(1);
+      y = runner->second->getEndpoint(0) - runner->second->getEndpoint(2);
+      const double a = x.Norm();
+      const double b = y.Norm();
+      const double c = runner->second->getEndpoint(2).distance(runner->second->getEndpoint(1));
+      const double G = sqrt(((a + b + c) * (a + b + c) - 2 * (a * a + b * b + c * c)) / 16.); // area of tesselated triangle
+      x = runner->second->getPlane().getNormal();
+      x.Scale(runner->second->getEndpoint(1).ScalarProduct(x));
+      const double h = x.Norm(); // distance of CoG to triangle
+      const double PyramidVolume = (1. / 3.) * G * h; // this formula holds for _all_ pyramids (independent of n-edge base or (not) centered peak)
+      Log() << Verbose(1) << "Area of triangle is " << setprecision(10) << G << " "
+          << (IsAngstroem ? "angstrom" : "atomiclength") << "^2, height is "
+          << h << " and the volume is " << PyramidVolume << " "
+          << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl;
+      volume += PyramidVolume;
+    }
+  Log() << Verbose(0) << "RESULT: The summed volume is " << setprecision(6)
+      << volume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3."
+      << endl;
+
+  return volume;
+};
+
+/** Stores triangles to file.
+ * \param *out output stream for debugging
+ * \param *mol molecule with atoms and bonds
+ * \param *TesselStruct Tesselation with boundary triangles
+ * \param *filename prefix of filename
+ * \param *extraSuffix intermediate suffix
+ */
+void StoreTrianglesinFile(const molecule * const mol, const Tesselation * const TesselStruct, const char *filename, const char *extraSuffix)
+{
+	Info FunctionInfo(__func__);
+  // 4. Store triangles in tecplot file
+  if (filename != NULL) {
+    if (DoTecplotOutput) {
+      string OutputName(filename);
+      OutputName.append(extraSuffix);
+      OutputName.append(TecplotSuffix);
+      ofstream *tecplot = new ofstream(OutputName.c_str());
+      WriteTecplotFile(tecplot, TesselStruct, mol, -1);
+      tecplot->close();
+      delete(tecplot);
+    }
+    if (DoRaster3DOutput) {
+      string OutputName(filename);
+      OutputName.append(extraSuffix);
+      OutputName.append(Raster3DSuffix);
+      ofstream *rasterplot = new ofstream(OutputName.c_str());
+      WriteRaster3dFile(rasterplot, TesselStruct, mol);
+      rasterplot->close();
+      delete(rasterplot);
+    }
+  }
+};
+
+/** Creates multiples of the by \a *mol given cluster and suspends them in water with a given final density.
+ * We get cluster volume by VolumeOfConvexEnvelope() and its diameters by GetDiametersOfCluster()
+ * TODO: Here, we need a VolumeOfGeneralEnvelope (i.e. non-convex one)
+ * \param *out output stream for debugging
+ * \param *configuration needed for path to store convex envelope file
+ * \param *mol molecule structure representing the cluster
+ * \param *&TesselStruct Tesselation structure with triangles on return
+ * \param ClusterVolume guesstimated cluster volume, if equal 0 we used VolumeOfConvexEnvelope() instead.
+ * \param celldensity desired average density in final cell
+ */
+void PrepareClustersinWater(config *configuration, molecule *mol, double ClusterVolume, double celldensity)
+{
+	Info FunctionInfo(__func__);
+  bool IsAngstroem = true;
+  double *GreatestDiameter = NULL;
+  Boundaries *BoundaryPoints = NULL;
+  class Tesselation *TesselStruct = NULL;
+  Vector BoxLengths;
+  int repetition[NDIM] = { 1, 1, 1 };
+  int TotalNoClusters = 1;
+  double totalmass = 0.;
+  double clustervolume = 0.;
+  double cellvolume = 0.;
+
+  // transform to PAS
+  mol->PrincipalAxisSystem(true);
+
+  IsAngstroem = configuration->GetIsAngstroem();
+  BoundaryPoints = GetBoundaryPoints(mol, TesselStruct);
+  GreatestDiameter = GetDiametersOfCluster(BoundaryPoints, mol, TesselStruct, IsAngstroem);
+  LinkedCell *LCList = new LinkedCell(mol, 10.);
+  FindConvexBorder(mol, BoundaryPoints, TesselStruct, (const LinkedCell *&)LCList, NULL);
+  delete (LCList);
+  delete[] BoundaryPoints;
+
+
+  // some preparations beforehand
+  if (ClusterVolume == 0)
+    clustervolume = VolumeOfConvexEnvelope(TesselStruct, configuration);
+  else
+    clustervolume = ClusterVolume;
+
+  delete TesselStruct;
+
+  for (int i = 0; i < NDIM; i++)
+    TotalNoClusters *= repetition[i];
+
+  // sum up the atomic masses
+  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
+      totalmass += (*iter)->type->mass;
+  }
+  DoLog(0) && (Log() << Verbose(0) << "RESULT: The summed mass is " << setprecision(10) << totalmass << " atomicmassunit." << endl);
+  DoLog(0) && (Log() << Verbose(0) << "RESULT: The average density is " << setprecision(10) << totalmass / clustervolume << " atomicmassunit/" << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl);
+
+  // solve cubic polynomial
+  DoLog(1) && (Log() << Verbose(1) << "Solving equidistant suspension in water problem ..." << endl);
+  if (IsAngstroem)
+    cellvolume = (TotalNoClusters * totalmass / SOLVENTDENSITY_A - (totalmass / clustervolume)) / (celldensity - 1);
+  else
+    cellvolume = (TotalNoClusters * totalmass / SOLVENTDENSITY_a0 - (totalmass / clustervolume)) / (celldensity - 1);
+  DoLog(1) && (Log() << Verbose(1) << "Cellvolume needed for a density of " << celldensity << " g/cm^3 is " << cellvolume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl);
+
+  double minimumvolume = TotalNoClusters * (GreatestDiameter[0] * GreatestDiameter[1] * GreatestDiameter[2]);
+  DoLog(1) && (Log() << Verbose(1) << "Minimum volume of the convex envelope contained in a rectangular box is " << minimumvolume << " atomicmassunit/" << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl);
+  if (minimumvolume > cellvolume) {
+    DoeLog(1) && (eLog()<< Verbose(1) << "the containing box already has a greater volume than the envisaged cell volume!" << endl);
+    DoLog(0) && (Log() << Verbose(0) << "Setting Box dimensions to minimum possible, the greatest diameters." << endl);
+    for (int i = 0; i < NDIM; i++)
+      BoxLengths[i] = GreatestDiameter[i];
+    mol->CenterEdge(&BoxLengths);
+  } else {
+    BoxLengths[0] = (repetition[0] * GreatestDiameter[0] + repetition[1] * GreatestDiameter[1] + repetition[2] * GreatestDiameter[2]);
+    BoxLengths[1] = (repetition[0] * repetition[1] * GreatestDiameter[0] * GreatestDiameter[1] + repetition[0] * repetition[2] * GreatestDiameter[0] * GreatestDiameter[2] + repetition[1] * repetition[2] * GreatestDiameter[1] * GreatestDiameter[2]);
+    BoxLengths[2] = minimumvolume - cellvolume;
+    double x0 = 0.;
+    double x1 = 0.;
+    double x2 = 0.;
+    if (gsl_poly_solve_cubic(BoxLengths[0], BoxLengths[1], BoxLengths[2], &x0, &x1, &x2) == 1) // either 1 or 3 on return
+      DoLog(0) && (Log() << Verbose(0) << "RESULT: The resulting spacing is: " << x0 << " ." << endl);
+    else {
+      DoLog(0) && (Log() << Verbose(0) << "RESULT: The resulting spacings are: " << x0 << " and " << x1 << " and " << x2 << " ." << endl);
+      x0 = x2; // sorted in ascending order
+    }
+
+    cellvolume = 1.;
+    for (int i = 0; i < NDIM; i++) {
+      BoxLengths[i] = repetition[i] * (x0 + GreatestDiameter[i]);
+      cellvolume *= BoxLengths[i];
+    }
+
+    // set new box dimensions
+    DoLog(0) && (Log() << Verbose(0) << "Translating to box with these boundaries." << endl);
+    mol->SetBoxDimension(&BoxLengths);
+    mol->CenterInBox();
+  }
+  delete GreatestDiameter;
+  // update Box of atoms by boundary
+  mol->SetBoxDimension(&BoxLengths);
+  DoLog(0) && (Log() << Verbose(0) << "RESULT: The resulting cell dimensions are: " << BoxLengths[0] << " and " << BoxLengths[1] << " and " << BoxLengths[2] << " with total volume of " << cellvolume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl);
+};
+
+
+/** Fills the empty space of the simulation box with water/
+ * \param *out output stream for debugging
+ * \param *List list of molecules already present in box
+ * \param *TesselStruct contains tesselated surface
+ * \param *filler molecule which the box is to be filled with
+ * \param configuration contains box dimensions
+ * \param MaxDistance fills in molecules only up to this distance (set to -1 if whole of the domain)
+ * \param distance[NDIM] distance between filling molecules in each direction
+ * \param boundary length of boundary zone between molecule and filling mollecules
+ * \param epsilon distance to surface which is not filled
+ * \param RandAtomDisplacement maximum distance for random displacement per atom
+ * \param RandMolDisplacement maximum distance for random displacement per filler molecule
+ * \param DoRandomRotation true - do random rotiations, false - don't
+ * \return *mol pointer to new molecule with filled atoms
+ */
+molecule * FillBoxWithMolecule(MoleculeListClass *List, molecule *filler, config &configuration, const double MaxDistance, const double distance[NDIM], const double boundary, const double RandomAtomDisplacement, const double RandomMolDisplacement, const bool DoRandomRotation)
+{
+	Info FunctionInfo(__func__);
+  molecule *Filling = World::getInstance().createMolecule();
+  Vector CurrentPosition;
+  int N[NDIM];
+  int n[NDIM];
+  double *M =  ReturnFullMatrixforSymmetric(World::getInstance().getDomain());
+  double Rotations[NDIM*NDIM];
+  double *MInverse = InverseMatrix(M);
+  Vector AtomTranslations;
+  Vector FillerTranslations;
+  Vector FillerDistance;
+  Vector Inserter;
+  double FillIt = false;
+  bond *Binder = NULL;
+  double phi[NDIM];
+  map<molecule *, Tesselation *> TesselStruct;
+  map<molecule *, LinkedCell *> LCList;
+
+  for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++)
+    if ((*ListRunner)->getAtomCount() > 0) {
+      DoLog(1) && (Log() << Verbose(1) << "Pre-creating linked cell lists for molecule " << *ListRunner << "." << endl);
+      LCList[(*ListRunner)] = new LinkedCell((*ListRunner), 10.); // get linked cell list
+      DoLog(1) && (Log() << Verbose(1) << "Pre-creating tesselation for molecule " << *ListRunner << "." << endl);
+      TesselStruct[(*ListRunner)] = NULL;
+      FindNonConvexBorder((*ListRunner), TesselStruct[(*ListRunner)], (const LinkedCell *&)LCList[(*ListRunner)], 5., NULL);
+    }
+
+  // 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);
+  for(molecule::iterator AtomRunner = filler->begin(); AtomRunner != filler->end(); ++AtomRunner)
+    for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
+      if ((*BondRunner)->leftatom == *AtomRunner)
+        DoLog(2) && (Log() << Verbose(2) << "  " << *(*BondRunner) << endl);
+
+  atom * CopyAtoms[FillerCount];
+
+  // calculate filler grid in [0,1]^3
+  FillerDistance = Vector(distance[0], distance[1], distance[2]);
+  FillerDistance.InverseMatrixMultiplication(M);
+  for(int i=0;i<NDIM;i++)
+    N[i] = (int) ceil(1./FillerDistance[i]);
+  DoLog(1) && (Log() << Verbose(1) << "INFO: Grid steps are " << N[0] << ", " << N[1] << ", " << N[2] << "." << endl);
+
+  // initialize seed of random number generator to current time
+  srand ( time(NULL) );
+
+  // go over [0,1]^3 filler grid
+  for (n[0] = 0; n[0] < N[0]; n[0]++)
+    for (n[1] = 0; n[1] < N[1]; n[1]++)
+      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);
+        // create molecule random translation vector ...
+        for (int i=0;i<NDIM;i++)
+          FillerTranslations[i] = RandomMolDisplacement*(rand()/(RAND_MAX/2.) - 1.);
+        DoLog(2) && (Log() << Verbose(2) << "INFO: Current Position is " << CurrentPosition << "+" << FillerTranslations << "." << endl);
+
+        // go through all atoms
+        for (int i=0;i<FillerCount;i++)
+          CopyAtoms[i] = NULL;
+        for(molecule::const_iterator iter = filler->begin(); iter !=filler->end();++iter){
+
+          // create atomic random translation vector ...
+          for (int i=0;i<NDIM;i++)
+            AtomTranslations[i] = RandomAtomDisplacement*(rand()/(RAND_MAX/2.) - 1.);
+
+          // ... and rotation matrix
+          if (DoRandomRotation) {
+            for (int i=0;i<NDIM;i++) {
+              phi[i] = rand()/(RAND_MAX/(2.*M_PI));
+            }
+
+            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])                                     ;
+          }
+
+          // ... and put at new position
+          Inserter = (*iter)->x;
+          if (DoRandomRotation)
+            Inserter.MatrixMultiplication(Rotations);
+          Inserter += AtomTranslations + FillerTranslations + CurrentPosition;
+
+          // check whether inserter is inside box
+          Inserter.MatrixMultiplication(MInverse);
+          FillIt = true;
+          for (int i=0;i<NDIM;i++)
+            FillIt = FillIt && (Inserter[i] >= -MYEPSILON) && ((Inserter[i]-1.) <= MYEPSILON);
+          Inserter.MatrixMultiplication(M);
+
+          // Check whether point is in- or outside
+          for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) {
+            // get linked cell list
+            if (TesselStruct[(*ListRunner)] != NULL) {
+              const double distance = (TesselStruct[(*ListRunner)]->GetDistanceToSurface(Inserter, LCList[(*ListRunner)]));
+              FillIt = FillIt && (distance > boundary) && ((MaxDistance < 0) || (MaxDistance > distance));
+            }
+          }
+          // insert into Filling
+          if (FillIt) {
+            DoLog(1) && (Log() << Verbose(1) << "INFO: Position at " << Inserter << " is outer point." << endl);
+            // copy atom ...
+            CopyAtoms[(*iter)->nr] = (*iter)->clone();
+            CopyAtoms[(*iter)->nr]->x = 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);
+          } else {
+            DoLog(1) && (Log() << Verbose(1) << "INFO: Position at " << Inserter << " is inner point, within boundary or outside of MaxDistance." << endl);
+            CopyAtoms[(*iter)->nr] = NULL;
+            continue;
+          }
+        }
+        // go through all bonds and add as well
+        for(molecule::iterator AtomRunner = filler->begin(); AtomRunner != filler->end(); ++AtomRunner)
+          for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
+            if ((*BondRunner)->leftatom == *AtomRunner) {
+              Binder = (*BondRunner);
+              if ((CopyAtoms[Binder->leftatom->nr] != NULL) && (CopyAtoms[Binder->rightatom->nr] != NULL)) {
+                Log()  << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl;
+                Filling->AddBond(CopyAtoms[Binder->leftatom->nr], CopyAtoms[Binder->rightatom->nr], Binder->BondDegree);
+              }
+            }
+      }
+  for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) {
+    delete LCList[*ListRunner];
+    delete TesselStruct[(*ListRunner)];
+  }
+  delete[](M);
+  delete[](MInverse);
+
+  return Filling;
+};
+
+
+/** Tesselates the non convex boundary by rolling a virtual sphere along the surface of the molecule.
+ * \param *out output stream for debugging
+ * \param *mol molecule structure with Atom's and Bond's
+ * \param *&TesselStruct Tesselation filled with points, lines and triangles on boundary on return
+ * \param *&LCList atoms in LinkedCell list
+ * \param RADIUS radius of the virtual sphere
+ * \param *filename filename prefix for output of vertex data
+ * \return true - tesselation successful, false - tesselation failed
+ */
+bool FindNonConvexBorder(const molecule* const mol, Tesselation *&TesselStruct, const LinkedCell *&LCList, const double RADIUS, const char *filename = NULL)
+{
+	Info FunctionInfo(__func__);
+  bool freeLC = false;
+  bool status = false;
+  CandidateForTesselation *baseline = NULL;
+  bool OneLoopWithoutSuccessFlag = true;  // marks whether we went once through all baselines without finding any without two triangles
+  bool TesselationFailFlag = false;
+
+  mol->getAtomCount();
+
+  if (TesselStruct == NULL) {
+    DoLog(1) && (Log() << Verbose(1) << "Allocating Tesselation struct ..." << endl);
+    TesselStruct= new Tesselation;
+  } else {
+    delete(TesselStruct);
+    DoLog(1) && (Log() << Verbose(1) << "Re-Allocating Tesselation struct ..." << endl);
+    TesselStruct = new Tesselation;
+  }
+
+  // initialise Linked Cell
+  if (LCList == NULL) {
+    LCList = new LinkedCell(mol, 2.*RADIUS);
+    freeLC = true;
+  }
+
+  // 1. get starting triangle
+  if (!TesselStruct->FindStartingTriangle(RADIUS, LCList)) {
+    DoeLog(0) && (eLog() << Verbose(0) << "No valid starting triangle found." << endl);
+    //performCriticalExit();
+  }
+  if (filename != NULL) {
+    if ((DoSingleStepOutput && ((TesselStruct->TrianglesOnBoundary.size() % SingleStepWidth == 0)))) { // if we have a new triangle and want to output each new triangle configuration
+      TesselStruct->Output(filename, mol);
+    }
+  }
+
+  // 2. expand from there
+  while ((!TesselStruct->OpenLines.empty()) && (OneLoopWithoutSuccessFlag)) {
+    (cerr << "There are " <<  TesselStruct->TrianglesOnBoundary.size() << " triangles and " << TesselStruct->OpenLines.size() << " open lines to scan for candidates." << endl);
+    // 2a. print OpenLines without candidates
+    DoLog(1) && (Log() << Verbose(1) << "There are the following open lines to scan for a candidates:" << endl);
+    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++)
+      if (Runner->second->pointlist.empty())
+        DoLog(1) && (Log() << Verbose(1) << " " << *(Runner->second) << endl);
+
+    // 2b. find best candidate for each OpenLine
+    TesselationFailFlag = TesselStruct->FindCandidatesforOpenLines(RADIUS, LCList);
+
+    // 2c. print OpenLines with candidates again
+    DoLog(1) && (Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for the best candidates:" << endl);
+    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++)
+      DoLog(1) && (Log() << Verbose(1) << " " << *(Runner->second) << endl);
+
+    // 2d. search for smallest ShortestAngle among all candidates
+    double ShortestAngle = 4.*M_PI;
+    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) {
+      if (Runner->second->ShortestAngle < ShortestAngle) {
+        baseline = Runner->second;
+        ShortestAngle = baseline->ShortestAngle;
+        DoLog(1) && (Log() << Verbose(1) << "New best candidate is " << *baseline->BaseLine << " with point " << *(*baseline->pointlist.begin()) << " and angle " << baseline->ShortestAngle << endl);
+      }
+    }
+    // 2e. if we found one, add candidate
+    if ((ShortestAngle == 4.*M_PI) || (baseline->pointlist.empty()))
+      OneLoopWithoutSuccessFlag = false;
+    else {
+      TesselStruct->AddCandidatePolygon(*baseline, RADIUS, LCList);
+    }
+
+    // 2f. write temporary envelope
+    if (filename != NULL) {
+      if ((DoSingleStepOutput && ((TesselStruct->TrianglesOnBoundary.size() % SingleStepWidth == 0)))) { // if we have a new triangle and want to output each new triangle configuration
+        TesselStruct->Output(filename, mol);
+      }
+    }
+  }
+//  // check envelope for consistency
+//  status = CheckListOfBaselines(TesselStruct);
+//
+//  // look whether all points are inside of the convex envelope, otherwise add them via degenerated triangles
+//  //->InsertStraddlingPoints(mol, LCList);
+//  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
+//  class TesselPoint *Runner = NULL;
+//    Runner = *iter;
+//    Log() << Verbose(1) << "Checking on " << Runner->Name << " ... " << endl;
+//    if (!->IsInnerPoint(Runner, LCList)) {
+//      Log() << Verbose(2) << Runner->Name << " is outside of envelope, adding via degenerated triangles." << endl;
+//      ->AddBoundaryPointByDegeneratedTriangle(Runner, LCList);
+//    } else {
+//      Log() << Verbose(2) << Runner->Name << " is inside of or on envelope." << endl;
+//    }
+//  }
+
+//  // Purges surplus triangles.
+//  TesselStruct->RemoveDegeneratedTriangles();
+//
+//  // check envelope for consistency
+//  status = CheckListOfBaselines(TesselStruct);
+
+  cout << "before correction" << endl;
+
+  // store before correction
+  StoreTrianglesinFile(mol, TesselStruct, filename, "");
+
+//  // correct degenerated polygons
+//  TesselStruct->CorrectAllDegeneratedPolygons();
+//
+//  // check envelope for consistency
+//  status = CheckListOfBaselines(TesselStruct);
+
+  // write final envelope
+  CalculateConcavityPerBoundaryPoint(TesselStruct);
+  cout << "after correction" << endl;
+  StoreTrianglesinFile(mol, TesselStruct, filename, "");
+
+  if (freeLC)
+    delete(LCList);
+
+  return status;
+};
+
+
+/** Finds a hole of sufficient size in \a *mols to embed \a *srcmol into it.
+ * \param *out output stream for debugging
+ * \param *mols molecules in the domain to embed in between
+ * \param *srcmol embedding molecule
+ * \return *Vector new center of \a *srcmol for embedding relative to \a this
+ */
+Vector* FindEmbeddingHole(MoleculeListClass *mols, molecule *srcmol)
+{
+	Info FunctionInfo(__func__);
+  Vector *Center = new Vector;
+  Center->Zero();
+  // calculate volume/shape of \a *srcmol
+
+  // find embedding holes
+
+  // if more than one, let user choose
+
+  // return embedding center
+  return Center;
+};
+
Index: src/boundary.hpp
===================================================================
--- src/boundary.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/boundary.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,64 @@
+#ifndef BOUNDARY_HPP_
+#define BOUNDARY_HPP_
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <fstream>
+#include <iostream>
+
+// STL headers
+#include <map>
+
+#include "defs.hpp"
+
+/****************************************** forward declarations *****************************/
+
+class atom;
+class BoundaryPointSet;
+class BoundaryLineSet;
+class BoundaryTriangleSet;
+class config;
+class LinkedCell;
+class molecule;
+class MoleculeListClass;
+class Tesselation;
+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>
+
+/********************************************** declarations *******************************/
+
+double ConvexizeNonconvexEnvelope(class Tesselation *&TesselStruct, const molecule * const mol, const char * const filename);
+molecule * FillBoxWithMolecule(MoleculeListClass *List, molecule *filler, config &configuration, const double MaxDistance, const double distance[NDIM], const double boundary, const double RandomAtomDisplacement, const double RandomMolDisplacement, const bool DoRandomRotation);
+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);
+double * GetDiametersOfCluster(const Boundaries *BoundaryPtr, const molecule *mol, Tesselation *&TesselStruct, const bool IsAngstroem);
+void PrepareClustersinWater(config *configuration, molecule *mol, double ClusterVolume, double celldensity);
+bool RemoveAllBoundaryPoints(class Tesselation *&TesselStruct, const molecule * const mol, const char * const filename);
+void StoreTrianglesinFile(const molecule * const mol, const Tesselation * const TesselStruct, const char *filename, const char *extraSuffix);
+double VolumeOfConvexEnvelope(class Tesselation *TesselStruct, class config *configuration);
+
+
+#endif /*BOUNDARY_HPP_*/
Index: src/builder.cpp
===================================================================
--- src/builder.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/builder.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,192 @@
+/** \file builder.cpp
+ *
+ *  date: Jan 1, 2007
+ *  author: heber
+ *
+ */
+
+/*! \mainpage MoleCuilder - a molecular set builder
+ *
+ * This introductory shall briefly make acquainted with the program, helping in installing and a first run.
+ *
+ * \section about About the Program
+ *
+ *  MoleCuilder is a program, written entirely in C++, that enables the construction of a coordinate set for the
+ *  atoms making up an molecule. It allows for both building of simple molecules by adding atom-wise giving bond
+ *  angles and distances or absolute coordinates, but also using them as templates. Regions can be specified and
+ *  ordered to be filled with a molecule in a certain manner. Greater conglomerations of molecules can be tesselated
+ *  and recognized as a region themselves to be subsequently surrounded by other (surface solvated) molecules.
+ *  In the end, MoleCuilder allows the construction of arbitrary nano structures, whether they be crystalline or
+ *  amorphic in nature.
+ *
+ *
+ * \section install Installation
+ *
+ *  Installation should without problems succeed as follows:
+ *  -# ./configure (or: mkdir build;mkdir run;cd build; ../configure --bindir=../run)
+ *  -# make
+ *  -# make install
+ *
+ *  Further useful commands are
+ *  -# make clean uninstall: deletes .o-files and removes executable from the given binary directory\n
+ *  -# make doxygen-doc: Creates these html pages out of the documented source
+ *  -# make check: Runs an extensive set of unit tests and a testsuite which also gives a good overview on the set of
+ *                 functions.
+ *
+ * \section run Running
+ *
+ *  The program can be executed by running: ./molecuilder
+ *
+ *  MoleCuilder has three interfaces at your disposal:
+ *  -# Textmenu: A simple interactive console-based menu, where awaits your choices and inputs in order to set atoms
+ *               as you like
+ *  -# CommandLineUI: Every command can also be chained up as a sequence of actions on the command line to be executed
+ *               with any user interaction.
+ *  -# GraphicalUI: A graphical user interface that also display the molecular structure being built and lots of other
+ *               informations to ease the construction of bigger geometries.
+ *
+ *  The supported output formats right now are:
+ *  -# mpqc: Configuration files of the Massively Parallel Quantum Chemistry package (Sandia labs)
+ *  -# pcp: Configuration files of the Parallel Car-Parrinello program (Institute for Numerical Simulation)
+ *  -# tremolo: Configuration files of TREMOLO (Institute for Numerical Simulation)
+ *  -# xyz: the most basic format for the 3d arrangement of atoms consisting of a list of element and 3 coordinates.
+ *
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "bondgraph.hpp"
+#include "CommandLineParser.hpp"
+#include "config.hpp"
+#include "log.hpp"
+#include "memoryusageobserver.hpp"
+#include "molecule.hpp"
+#include "periodentafel.hpp"
+#include "tesselationhelpers.hpp"
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/TextUI/TextUIFactory.hpp"
+#include "UIElements/CommandLineUI/CommandLineUIFactory.hpp"
+#ifdef USE_GUI_QT
+#include "UIElements/QT4/QTUIFactory.hpp"
+#endif
+#include "UIElements/MainWindow.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Menu/ActionMenuItem.hpp"
+#include "verbose.hpp"
+#include "World.hpp"
+
+#include "Actions/ActionRegistry.hpp"
+#include "Actions/ActionHistory.hpp"
+#include "Actions/MapOfActions.hpp"
+
+#include "Parser/ChangeTracker.hpp"
+#include "Parser/FormatParserStorage.hpp"
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/TextUI/TextUIFactory.hpp"
+#include "UIElements/CommandLineUI/CommandLineUIFactory.hpp"
+#include "UIElements/MainWindow.hpp"
+#include "UIElements/Dialog.hpp"
+
+#include "version.h"
+
+
+/********************************************** Main routine **************************************/
+
+void cleanUp(){
+  FormatParserStorage::purgeInstance();
+  ChangeTracker::purgeInstance();
+  World::purgeInstance();
+  logger::purgeInstance();
+  errorLogger::purgeInstance();
+  UIFactory::purgeInstance();
+  MapOfActions::purgeInstance();
+  CommandLineParser::purgeInstance();
+  ActionRegistry::purgeInstance();
+  ActionHistory::purgeInstance();
+#ifdef LOG_OBSERVER
+  cout << observerLog().getLog();
+#endif
+  Memory::getState();
+}
+
+int main(int argc, char **argv)
+{
+  // while we are non interactive, we want to abort from asserts
+  //ASSERT_DO(Assert::Abort);
+  string line;
+  char **Arguments = NULL;
+  int ArgcSize = 0;
+  int ExitFlag = 0;
+  bool ArgumentsCopied = false;
+  std::string BondGraphFileName("\n");
+
+  // print version check whether arguments are present at all
+  cout << ESPACKVersion << endl;
+
+  setVerbosity(0);
+  // 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
+  // this is handled by the cleanup function
+  atexit(cleanUp);
+
+  // Parse command line options and if present create respective UI
+  {
+    // construct bond graph
+    if (World::getInstance().getConfig()->BG == NULL) {
+      World::getInstance().getConfig()->BG = new BondGraph(World::getInstance().getConfig()->GetIsAngstroem());
+      if (World::getInstance().getConfig()->BG->LoadBondLengthTable(BondGraphFileName)) {
+        DoLog(0) && (Log() << Verbose(0) << "Bond length table loaded successfully." << endl);
+      } else {
+        DoeLog(1) && (eLog()<< Verbose(1) << "Bond length table loading failed." << endl);
+      }
+    }
+    // handle remaining arguments by CommandLineParser
+    if (argc>1) {
+      MapOfActions::getInstance().AddOptionsToParser();
+      map <std::string, std::string> ShortFormToActionMap = MapOfActions::getInstance().getShortFormToActionMap();
+      CommandLineParser::getInstance().Run(argc,argv, ShortFormToActionMap);
+      DoLog(0) && (Log() << Verbose(0) << "Setting UI to CommandLine." << endl);
+      UIFactory::registerFactory(new CommandLineUIFactory::description());
+      UIFactory::makeUserInterface("CommandLine");
+    } else {
+      #ifdef USE_GUI_QT
+        DoLog(0) && (Log() << Verbose(0) << "Setting UI to QT4." << endl);
+        UIFactory::registerFactory(new QTUIFactory::description());
+        UIFactory::makeUserInterface("QT4");
+      #else
+        DoLog(0) && (Log() << Verbose(0) << "Setting UI to Text." << endl);
+        cout << ESPACKVersion << endl;
+        UIFactory::registerFactory(new TextUIFactory::description());
+        UIFactory::makeUserInterface("Text");
+      #endif
+    }
+  }
+
+  {
+    MainWindow *mainWindow = UIFactory::getInstance().makeMainWindow();
+    mainWindow->display();
+    delete mainWindow;
+  }
+
+  FormatParserStorage::getInstance().SaveAll();
+  ChangeTracker::getInstance().saveStatus();
+
+  // free the new argv
+  if (ArgumentsCopied) {
+    for (int i=0; i<ArgcSize;i++)
+      delete[](Arguments[i]);
+    delete[](Arguments);
+  }
+  //delete[](ConfigFileName);
+
+  ExitFlag = World::getInstance().getExitFlag();
+  return (ExitFlag == 1 ? 0 : ExitFlag);
+}
+
+/********************************************** E N D **************************************************/
Index: src/config.cpp
===================================================================
--- src/config.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/config.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,2121 @@
+/** \file config.cpp
+ *
+ * Function implementations for the class config.
+ *
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include <stdio.h>
+#include <cstring>
+
+#include "atom.hpp"
+#include "bond.hpp"
+#include "bondgraph.hpp"
+#include "config.hpp"
+#include "ConfigFileBuffer.hpp"
+#include "element.hpp"
+#include "helpers.hpp"
+#include "info.hpp"
+#include "lists.hpp"
+#include "log.hpp"
+#include "molecule.hpp"
+#include "memoryallocator.hpp"
+#include "molecule.hpp"
+#include "periodentafel.hpp"
+#include "ThermoStatContainer.hpp"
+#include "World.hpp"
+
+/************************************* Functions for class config ***************************/
+
+/** 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) {
+  mainname = new char[MAXSTRINGSIZE];
+  defaultpath = new char[MAXSTRINGSIZE];
+  pseudopotpath = new char[MAXSTRINGSIZE];
+  databasepath = new char[MAXSTRINGSIZE];
+  configname = new char[MAXSTRINGSIZE];
+  Thermostats = new ThermoStatContainer();
+  strcpy(mainname,"pcp");
+  strcpy(defaultpath,"not specified");
+  strcpy(pseudopotpath,"not specified");
+  configname[0]='\0';
+  basis = "3-21G";
+};
+
+/** Destructor for config file class.
+ */
+config::~config()
+{
+  delete[](mainname);
+  delete[](defaultpath);
+  delete[](pseudopotpath);
+  delete[](databasepath);
+  delete[](configname);
+  if (Thermostats != NULL)
+    delete(Thermostats);
+
+  if (BG != NULL)
+    delete(BG);
+};
+
+/** Displays menu for editing each entry of the config file.
+ * Nothing fancy here, just lots of Log() << Verbose(0)s for the menu and a switch/case
+ * for each entry of the config file structure.
+ */
+void config::Edit()
+{
+  char choice;
+
+  do {
+    DoLog(0) && (Log() << Verbose(0) << "===========EDIT CONFIGURATION============================" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " A - mainname (prefix for all runtime files)" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " B - Default path (for runtime files)" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " C - Path of pseudopotential files" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " D - Number of coefficient sharing processes" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " E - Number of wave function sharing processes" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " F - 0: Don't output density for OpenDX, 1: do" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " G - 0: Don't output physical data, 1: do" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " H - 0: Don't output densities of each unperturbed orbital for OpenDX, 1: do" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " I - 0: Don't output current density for OpenDX, 1: do" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " J - 0: Don't do the full current calculation, 1: do" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " K - 0: Don't do perturbation calculation to obtain susceptibility and shielding, 1: do" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " L - 0: Wannier centres as calculated, 1: common centre for all, 2: unite centres according to spread, 3: cell centre, 4: shifted to nearest grid point" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " M - Absolute begin of unphysical sawtooth transfer for position operator within cell" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " N - (0,1,2) x,y,z-plane to do two-dimensional current vector cut" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " O - Absolute position along vector cut axis for cut plane" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " P - Additional Gram-Schmidt-Orthonormalization to stabilize numerics" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " Q - Initial integer value of random number generator" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " R - for perturbation 0, for structure optimization defines upper limit of iterations" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " T - Output visual after ...th step" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " U - Output source densities of wave functions after ...th step" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " X - minimization iterations per wave function, if unsure leave at default value 0" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " Y - tolerance value for total spread in iterative Jacobi diagonalization" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " Z - Maximum number of minimization iterations" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " a - Relative change in total energy to stop min. iteration" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " b - Relative change in kinetic energy to stop min. iteration" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " c - Check stop conditions every ..th step during min. iteration" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " e - Maximum number of minimization iterations during initial level" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " f - Relative change in total energy to stop min. iteration during initial level" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " g - Relative change in kinetic energy to stop min. iteration during initial level" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " h - Check stop conditions every ..th step during min. iteration during initial level" << endl);
+//    Log() << Verbose(0) << " j - six lower diagonal entries of matrix, defining the unit cell" << endl;
+    DoLog(0) && (Log() << Verbose(0) << " k - Energy cutoff of plane wave basis in Hartree" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " l - Maximum number of levels in multi-level-ansatz" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " m - Factor by which grid nodes increase between standard and upper level" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " n - 0: Don't use RiemannTensor, 1: Do" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " o - Factor by which grid nodes increase between Riemann and standard(?) level" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " p - Number of Riemann levels" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " r - 0: Don't Use RiemannTensor, 1: Do" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " s - 0: Doubly occupied orbitals, 1: Up-/Down-Orbitals" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " t - Number of orbitals (depends pn SpinType)" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " u - Number of SpinUp orbitals (depends on SpinType)" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " v - Number of SpinDown orbitals (depends on SpinType)" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " w - Number of additional, unoccupied orbitals" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " x - radial cutoff for ewald summation in Bohrradii" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " y - 0: Don't do structure optimization beforehand, 1: Do" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " z - 0: Units are in Bohr radii, 1: units are in Aengstrom" << endl);
+    DoLog(0) && (Log() << Verbose(0) << " i - 0: Coordinates given in file are absolute, 1: ... are relative to unit cell" << endl);
+    DoLog(0) && (Log() << Verbose(0) << "=========================================================" << endl);
+    DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
+    cin >> choice;
+
+    switch (choice) {
+        case 'A': // mainname
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::mainname << "\t new: ");
+          cin >> config::mainname;
+          break;
+        case 'B': // defaultpath
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::defaultpath << "\t new: ");
+          cin >> config::defaultpath;
+          break;
+        case 'C': // pseudopotpath
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::pseudopotpath << "\t new: ");
+          cin >> config::pseudopotpath;
+          break;
+
+        case 'D': // ProcPEGamma
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::ProcPEGamma << "\t new: ");
+          cin >> config::ProcPEGamma;
+          break;
+        case 'E': // ProcPEPsi
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::ProcPEPsi << "\t new: ");
+          cin >> config::ProcPEPsi;
+          break;
+        case 'F': // DoOutVis
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::DoOutVis << "\t new: ");
+          cin >> config::DoOutVis;
+          break;
+        case 'G': // DoOutMes
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::DoOutMes << "\t new: ");
+          cin >> config::DoOutMes;
+          break;
+        case 'H': // DoOutOrbitals
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::DoOutOrbitals << "\t new: ");
+          cin >> config::DoOutOrbitals;
+          break;
+        case 'I': // DoOutCurrent
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::DoOutCurrent << "\t new: ");
+          cin >> config::DoOutCurrent;
+          break;
+        case 'J': // DoFullCurrent
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::DoFullCurrent << "\t new: ");
+          cin >> config::DoFullCurrent;
+          break;
+        case 'K': // DoPerturbation
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::DoPerturbation << "\t new: ");
+          cin >> config::DoPerturbation;
+          break;
+        case 'L': // CommonWannier
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::CommonWannier << "\t new: ");
+          cin >> config::CommonWannier;
+          break;
+        case 'M': // SawtoothStart
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::SawtoothStart << "\t new: ");
+          cin >> config::SawtoothStart;
+          break;
+        case 'N': // VectorPlane
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::VectorPlane << "\t new: ");
+          cin >> config::VectorPlane;
+          break;
+        case 'O': // VectorCut
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::VectorCut << "\t new: ");
+          cin >> config::VectorCut;
+          break;
+        case 'P': // UseAddGramSch
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::UseAddGramSch << "\t new: ");
+          cin >> config::UseAddGramSch;
+          break;
+        case 'Q': // Seed
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::Seed << "\t new: ");
+          cin >> config::Seed;
+          break;
+
+        case 'R': // MaxOuterStep
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::MaxOuterStep << "\t new: ");
+          cin >> config::MaxOuterStep;
+          break;
+        case 'T': // OutVisStep
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::OutVisStep << "\t new: ");
+          cin >> config::OutVisStep;
+          break;
+        case 'U': // OutSrcStep
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::OutSrcStep << "\t new: ");
+          cin >> config::OutSrcStep;
+          break;
+        case 'X': // MaxPsiStep
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::MaxPsiStep << "\t new: ");
+          cin >> config::MaxPsiStep;
+          break;
+        case 'Y': // EpsWannier
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::EpsWannier << "\t new: ");
+          cin >> config::EpsWannier;
+          break;
+
+        case 'Z': // MaxMinStep
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::MaxMinStep << "\t new: ");
+          cin >> config::MaxMinStep;
+          break;
+        case 'a': // RelEpsTotalEnergy
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::RelEpsTotalEnergy << "\t new: ");
+          cin >> config::RelEpsTotalEnergy;
+          break;
+        case 'b': // RelEpsKineticEnergy
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::RelEpsKineticEnergy << "\t new: ");
+          cin >> config::RelEpsKineticEnergy;
+          break;
+        case 'c': // MaxMinStopStep
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::MaxMinStopStep << "\t new: ");
+          cin >> config::MaxMinStopStep;
+          break;
+        case 'e': // MaxInitMinStep
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::MaxInitMinStep << "\t new: ");
+          cin >> config::MaxInitMinStep;
+          break;
+        case 'f': // InitRelEpsTotalEnergy
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::InitRelEpsTotalEnergy << "\t new: ");
+          cin >> config::InitRelEpsTotalEnergy;
+          break;
+        case 'g': // InitRelEpsKineticEnergy
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::InitRelEpsKineticEnergy << "\t new: ");
+          cin >> config::InitRelEpsKineticEnergy;
+          break;
+        case 'h': // InitMaxMinStopStep
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::InitMaxMinStopStep << "\t new: ");
+          cin >> config::InitMaxMinStopStep;
+          break;
+
+//        case 'j': // BoxLength
+//          Log() << Verbose(0) << "enter lower triadiagonalo form of basis matrix" << endl << endl;
+//          double * const cell_size = World::getInstance().getDomain();
+//          for (int i=0;i<6;i++) {
+//            Log() << Verbose(0) << "Cell size" << i << ": ";
+//            cin >> cell_size[i];
+//          }
+//          break;
+
+        case 'k': // ECut
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::ECut << "\t new: ");
+          cin >> config::ECut;
+          break;
+        case 'l': // MaxLevel
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::MaxLevel << "\t new: ");
+          cin >> config::MaxLevel;
+          break;
+        case 'm': // RiemannTensor
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::RiemannTensor << "\t new: ");
+          cin >> config::RiemannTensor;
+          break;
+        case 'n': // LevRFactor
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::LevRFactor << "\t new: ");
+          cin >> config::LevRFactor;
+          break;
+        case 'o': // RiemannLevel
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::RiemannLevel << "\t new: ");
+          cin >> config::RiemannLevel;
+          break;
+        case 'p': // Lev0Factor
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::Lev0Factor << "\t new: ");
+          cin >> config::Lev0Factor;
+          break;
+        case 'r': // RTActualUse
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::RTActualUse << "\t new: ");
+          cin >> config::RTActualUse;
+          break;
+        case 's': // PsiType
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::PsiType << "\t new: ");
+          cin >> config::PsiType;
+          break;
+        case 't': // MaxPsiDouble
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::MaxPsiDouble << "\t new: ");
+          cin >> config::MaxPsiDouble;
+          break;
+        case 'u': // PsiMaxNoUp
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::PsiMaxNoUp << "\t new: ");
+          cin >> config::PsiMaxNoUp;
+          break;
+        case 'v': // PsiMaxNoDown
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::PsiMaxNoDown << "\t new: ");
+          cin >> config::PsiMaxNoDown;
+          break;
+        case 'w': // AddPsis
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::AddPsis << "\t new: ");
+          cin >> config::AddPsis;
+          break;
+
+        case 'x': // RCut
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::RCut << "\t new: ");
+          cin >> config::RCut;
+          break;
+        case 'y': // StructOpt
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::StructOpt << "\t new: ");
+          cin >> config::StructOpt;
+          break;
+        case 'z': // IsAngstroem
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::IsAngstroem << "\t new: ");
+          cin >> config::IsAngstroem;
+          break;
+        case 'i': // RelativeCoord
+          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::RelativeCoord << "\t new: ");
+          cin >> config::RelativeCoord;
+          break;
+    };
+  } while (choice != 'q');
+};
+
+/** Tests whether a given configuration file adhears to old or new syntax.
+ * \param *filename filename of config file to be tested
+ * \param *periode pointer to a periodentafel class with all elements
+ * \return 0 - old syntax, 1 - new syntax, -1 - unknown syntax
+ */
+int config::TestSyntax(const char * const filename, const periodentafel * const periode) const
+{
+  int test;
+  ifstream file(filename);
+
+  // search file for keyword: ProcPEGamma (new syntax)
+  if (ParseForParameter(1,&file,"ProcPEGamma", 0, 1, 1, int_type, &test, 1, optional)) {
+    file.close();
+    return 1;
+  }
+  // search file for keyword: ProcsGammaPsi (old syntax)
+  if (ParseForParameter(1,&file,"ProcsGammaPsi", 0, 1, 1, int_type, &test, 1, optional)) {
+    file.close();
+    return 0;
+  }
+  file.close();
+  return -1;
+}
+
+/** Returns private config::IsAngstroem.
+ * \return IsAngstroem
+ */
+bool config::GetIsAngstroem() const
+{
+  return (IsAngstroem == 1);
+};
+
+/** Returns private config::*defaultpath.
+ * \return *defaultpath
+ */
+char * config::GetDefaultPath() const
+{
+  return defaultpath;
+};
+
+
+/** Returns private config::*defaultpath.
+ * \return *defaultpath
+ */
+void config::SetDefaultPath(const char * const path)
+{
+  strcpy(defaultpath, path);
+};
+
+/** Loads a molecule from a ConfigFileBuffer.
+ * \param *mol molecule to load
+ * \param *FileBuffer ConfigFileBuffer to use
+ * \param *periode periodentafel for finding elements
+ * \param FastParsing whether to parse trajectories or not
+ */
+void LoadMolecule(molecule * const &mol, struct ConfigFileBuffer * const &FileBuffer, const periodentafel * const periode, const bool FastParsing)
+{
+  int MaxTypes = 0;
+  const element *elementhash[MAX_ELEMENTS];
+  char name[MAX_ELEMENTS];
+  char keyword[MAX_ELEMENTS];
+  int Z = -1;
+  int No[MAX_ELEMENTS];
+  int verbose = 0;
+  double value[3];
+
+  if (mol == NULL) {
+    DoeLog(0) && (eLog()<< Verbose(0) << "Molecule is not allocated in LoadMolecule(), exit.");
+    performCriticalExit();
+  }
+
+  ParseForParameter(verbose,FileBuffer,"MaxTypes", 0, 1, 1, int_type, &(MaxTypes), 1, critical);
+  if (MaxTypes == 0) {
+    DoeLog(1) && (eLog()<< Verbose(1) << "There are no atoms according to MaxTypes in this config file." << endl);
+    //performCriticalExit();
+  } else {
+    // prescan number of ions per type
+    DoLog(0) && (Log() << Verbose(0) << "Prescanning ions per type: " << endl);
+    int NoAtoms = 0;
+    for (int i=0; i < MaxTypes; i++) {
+      sprintf(name,"Ion_Type%i",i+1);
+      ParseForParameter(verbose,FileBuffer, (const char*)name, 0, 1, 1, int_type, &No[i], 1, critical);
+      ParseForParameter(verbose,FileBuffer, name, 0, 2, 1, int_type, &Z, 1, critical);
+      elementhash[i] = periode->FindElement(Z);
+      DoLog(1) && (Log() << Verbose(1) << i << ". Z = " << elementhash[i]->Z << " with " << No[i] << " ions." << endl);
+      NoAtoms += No[i];
+    }
+    int repetition = 0; // which repeated keyword shall be read
+
+    // sort the lines via the LineMapping
+    sprintf(name,"Ion_Type%i",MaxTypes);
+    if (!ParseForParameter(verbose,FileBuffer, (const char*)name, 1, 1, 1, int_type, &value[0], 1, critical)) {
+      DoeLog(0) && (eLog()<< Verbose(0) << "There are no atoms in the config file!" << endl);
+      performCriticalExit();
+      return;
+    }
+    FileBuffer->CurrentLine++;
+    //Log() << Verbose(0) << FileBuffer->buffer[ FileBuffer->LineMapping[FileBuffer->CurrentLine]];
+    FileBuffer->MapIonTypesInBuffer(NoAtoms);
+    //for (int i=0; i<(NoAtoms < 100 ? NoAtoms : 100 < 100 ? NoAtoms : 100);++i) {
+    //  Log() << Verbose(0) << FileBuffer->buffer[ FileBuffer->LineMapping[FileBuffer->CurrentLine+i]];
+    //}
+
+    map<int, atom *> AtomList[MaxTypes];
+    map<int, atom *> LinearList;
+    atom *neues = NULL;
+    if (!FastParsing) {
+      // parse in trajectories
+      bool status = true;
+      while (status) {
+        DoLog(0) && (Log() << Verbose(0) << "Currently parsing MD step " << repetition << "." << endl);
+        for (int i=0; i < MaxTypes; i++) {
+          sprintf(name,"Ion_Type%i",i+1);
+          for(int j=0;j<No[i];j++) {
+            sprintf(keyword,"%s_%i",name, j+1);
+            if (repetition == 0) {
+              neues = World::getInstance().createAtom();
+              AtomList[i][j] = neues;
+              LinearList[ FileBuffer->LineMapping[FileBuffer->CurrentLine] ] = neues;
+              neues->type = 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, 4, 1, int_type, &neues->FixedIon, 1, (repetition == 0) ? critical : optional));
+            if (!status) break;
+
+            // check size of vectors
+            if (neues->Trajectory.R.size() <= (unsigned int)(repetition)) {
+              //Log() << Verbose(0) << "Increasing size for trajectory array of " << keyword << " to " << (repetition+10) << "." << endl;
+              neues->Trajectory.R.resize(repetition+10);
+              neues->Trajectory.U.resize(repetition+10);
+              neues->Trajectory.F.resize(repetition+10);
+            }
+
+            // put into trajectories list
+            for (int d=0;d<NDIM;d++)
+              neues->Trajectory.R.at(repetition)[d] = neues->x[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.;
+            for (int d=0;d<NDIM;d++)
+              neues->Trajectory.U.at(repetition)[d] = neues->v[d];
+
+            // parse forces if present
+            if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 8, 1, double_type, &value[0], 1,optional))
+              value[0] = 0.;
+            if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 9, 1, double_type, &value[1], 1,optional))
+              value[1] = 0.;
+            if(!ParseForParameter(verbose,FileBuffer, keyword, 1, 10, 1, double_type, &value[2], 1,optional))
+              value[2] = 0.;
+            for (int d=0;d<NDIM;d++)
+              neues->Trajectory.F.at(repetition)[d] = value[d];
+
+  //            Log() << Verbose(0) << "Parsed position of step " << (repetition) << ": (";
+  //            for (int d=0;d<NDIM;d++)
+  //              Log() << Verbose(0) << neues->Trajectory.R.at(repetition).x[d] << " ";          // next step
+  //            Log() << Verbose(0) << ")\t(";
+  //            for (int d=0;d<NDIM;d++)
+  //              Log() << Verbose(0) << neues->Trajectory.U.at(repetition).x[d] << " ";          // next step
+  //            Log() << Verbose(0) << ")\t(";
+  //            for (int d=0;d<NDIM;d++)
+  //              Log() << Verbose(0) << neues->Trajectory.F.at(repetition).x[d] << " ";          // next step
+  //            Log() << Verbose(0) << ")" << endl;
+          }
+        }
+        repetition++;
+      }
+      repetition--;
+      DoLog(0) && (Log() << Verbose(0) << "Found " << repetition << " trajectory steps." << endl);
+      if (repetition <= 1)  // if onyl one step, desactivate use of trajectories
+        mol->MDSteps = 0;
+      else
+        mol->MDSteps = repetition;
+    } else {
+      // find the maximum number of MD steps so that we may parse last one (Ion_Type1_1 must always be present, because is the first atom)
+      repetition = 0;
+      while ( ParseForParameter(verbose,FileBuffer, "Ion_Type1_1", 0, 1, 1, double_type, &value[0], repetition, (repetition == 0) ? critical : optional) &&
+              ParseForParameter(verbose,FileBuffer, "Ion_Type1_1", 0, 2, 1, double_type, &value[1], repetition, (repetition == 0) ? critical : optional) &&
+              ParseForParameter(verbose,FileBuffer, "Ion_Type1_1", 0, 3, 1, double_type, &value[2], repetition, (repetition == 0) ? critical : optional))
+        repetition++;
+      DoLog(0) && (Log() << Verbose(0) << "I found " << repetition << " times the keyword Ion_Type1_1." << endl);
+      // parse in molecule coordinates
+      for (int i=0; i < MaxTypes; i++) {
+        sprintf(name,"Ion_Type%i",i+1);
+        for(int j=0;j<No[i];j++) {
+          sprintf(keyword,"%s_%i",name, j+1);
+          if (repetition == 0) {
+            neues = World::getInstance().createAtom();
+            AtomList[i][j] = neues;
+            LinearList[ FileBuffer->LineMapping[FileBuffer->CurrentLine] ] = neues;
+            neues->type = 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, 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.;
+          // 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
+          mol->AddAtom(neues);
+        }
+      }
+    }
+    // put atoms into the molecule in their original order
+    for(map<int, atom*>::iterator runner = LinearList.begin(); runner != LinearList.end(); ++runner) {
+      mol->AddAtom(runner->second);
+    }
+  }
+};
+
+
+/** Initializes config file structure by loading elements from a give file.
+ * \param *file input file stream being the opened config file
+ * \param BondGraphFileName file name of the bond length table file, if string is left blank, no table is parsed.
+ * \param *periode pointer to a periodentafel class with all elements
+ * \param *&MolList pointer to MoleculeListClass, on return containing all parsed molecules in system
+ */
+void config::Load(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, MoleculeListClass * const &MolList)
+{
+  molecule *mol = World::getInstance().createMolecule();
+  ifstream *file = new ifstream(filename);
+  if (file == NULL) {
+    DoeLog(1) && (eLog()<< Verbose(1) << "config file " << filename << " missing!" << endl);
+    return;
+  }
+  file->close();
+  delete(file);
+
+  // ParseParameterFile
+  class ConfigFileBuffer *FileBuffer = new ConfigFileBuffer(filename);
+
+  /* Oeffne Hauptparameterdatei */
+  int di = 0;
+  double BoxLength[9];
+  string zeile;
+  string dummy;
+  int verbose = 0;
+  
+  //TODO: This is actually sensible?: if (MaxOuterStep > 0)
+  ParseThermostats(FileBuffer);
+  
+  /* Namen einlesen */
+
+  // 1. parse in options
+  ParseForParameter(verbose,FileBuffer, "mainname", 0, 1, 1, string_type, (config::mainname), 1, critical);
+  ParseForParameter(verbose,FileBuffer, "defaultpath", 0, 1, 1, string_type, (config::defaultpath), 1, critical);
+  ParseForParameter(verbose,FileBuffer, "pseudopotpath", 0, 1, 1, string_type, (config::pseudopotpath), 1, critical);
+  ParseForParameter(verbose,FileBuffer,"ProcPEGamma", 0, 1, 1, int_type, &(config::ProcPEGamma), 1, critical);
+  ParseForParameter(verbose,FileBuffer,"ProcPEPsi", 0, 1, 1, int_type, &(config::ProcPEPsi), 1, critical);
+
+  if (!ParseForParameter(verbose,FileBuffer,"Seed", 0, 1, 1, int_type, &(config::Seed), 1, optional))
+    config::Seed = 1;
+
+  if(!ParseForParameter(verbose,FileBuffer,"DoOutOrbitals", 0, 1, 1, int_type, &(config::DoOutOrbitals), 1, optional)) {
+    config::DoOutOrbitals = 0;
+  } else {
+    if (config::DoOutOrbitals < 0) config::DoOutOrbitals = 0;
+    if (config::DoOutOrbitals > 1) config::DoOutOrbitals = 1;
+  }
+  ParseForParameter(verbose,FileBuffer,"DoOutVis", 0, 1, 1, int_type, &(config::DoOutVis), 1, critical);
+  if (config::DoOutVis < 0) config::DoOutVis = 0;
+  if (config::DoOutVis > 1) config::DoOutVis = 1;
+  if (!ParseForParameter(verbose,FileBuffer,"VectorPlane", 0, 1, 1, int_type, &(config::VectorPlane), 1, optional))
+    config::VectorPlane = -1;
+  if (!ParseForParameter(verbose,FileBuffer,"VectorCut", 0, 1, 1, double_type, &(config::VectorCut), 1, optional))
+    config::VectorCut = 0.;
+  ParseForParameter(verbose,FileBuffer,"DoOutMes", 0, 1, 1, int_type, &(config::DoOutMes), 1, critical);
+  if (config::DoOutMes < 0) config::DoOutMes = 0;
+  if (config::DoOutMes > 1) config::DoOutMes = 1;
+  if (!ParseForParameter(verbose,FileBuffer,"DoOutCurr", 0, 1, 1, int_type, &(config::DoOutCurrent), 1, optional))
+    config::DoOutCurrent = 0;
+  if (config::DoOutCurrent < 0) config::DoOutCurrent = 0;
+  if (config::DoOutCurrent > 1) config::DoOutCurrent = 1;
+  ParseForParameter(verbose,FileBuffer,"AddGramSch", 0, 1, 1, int_type, &(config::UseAddGramSch), 1, critical);
+  if (config::UseAddGramSch < 0) config::UseAddGramSch = 0;
+  if (config::UseAddGramSch > 2) config::UseAddGramSch = 2;
+  if(!ParseForParameter(verbose,FileBuffer,"DoWannier", 0, 1, 1, int_type, &(config::DoWannier), 1, optional)) {
+    config::DoWannier = 0;
+  } else {
+    if (config::DoWannier < 0) config::DoWannier = 0;
+    if (config::DoWannier > 1) config::DoWannier = 1;
+  }
+  if(!ParseForParameter(verbose,FileBuffer,"CommonWannier", 0, 1, 1, int_type, &(config::CommonWannier), 1, optional)) {
+    config::CommonWannier = 0;
+  } else {
+    if (config::CommonWannier < 0) config::CommonWannier = 0;
+    if (config::CommonWannier > 4) config::CommonWannier = 4;
+  }
+  if(!ParseForParameter(verbose,FileBuffer,"SawtoothStart", 0, 1, 1, double_type, &(config::SawtoothStart), 1, optional)) {
+    config::SawtoothStart = 0.01;
+  } else {
+    if (config::SawtoothStart < 0.) config::SawtoothStart = 0.;
+    if (config::SawtoothStart > 1.) config::SawtoothStart = 1.;
+  }
+  
+  if (ParseForParameter(verbose,FileBuffer,"DoConstrainedMD", 0, 1, 1, int_type, &(config::DoConstrainedMD), 1, optional))
+    if (config::DoConstrainedMD < 0) 
+      config::DoConstrainedMD = 0;
+  ParseForParameter(verbose,FileBuffer,"MaxOuterStep", 0, 1, 1, int_type, &(config::MaxOuterStep), 1, critical);
+  if (!ParseForParameter(verbose,FileBuffer,"Deltat", 0, 1, 1, double_type, &(config::Deltat), 1, optional))
+    config::Deltat = 1;
+  ParseForParameter(verbose,FileBuffer,"OutVisStep", 0, 1, 1, int_type, &(config::OutVisStep), 1, optional);
+  ParseForParameter(verbose,FileBuffer,"OutSrcStep", 0, 1, 1, int_type, &(config::OutSrcStep), 1, optional);
+  ParseForParameter(verbose,FileBuffer,"TargetTemp", 0, 1, 1, double_type, &(Thermostats->TargetTemp), 1, optional);
+  //ParseForParameter(verbose,FileBuffer,"Thermostat", 0, 1, 1, int_type, &(config::ScaleTempStep), 1, optional);
+  if (!ParseForParameter(verbose,FileBuffer,"EpsWannier", 0, 1, 1, double_type, &(config::EpsWannier), 1, optional))
+    config::EpsWannier = 1e-8;
+
+  // stop conditions
+  //if (config::MaxOuterStep <= 0) config::MaxOuterStep = 1;
+  ParseForParameter(verbose,FileBuffer,"MaxPsiStep", 0, 1, 1, int_type, &(config::MaxPsiStep), 1, critical);
+  if (config::MaxPsiStep <= 0) config::MaxPsiStep = 3;
+
+  ParseForParameter(verbose,FileBuffer,"MaxMinStep", 0, 1, 1, int_type, &(config::MaxMinStep), 1, critical);
+  ParseForParameter(verbose,FileBuffer,"RelEpsTotalE", 0, 1, 1, double_type, &(config::RelEpsTotalEnergy), 1, critical);
+  ParseForParameter(verbose,FileBuffer,"RelEpsKineticE", 0, 1, 1, double_type, &(config::RelEpsKineticEnergy), 1, critical);
+  ParseForParameter(verbose,FileBuffer,"MaxMinStopStep", 0, 1, 1, int_type, &(config::MaxMinStopStep), 1, critical);
+  ParseForParameter(verbose,FileBuffer,"MaxMinGapStopStep", 0, 1, 1, int_type, &(config::MaxMinGapStopStep), 1, critical);
+  if (config::MaxMinStep <= 0) config::MaxMinStep = config::MaxPsiStep;
+  if (config::MaxMinStopStep < 1) config::MaxMinStopStep = 1;
+  if (config::MaxMinGapStopStep < 1) config::MaxMinGapStopStep = 1;
+
+  ParseForParameter(verbose,FileBuffer,"MaxInitMinStep", 0, 1, 1, int_type, &(config::MaxInitMinStep), 1, critical);
+  ParseForParameter(verbose,FileBuffer,"InitRelEpsTotalE", 0, 1, 1, double_type, &(config::InitRelEpsTotalEnergy), 1, critical);
+  ParseForParameter(verbose,FileBuffer,"InitRelEpsKineticE", 0, 1, 1, double_type, &(config::InitRelEpsKineticEnergy), 1, critical);
+  ParseForParameter(verbose,FileBuffer,"InitMaxMinStopStep", 0, 1, 1, int_type, &(config::InitMaxMinStopStep), 1, critical);
+  ParseForParameter(verbose,FileBuffer,"InitMaxMinGapStopStep", 0, 1, 1, int_type, &(config::InitMaxMinGapStopStep), 1, critical);
+  if (config::MaxInitMinStep <= 0) config::MaxInitMinStep = config::MaxPsiStep;
+  if (config::InitMaxMinStopStep < 1) config::InitMaxMinStopStep = 1;
+  if (config::InitMaxMinGapStopStep < 1) config::InitMaxMinGapStopStep = 1;
+
+  // 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();
+  cell_size[0] = BoxLength[0];
+  cell_size[1] = BoxLength[3];
+  cell_size[2] = BoxLength[4];
+  cell_size[3] = BoxLength[6];
+  cell_size[4] = BoxLength[7];
+  cell_size[5] = BoxLength[8];
+  //if (1) fprintf(stderr,"\n");
+
+  ParseForParameter(verbose,FileBuffer,"DoPerturbation", 0, 1, 1, int_type, &(config::DoPerturbation), 1, optional);
+  ParseForParameter(verbose,FileBuffer,"DoOutNICS", 0, 1, 1, int_type, &(config::DoOutNICS), 1, optional);
+  if (!ParseForParameter(verbose,FileBuffer,"DoFullCurrent", 0, 1, 1, int_type, &(config::DoFullCurrent), 1, optional))
+    config::DoFullCurrent = 0;
+  if (config::DoFullCurrent < 0) config::DoFullCurrent = 0;
+  if (config::DoFullCurrent > 2) config::DoFullCurrent = 2;
+  if (config::DoOutNICS < 0) config::DoOutNICS = 0;
+  if (config::DoOutNICS > 2) config::DoOutNICS = 2;
+  if (config::DoPerturbation == 0) {
+    config::DoFullCurrent = 0;
+    config::DoOutNICS = 0;
+  }
+
+  ParseForParameter(verbose,FileBuffer,"ECut", 0, 1, 1, double_type, &(config::ECut), 1, critical);
+  ParseForParameter(verbose,FileBuffer,"MaxLevel", 0, 1, 1, int_type, &(config::MaxLevel), 1, critical);
+  ParseForParameter(verbose,FileBuffer,"Level0Factor", 0, 1, 1, int_type, &(config::Lev0Factor), 1, critical);
+  if (config::Lev0Factor < 2) {
+    config::Lev0Factor = 2;
+  }
+  ParseForParameter(verbose,FileBuffer,"RiemannTensor", 0, 1, 1, int_type, &di, 1, critical);
+  if (di >= 0 && di < 2) {
+    config::RiemannTensor = di;
+  } else {
+    fprintf(stderr, "0 <= RiemanTensor < 2: 0 UseNotRT, 1 UseRT");
+    exit(1);
+  }
+  switch (config::RiemannTensor) {
+    case 0: //UseNoRT
+      if (config::MaxLevel < 2) {
+        config::MaxLevel = 2;
+      }
+      config::LevRFactor = 2;
+      config::RTActualUse = 0;
+      break;
+    case 1: // UseRT
+      if (config::MaxLevel < 3) {
+        config::MaxLevel = 3;
+      }
+      ParseForParameter(verbose,FileBuffer,"RiemannLevel", 0, 1, 1, int_type, &(config::RiemannLevel), 1, critical);
+      if (config::RiemannLevel < 2) {
+        config::RiemannLevel = 2;
+      }
+      if (config::RiemannLevel > config::MaxLevel-1) {
+        config::RiemannLevel = config::MaxLevel-1;
+      }
+      ParseForParameter(verbose,FileBuffer,"LevRFactor", 0, 1, 1, int_type, &(config::LevRFactor), 1, critical);
+      if (config::LevRFactor < 2) {
+        config::LevRFactor = 2;
+      }
+      config::Lev0Factor = 2;
+      config::RTActualUse = 2;
+      break;
+  }
+  ParseForParameter(verbose,FileBuffer,"PsiType", 0, 1, 1, int_type, &di, 1, critical);
+  if (di >= 0 && di < 2) {
+    config::PsiType = di;
+  } else {
+    fprintf(stderr, "0 <= PsiType < 2: 0 UseSpinDouble, 1 UseSpinUpDown");
+    exit(1);
+  }
+  switch (config::PsiType) {
+  case 0: // SpinDouble
+    ParseForParameter(verbose,FileBuffer,"MaxPsiDouble", 0, 1, 1, int_type, &(config::MaxPsiDouble), 1, critical);
+    ParseForParameter(verbose,FileBuffer,"AddPsis", 0, 1, 1, int_type, &(config::AddPsis), 1, optional);
+    break;
+  case 1: // SpinUpDown
+    if (config::ProcPEGamma % 2) config::ProcPEGamma*=2;
+    ParseForParameter(verbose,FileBuffer,"PsiMaxNoUp", 0, 1, 1, int_type, &(config::PsiMaxNoUp), 1, critical);
+    ParseForParameter(verbose,FileBuffer,"PsiMaxNoDown", 0, 1, 1, int_type, &(config::PsiMaxNoDown), 1, critical);
+    ParseForParameter(verbose,FileBuffer,"AddPsis", 0, 1, 1, int_type, &(config::AddPsis), 1, optional);
+    break;
+  }
+
+  // IonsInitRead
+
+  ParseForParameter(verbose,FileBuffer,"RCut", 0, 1, 1, double_type, &(config::RCut), 1, critical);
+  ParseForParameter(verbose,FileBuffer,"IsAngstroem", 0, 1, 1, int_type, &(config::IsAngstroem), 1, critical);
+  ParseForParameter(verbose,FileBuffer,"MaxTypes", 0, 1, 1, int_type, &(MaxTypes), 1, critical);
+  if (!ParseForParameter(verbose,FileBuffer,"RelativeCoord", 0, 1, 1, int_type, &(config::RelativeCoord) , 1, optional))
+    config::RelativeCoord = 0;
+  if (!ParseForParameter(verbose,FileBuffer,"StructOpt", 0, 1, 1, int_type, &(config::StructOpt), 1, optional))
+    config::StructOpt = 0;
+
+  // 2. parse the bond graph file if given
+  if (BG == NULL) {
+    BG = new BondGraph(IsAngstroem);
+    if (BG->LoadBondLengthTable(BondGraphFileName)) {
+      DoLog(0) && (Log() << Verbose(0) << "Bond length table loaded successfully." << endl);
+    } else {
+      DoeLog(1) && (eLog()<< Verbose(1) << "Bond length table loading failed." << endl);
+    }
+  }
+
+  // 3. parse the molecule in
+  LoadMolecule(mol, FileBuffer, periode, FastParsing);
+  mol->SetNameFromFilename(filename);
+  mol->ActiveFlag = true;
+  MolList->insert(mol);
+
+  // 4. dissect the molecule into connected subgraphs
+  // don't do this here ...
+  //MolList->DissectMoleculeIntoConnectedSubgraphs(mol,this);
+  //delete(mol);
+
+  delete(FileBuffer);
+};
+
+/** Initializes config file structure by loading elements from a give file with old pcp syntax.
+ * \param *file input file stream being the opened config file with old pcp syntax
+ * \param BondGraphFileName file name of the bond length table file, if string is left blank, no table is parsed.
+ * \param *periode pointer to a periodentafel class with all elements
+ * \param *&MolList pointer to MoleculeListClass, on return containing all parsed molecules in system
+ */
+void config::LoadOld(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, MoleculeListClass * const &MolList)
+{
+  molecule *mol = World::getInstance().createMolecule();
+  ifstream *file = new ifstream(filename);
+  if (file == NULL) {
+    DoeLog(1) && (eLog()<< Verbose(1) << "config file " << filename << " missing!" << endl);
+    return;
+  }
+  // ParseParameters
+
+  /* Oeffne Hauptparameterdatei */
+  int l = 0;
+  int i = 0;
+  int di = 0;
+  double a = 0.;
+  double b = 0.;
+  double BoxLength[9];
+  string zeile;
+  string dummy;
+  const element *elementhash[128];
+  int Z = -1;
+  int No = -1;
+  int AtomNo = -1;
+  int found = 0;
+  int verbose = 0;
+
+  mol->ActiveFlag = true;
+  MolList->insert(mol);
+  /* Namen einlesen */
+
+  ParseForParameter(verbose,file, "mainname", 0, 1, 1, string_type, (config::mainname), 1, critical);
+  ParseForParameter(verbose,file, "defaultpath", 0, 1, 1, string_type, (config::defaultpath), 1, critical);
+  ParseForParameter(verbose,file, "pseudopotpath", 0, 1, 1, string_type, (config::pseudopotpath), 1, critical);
+  ParseForParameter(verbose,file, "ProcsGammaPsi", 0, 1, 1, int_type, &(config::ProcPEGamma), 1, critical);
+  ParseForParameter(verbose,file, "ProcsGammaPsi", 0, 2, 1, int_type, &(config::ProcPEPsi), 1, critical);
+  config::Seed = 1;
+  config::DoOutOrbitals = 0;
+  ParseForParameter(verbose,file,"DoOutVis", 0, 1, 1, int_type, &(config::DoOutVis), 1, critical);
+  if (config::DoOutVis < 0) config::DoOutVis = 0;
+  if (config::DoOutVis > 1) config::DoOutVis = 1;
+  config::VectorPlane = -1;
+  config::VectorCut = 0.;
+  ParseForParameter(verbose,file,"DoOutMes", 0, 1, 1, int_type, &(config::DoOutMes), 1, critical);
+  if (config::DoOutMes < 0) config::DoOutMes = 0;
+  if (config::DoOutMes > 1) config::DoOutMes = 1;
+  config::DoOutCurrent = 0;
+  ParseForParameter(verbose,file,"AddGramSch", 0, 1, 1, int_type, &(config::UseAddGramSch), 1, critical);
+  if (config::UseAddGramSch < 0) config::UseAddGramSch = 0;
+  if (config::UseAddGramSch > 2) config::UseAddGramSch = 2;
+  config::CommonWannier = 0;
+  config::SawtoothStart = 0.01;
+
+  ParseForParameter(verbose,file,"MaxOuterStep", 0, 1, 1, double_type, &(config::MaxOuterStep), 1, critical);
+  ParseForParameter(verbose,file,"Deltat", 0, 1, 1, double_type, &(config::Deltat), 1, optional);
+  ParseForParameter(verbose,file,"VisOuterStep", 0, 1, 1, int_type, &(config::OutVisStep), 1, optional);
+  ParseForParameter(verbose,file,"VisSrcOuterStep", 0, 1, 1, int_type, &(config::OutSrcStep), 1, optional);
+  ParseForParameter(verbose,file,"TargetTemp", 0, 1, 1, double_type, &(Thermostats->TargetTemp), 1, optional);
+  ParseForParameter(verbose,file,"ScaleTempStep", 0, 1, 1, int_type, &(Thermostats->ScaleTempStep), 1, optional);
+  config::EpsWannier = 1e-8;
+
+  // stop conditions
+  //if (config::MaxOuterStep <= 0) config::MaxOuterStep = 1;
+  ParseForParameter(verbose,file,"MaxPsiStep", 0, 1, 1, int_type, &(config::MaxPsiStep), 1, critical);
+  if (config::MaxPsiStep <= 0) config::MaxPsiStep = 3;
+
+  ParseForParameter(verbose,file,"MaxMinStep", 0, 1, 1, int_type, &(config::MaxMinStep), 1, critical);
+  ParseForParameter(verbose,file,"MaxMinStep", 0, 2, 1, double_type, &(config::RelEpsTotalEnergy), 1, critical);
+  ParseForParameter(verbose,file,"MaxMinStep", 0, 3, 1, double_type, &(config::RelEpsKineticEnergy), 1, critical);
+  ParseForParameter(verbose,file,"MaxMinStep", 0, 4, 1, int_type, &(config::MaxMinStopStep), 1, critical);
+  if (config::MaxMinStep <= 0) config::MaxMinStep = config::MaxPsiStep;
+  if (config::MaxMinStopStep < 1) config::MaxMinStopStep = 1;
+  config::MaxMinGapStopStep = 1;
+
+  ParseForParameter(verbose,file,"MaxInitMinStep", 0, 1, 1, int_type, &(config::MaxInitMinStep), 1, critical);
+  ParseForParameter(verbose,file,"MaxInitMinStep", 0, 2, 1, double_type, &(config::InitRelEpsTotalEnergy), 1, critical);
+  ParseForParameter(verbose,file,"MaxInitMinStep", 0, 3, 1, double_type, &(config::InitRelEpsKineticEnergy), 1, critical);
+  ParseForParameter(verbose,file,"MaxInitMinStep", 0, 4, 1, int_type, &(config::InitMaxMinStopStep), 1, critical);
+  if (config::MaxInitMinStep <= 0) config::MaxInitMinStep = config::MaxPsiStep;
+  if (config::InitMaxMinStopStep < 1) config::InitMaxMinStopStep = 1;
+  config::InitMaxMinGapStopStep = 1;
+
+  ParseForParameter(verbose,file, "BoxLength", 0, 3, 3, lower_trigrid, BoxLength, 1, critical); /* Lattice->RealBasis */
+  double * const cell_size = World::getInstance().getDomain();
+  cell_size[0] = BoxLength[0];
+  cell_size[1] = BoxLength[3];
+  cell_size[2] = BoxLength[4];
+  cell_size[3] = BoxLength[6];
+  cell_size[4] = BoxLength[7];
+  cell_size[5] = BoxLength[8];
+  if (1) fprintf(stderr,"\n");
+  config::DoPerturbation = 0;
+  config::DoFullCurrent = 0;
+
+  ParseForParameter(verbose,file,"ECut", 0, 1, 1, double_type, &(config::ECut), 1, critical);
+  ParseForParameter(verbose,file,"MaxLevel", 0, 1, 1, int_type, &(config::MaxLevel), 1, critical);
+  ParseForParameter(verbose,file,"Level0Factor", 0, 1, 1, int_type, &(config::Lev0Factor), 1, critical);
+  if (config::Lev0Factor < 2) {
+    config::Lev0Factor = 2;
+  }
+  ParseForParameter(verbose,file,"RiemannTensor", 0, 1, 1, int_type, &di, 1, critical);
+  if (di >= 0 && di < 2) {
+    config::RiemannTensor = di;
+  } else {
+    fprintf(stderr, "0 <= RiemanTensor < 2: 0 UseNotRT, 1 UseRT");
+    exit(1);
+  }
+  switch (config::RiemannTensor) {
+    case 0: //UseNoRT
+      if (config::MaxLevel < 2) {
+        config::MaxLevel = 2;
+      }
+      config::LevRFactor = 2;
+      config::RTActualUse = 0;
+      break;
+    case 1: // UseRT
+      if (config::MaxLevel < 3) {
+        config::MaxLevel = 3;
+      }
+      ParseForParameter(verbose,file,"RiemannLevel", 0, 1, 1, int_type, &(config::RiemannLevel), 1, critical);
+      if (config::RiemannLevel < 2) {
+        config::RiemannLevel = 2;
+      }
+      if (config::RiemannLevel > config::MaxLevel-1) {
+        config::RiemannLevel = config::MaxLevel-1;
+      }
+      ParseForParameter(verbose,file,"LevRFactor", 0, 1, 1, int_type, &(config::LevRFactor), 1, critical);
+      if (config::LevRFactor < 2) {
+        config::LevRFactor = 2;
+      }
+      config::Lev0Factor = 2;
+      config::RTActualUse = 2;
+      break;
+  }
+  ParseForParameter(verbose,file,"PsiType", 0, 1, 1, int_type, &di, 1, critical);
+  if (di >= 0 && di < 2) {
+    config::PsiType = di;
+  } else {
+    fprintf(stderr, "0 <= PsiType < 2: 0 UseSpinDouble, 1 UseSpinUpDown");
+    exit(1);
+  }
+  switch (config::PsiType) {
+  case 0: // SpinDouble
+    ParseForParameter(verbose,file,"MaxPsiDouble", 0, 1, 1, int_type, &(config::MaxPsiDouble), 1, critical);
+    config::AddPsis = 0;
+    break;
+  case 1: // SpinUpDown
+    if (config::ProcPEGamma % 2) config::ProcPEGamma*=2;
+    ParseForParameter(verbose,file,"MaxPsiUp", 0, 1, 1, int_type, &(config::PsiMaxNoUp), 1, critical);
+    ParseForParameter(verbose,file,"MaxPsiDown", 0, 1, 1, int_type, &(config::PsiMaxNoDown), 1, critical);
+    config::AddPsis = 0;
+    break;
+  }
+
+  // IonsInitRead
+
+  ParseForParameter(verbose,file,"RCut", 0, 1, 1, double_type, &(config::RCut), 1, critical);
+  ParseForParameter(verbose,file,"IsAngstroem", 0, 1, 1, int_type, &(config::IsAngstroem), 1, critical);
+  config::RelativeCoord = 0;
+  config::StructOpt = 0;
+
+
+  // 2. parse the bond graph file if given
+  BG = new BondGraph(IsAngstroem);
+  if (BG->LoadBondLengthTable(BondGraphFileName)) {
+    DoLog(0) && (Log() << Verbose(0) << "Bond length table loaded successfully." << endl);
+  } else {
+    DoLog(0) && (Log() << Verbose(0) << "Bond length table loading failed." << endl);
+  }
+
+  // Routine from builder.cpp
+
+  for (i=MAX_ELEMENTS;i--;)
+    elementhash[i] = NULL;
+  DoLog(0) && (Log() << Verbose(0) << "Parsing Ions ..." << endl);
+  No=0;
+  found = 0;
+  while (getline(*file,zeile,'\n')) {
+    if (zeile.find("Ions_Data") == 0) {
+      DoLog(1) && (Log() << Verbose(1) << "found Ions_Data...begin parsing" << endl);
+      found ++;
+    }
+    if (found > 0) {
+      if (zeile.find("Ions_Data") == 0)
+        getline(*file,zeile,'\n'); // read next line and parse this one
+      istringstream input(zeile);
+      input >> AtomNo;  // number of atoms
+      input >> Z;       // atomic number
+      input >> a;
+      input >> l;
+      input >> l;
+      input >> b;     // element mass
+      elementhash[No] = periode->FindElement(Z);
+      DoLog(1) && (Log() << Verbose(1) << "AtomNo: " << AtomNo << "\tZ: " << Z << "\ta:" << a << "\tl:"  << l << "\b:" << b << "\tElement:" << elementhash[No] << "\t:" << endl);
+      for(i=0;i<AtomNo;i++) {
+        if (!getline(*file,zeile,'\n')) {// parse on and on
+          DoLog(2) && (Log() << Verbose(2) << "Error: Too few items in ionic list of element" << elementhash[No] << "." << endl << "Exiting." << endl);
+          // return 1;
+        } else {
+          //Log() << Verbose(2) << "Reading line: " << zeile << endl;
+        }
+        istringstream input2(zeile);
+        atom *neues = World::getInstance().createAtom();
+        input2 >> neues->x[0]; // x
+        input2 >> neues->x[1]; // y
+        input2 >> neues->x[2]; // z
+        input2 >> l;
+        neues->type = elementhash[No]; // find element type
+        mol->AddAtom(neues);
+      }
+      No++;
+    }
+  }
+  file->close();
+  delete(file);
+};
+
+/** Stores all elements of config structure from which they can be re-read.
+ * \param *filename name of file
+ * \param *periode pointer to a periodentafel class with all elements
+ * \param *mol pointer to molecule containing all atoms of the molecule
+ */
+bool config::Save(const char * const filename, const periodentafel * const periode, molecule * const mol) const
+{
+  bool result = true;
+  // bring MaxTypes up to date
+  mol->CountElements();
+  const double * const cell_size = World::getInstance().getDomain();
+  ofstream * const output = new ofstream(filename, ios::out);
+  if (output != NULL) {
+    *output << "# ParallelCarParinello - main configuration file - created with molecuilder" << endl;
+    *output << endl;
+    *output << "mainname\t" << config::mainname << "\t# programm name (for runtime files)" << endl;
+    *output << "defaultpath\t" << config::defaultpath << "\t# where to put files during runtime" << endl;
+    *output << "pseudopotpath\t" << config::pseudopotpath << "\t# where to find pseudopotentials" << endl;
+    *output << endl;
+    *output << "ProcPEGamma\t" << config::ProcPEGamma << "\t# for parallel computing: share constants" << endl;
+    *output << "ProcPEPsi\t" << config::ProcPEPsi << "\t# for parallel computing: share wave functions" << endl;
+    *output << "DoOutVis\t" << config::DoOutVis << "\t# Output data for OpenDX" << endl;
+    *output << "DoOutMes\t" << config::DoOutMes << "\t# Output data for measurements" << endl;
+    *output << "DoOutOrbitals\t" << config::DoOutOrbitals << "\t# Output all Orbitals" << endl;
+    *output << "DoOutCurr\t" << config::DoOutCurrent << "\t# Ouput current density for OpenDx" << endl;
+    *output << "DoOutNICS\t" << config::DoOutNICS << "\t# Output Nucleus independent current shieldings" << endl;
+    *output << "DoPerturbation\t" << config::DoPerturbation << "\t# Do perturbation calculate and determine susceptibility and shielding" << endl;
+    *output << "DoFullCurrent\t" << config::DoFullCurrent << "\t# Do full perturbation" << endl;
+    *output << "DoConstrainedMD\t" << config::DoConstrainedMD << "\t# Do perform a constrained (>0, relating to current MD step) instead of unconstrained (0) MD" << endl;
+    *output << "Thermostat\t" << Thermostats->ThermostatNames[Thermostats->Thermostat] << "\t";
+    switch(Thermostats->Thermostat) {
+      default:
+      case None:
+        break;
+      case Woodcock:
+        *output << Thermostats->ScaleTempStep;
+        break;
+      case Gaussian:
+        *output << Thermostats->ScaleTempStep;
+        break;
+      case Langevin:
+        *output << Thermostats->TempFrequency << "\t" << Thermostats->alpha;
+        break;
+      case Berendsen:
+        *output << Thermostats->TempFrequency;
+        break;
+      case NoseHoover:
+        *output << Thermostats->HooverMass;
+        break;
+    };
+    *output << "\t# Which Thermostat and its parameters to use in MD case." << endl;
+    *output << "CommonWannier\t" << config::CommonWannier << "\t# Put virtual centers at indivual orbits, all common, merged by variance, to grid point, to cell center" << endl;
+    *output << "SawtoothStart\t" << config::SawtoothStart << "\t# Absolute value for smooth transition at cell border " << endl;
+    *output << "VectorPlane\t" << config::VectorPlane << "\t# Cut plane axis (x, y or z: 0,1,2) for two-dim current vector plot" << endl;
+    *output << "VectorCut\t" << config::VectorCut << "\t# Cut plane axis value" << endl;
+    *output << "AddGramSch\t" << config::UseAddGramSch << "\t# Additional GramSchmidtOrtogonalization to be safe" << endl;
+    *output << "Seed\t\t" << config::Seed << "\t# initial value for random seed for Psi coefficients" << endl;
+    *output << endl;
+    *output << "MaxOuterStep\t" << config::MaxOuterStep << "\t# number of MolecularDynamics/Structure optimization steps" << endl;
+    *output << "Deltat\t" << config::Deltat << "\t# time per MD step" << endl;
+    *output << "OutVisStep\t" << config::OutVisStep << "\t# Output visual data every ...th step" << endl;
+    *output << "OutSrcStep\t" << config::OutSrcStep << "\t# Output \"restart\" data every ..th step" << endl;
+    *output << "TargetTemp\t" << Thermostats->TargetTemp << "\t# Target temperature" << endl;
+    *output << "MaxPsiStep\t" << config::MaxPsiStep << "\t# number of Minimisation steps per state (0 - default)" << endl;
+    *output << "EpsWannier\t" << config::EpsWannier << "\t# tolerance value for spread minimisation of orbitals" << endl;
+    *output << endl;
+    *output << "# Values specifying when to stop" << endl;
+    *output << "MaxMinStep\t" << config::MaxMinStep << "\t# Maximum number of steps" << endl;
+    *output << "RelEpsTotalE\t" << config::RelEpsTotalEnergy << "\t# relative change in total energy" << endl;
+    *output << "RelEpsKineticE\t" << config::RelEpsKineticEnergy << "\t# relative change in kinetic energy" << endl;
+    *output << "MaxMinStopStep\t" << config::MaxMinStopStep << "\t# check every ..th steps" << endl;
+    *output << "MaxMinGapStopStep\t" << config::MaxMinGapStopStep << "\t# check every ..th steps" << endl;
+    *output << endl;
+    *output << "# Values specifying when to stop for INIT, otherwise same as above" << endl;
+    *output << "MaxInitMinStep\t" << config::MaxInitMinStep << "\t# Maximum number of steps" << endl;
+    *output << "InitRelEpsTotalE\t" << config::InitRelEpsTotalEnergy << "\t# relative change in total energy" << endl;
+    *output << "InitRelEpsKineticE\t" << config::InitRelEpsKineticEnergy << "\t# relative change in kinetic energy" << endl;
+    *output << "InitMaxMinStopStep\t" << config::InitMaxMinStopStep << "\t# check every ..th steps" << endl;
+    *output << "InitMaxMinGapStopStep\t" << config::InitMaxMinGapStopStep << "\t# check every ..th steps" << endl;
+    *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;
+    // FIXME
+    *output << endl;
+    *output << "ECut\t\t" << config::ECut << "\t# energy cutoff for discretization in Hartrees" << endl;
+    *output << "MaxLevel\t" << config::MaxLevel << "\t# number of different levels in the code, >=2" << endl;
+    *output << "Level0Factor\t" << config::Lev0Factor << "\t# factor by which node number increases from S to 0 level" << endl;
+    *output << "RiemannTensor\t" << config::RiemannTensor << "\t# (Use metric)" << endl;
+    switch (config::RiemannTensor) {
+      case 0: //UseNoRT
+        break;
+      case 1: // UseRT
+        *output << "RiemannLevel\t" << config::RiemannLevel << "\t# Number of Riemann Levels" << endl;
+        *output << "LevRFactor\t" << config::LevRFactor << "\t# factor by which node number increases from 0 to R level from" << endl;
+        break;
+    }
+    *output << "PsiType\t\t" << config::PsiType << "\t# 0 - doubly occupied, 1 - SpinUp,SpinDown" << endl;
+    // write out both types for easier changing afterwards
+  //  switch (PsiType) {
+  //    case 0:
+        *output << "MaxPsiDouble\t" << config::MaxPsiDouble << "\t# here: specifying both maximum number of SpinUp- and -Down-states" << endl;
+  //      break;
+  //    case 1:
+        *output << "PsiMaxNoUp\t" << config::PsiMaxNoUp << "\t# here: specifying maximum number of SpinUp-states" << endl;
+        *output << "PsiMaxNoDown\t" << config::PsiMaxNoDown << "\t# here: specifying maximum number of SpinDown-states" << endl;
+  //      break;
+  //  }
+    *output << "AddPsis\t\t" << config::AddPsis << "\t# Additional unoccupied Psis for bandgap determination" << endl;
+    *output << endl;
+    *output << "RCut\t\t" << config::RCut << "\t# R-cut for the ewald summation" << endl;
+    *output << "StructOpt\t" << config::StructOpt << "\t# Do structure optimization beforehand" << endl;
+    *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 << endl;
+    result = result && mol->Checkout(output);
+    if (mol->MDSteps <=1 )
+      result = result && mol->Output(output);
+    else
+      result = result && mol->OutputTrajectories(output);
+    output->close();
+    output->clear();
+    delete(output);
+    return result;
+  } else {
+    DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open output file:" << filename << endl);
+    return false;
+  }
+};
+
+/** Stores all elements in a MPQC input file.
+ * Note that this format cannot be parsed again.
+ * \param *filename name of file (without ".in" suffix!)
+ * \param *mol pointer to molecule containing all atoms of the molecule
+ */
+bool config::SaveMPQC(const char * const filename, const molecule * const mol) const
+{
+  int AtomNo = -1;
+  Vector *center = NULL;
+  ofstream *output = NULL;
+
+  // first without hessian
+  {
+    stringstream * const fname = new stringstream;;
+    *fname << filename << ".in";
+    output = new ofstream(fname->str().c_str(), ios::out);
+    if (output == NULL) {
+      DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open mpqc output file:" << fname << endl);
+      delete(fname);
+      return false;
+    }
+    *output << "% Created by MoleCuilder" << endl;
+    *output << "mpqc: (" << endl;
+    *output << "\tsavestate = no" << endl;
+    *output << "\tdo_gradient = yes" << endl;
+    *output << "\tmole<MBPT2>: (" << endl;
+    *output << "\t\tmaxiter = 200" << endl;
+    *output << "\t\tbasis = $:basis" << endl;
+    *output << "\t\tmolecule = $:molecule" << endl;
+    *output << "\t\treference<CLHF>: (" << endl;
+    *output << "\t\t\tbasis = $:basis" << endl;
+    *output << "\t\t\tmolecule = $:molecule" << endl;
+    *output << "\t\t)" << endl;
+    *output << "\t)" << endl;
+    *output << ")" << endl;
+    *output << "molecule<Molecule>: (" << endl;
+    *output << "\tunit = " << (IsAngstroem ? "angstrom" : "bohr" ) << endl;
+    *output << "\t{ atoms geometry } = {" << endl;
+    center = mol->DetermineCenterOfAll();
+    // output of atoms
+    AtomNo = 0;
+    mol->ActOnAllAtoms( &atom::OutputMPQCLine, (ostream * const) output, (const Vector *)center, &AtomNo );
+    delete(center);
+    *output << "\t}" << endl;
+    *output << ")" << endl;
+    *output << "basis<GaussianBasisSet>: (" << endl;
+    *output << "\tname = \"" << basis << "\"" << endl;
+    *output << "\tmolecule = $:molecule" << endl;
+    *output << ")" << endl;
+    output->close();
+    delete(output);
+    delete(fname);
+  }
+
+  // second with hessian
+  {
+    stringstream * const fname = new stringstream;
+    *fname << filename << ".hess.in";
+    output = new ofstream(fname->str().c_str(), ios::out);
+    if (output == NULL) {
+      DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open mpqc hessian output file:" << fname << endl);
+      delete(fname);
+      return false;
+    }
+    *output << "% Created by MoleCuilder" << endl;
+    *output << "mpqc: (" << endl;
+    *output << "\tsavestate = no" << endl;
+    *output << "\tdo_gradient = yes" << endl;
+    *output << "\tmole<CLHF>: (" << endl;
+    *output << "\t\tmaxiter = 200" << endl;
+    *output << "\t\tbasis = $:basis" << endl;
+    *output << "\t\tmolecule = $:molecule" << endl;
+    *output << "\t)" << endl;
+    *output << "\tfreq<MolecularFrequencies>: (" << endl;
+    *output << "\t\tmolecule=$:molecule" << endl;
+    *output << "\t)" << endl;
+    *output << ")" << endl;
+    *output << "molecule<Molecule>: (" << endl;
+    *output << "\tunit = " << (IsAngstroem ? "angstrom" : "bohr" ) << endl;
+    *output << "\t{ atoms geometry } = {" << endl;
+    center = mol->DetermineCenterOfAll();
+    // output of atoms
+    AtomNo = 0;
+    mol->ActOnAllAtoms( &atom::OutputMPQCLine, (ostream * const) output, (const Vector *)center, &AtomNo );
+    delete(center);
+    *output << "\t}" << endl;
+    *output << ")" << endl;
+    *output << "basis<GaussianBasisSet>: (" << endl;
+    *output << "\tname = \"3-21G\"" << endl;
+    *output << "\tmolecule = $:molecule" << endl;
+    *output << ")" << endl;
+    output->close();
+    delete(output);
+    delete(fname);
+  }
+
+  return true;
+};
+
+/** Stores all atoms from all molecules in a PDB input file.
+ * Note that this format cannot be parsed again.
+ * \param *filename name of file (without ".in" suffix!)
+ * \param *MolList pointer to MoleculeListClass containing all atoms
+ */
+bool config::SavePDB(const char * const filename, const MoleculeListClass * const MolList) const
+{
+  int AtomNo = -1;
+  int MolNo = 0;
+  FILE *f = NULL;
+
+  char name[MAXSTRINGSIZE];
+  strncpy(name, filename, MAXSTRINGSIZE-1);
+  strncat(name, ".pdb", MAXSTRINGSIZE-(strlen(name)+1));
+  f = fopen(name, "w" );
+  if (f == NULL) {
+    DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open pdb output file:" << name << endl);
+    return false;
+  }
+  fprintf(f, "# Created by MoleCuilder\n");
+
+  for (MoleculeList::const_iterator MolRunner = MolList->ListOfMolecules.begin(); MolRunner != MolList->ListOfMolecules.end(); MolRunner++) {
+    int *elementNo = new int[MAX_ELEMENTS];
+    for (int i=0;i<MAX_ELEMENTS;i++)
+      elementNo[i] = 0;
+    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
+      fprintf(f,
+             "ATOM %6u %-4s %4s%c%4u    %8.3f%8.3f%8.3f%6.2f%6.2f      %4s%2s%2s\n",
+             (*iter)->nr,                /* atom serial number */
+             name,         /* atom name */
+             (*MolRunner)->name,      /* residue name */
+             '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 */
+             "0",            /* segment identifier */
+             (*iter)->type->symbol,    /* element symbol */
+             "0");           /* charge */
+      AtomNo++;
+    }
+    delete[](elementNo);
+    MolNo++;
+  }
+  fclose(f);
+
+  return true;
+};
+
+/** Stores all atoms in a PDB input file.
+ * Note that this format cannot be parsed again.
+ * \param *filename name of file (without ".in" suffix!)
+ * \param *mol pointer to molecule
+ */
+bool config::SavePDB(const char * const filename, const molecule * const mol) const
+{
+  int AtomNo = -1;
+  FILE *f = NULL;
+
+  int *elementNo = new int[MAX_ELEMENTS];
+  for (int i=0;i<MAX_ELEMENTS;i++)
+    elementNo[i] = 0;
+  char name[MAXSTRINGSIZE];
+  strncpy(name, filename, MAXSTRINGSIZE-1);
+  strncat(name, ".pdb", MAXSTRINGSIZE-(strlen(name)+1));
+  f = fopen(name, "w" );
+  if (f == NULL) {
+    DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open pdb output file:" << name << endl);
+    delete[](elementNo);
+    return false;
+  }
+  fprintf(f, "# Created by MoleCuilder\n");
+
+  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
+    fprintf(f,
+           "ATOM %6u %-4s %4s%c%4u    %8.3f%8.3f%8.3f%6.2f%6.2f      %4s%2s%2s\n",
+           (*iter)->nr,                /* atom serial number */
+           name,         /* atom name */
+           mol->name,      /* residue name */
+           '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 */
+           "0",            /* segment identifier */
+           (*iter)->type->symbol,    /* element symbol */
+           "0");           /* charge */
+    AtomNo++;
+  }
+  fclose(f);
+  delete[](elementNo);
+
+  return true;
+};
+
+/** Stores all atoms in a TREMOLO data input file.
+ * Note that this format cannot be parsed again.
+ * Note that TREMOLO does not like Id starting at 0, but at 1. Atoms with Id 0 are discarded!
+ * \param *filename name of file (without ".in" suffix!)
+ * \param *mol pointer to molecule
+ */
+bool config::SaveTREMOLO(const char * const filename, const molecule * const mol) const
+{
+  ofstream *output = NULL;
+  stringstream * const fname = new stringstream;
+
+  *fname << filename << ".data";
+  output = new ofstream(fname->str().c_str(), ios::out);
+  if (output == NULL) {
+    DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open tremolo output file:" << fname << endl);
+    delete(fname);
+    return false;
+  }
+
+  // scan maximum number of neighbours
+  int MaxNeighbours = 0;
+  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
+    const int count = (*iter)->ListOfBonds.size();
+    if (MaxNeighbours < count)
+      MaxNeighbours = count;
+  }
+  *output << "# ATOMDATA Id name resName resSeq x=3 Charge type neighbors=" << MaxNeighbours << endl;
+
+  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
+    *output << (*iter)->nr << "\t";
+    *output << (*iter)->getName() << "\t";
+    *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";
+    for (BondList::iterator runner = (*iter)->ListOfBonds.begin(); runner != (*iter)->ListOfBonds.end(); runner++)
+      *output << (*runner)->GetOtherAtom(*iter)->nr << "\t";
+    for(int i=(*iter)->ListOfBonds.size(); i < MaxNeighbours; i++)
+      *output << "-\t";
+    *output << endl;
+  }
+  output->flush();
+  output->close();
+  delete(output);
+  delete(fname);
+
+  return true;
+};
+
+/** Stores all atoms from all molecules in a TREMOLO data input file.
+ * Note that this format cannot be parsed again.
+ * Note that TREMOLO does not like Id starting at 0, but at 1. Atoms with Id 0 are discarded!
+ * \param *filename name of file (without ".in" suffix!)
+ * \param *MolList pointer to MoleculeListClass containing all atoms
+ */
+bool config::SaveTREMOLO(const char * const filename, const MoleculeListClass * const MolList) const
+{
+  Info FunctionInfo(__func__);
+  ofstream *output = NULL;
+  stringstream * const fname = new stringstream;
+
+  *fname << filename << ".data";
+  output = new ofstream(fname->str().c_str(), ios::out);
+  if (output == NULL) {
+    DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open tremolo output file:" << fname << endl);
+    delete(fname);
+    return false;
+  }
+
+  // scan maximum number of neighbours
+  int MaxNeighbours = 0;
+  for (MoleculeList::const_iterator MolWalker = MolList->ListOfMolecules.begin(); MolWalker != MolList->ListOfMolecules.end(); MolWalker++) {
+    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
+      const int count = (*iter)->ListOfBonds.size();
+      if (MaxNeighbours < count)
+        MaxNeighbours = count;
+    }
+  }
+  *output << "# ATOMDATA Id name resName resSeq x=3 Charge type neighbors=" << MaxNeighbours << endl;
+
+  // create global to local id map
+  map<int, int> LocalNotoGlobalNoMap;
+  {
+    unsigned int MolCounter = 0;
+    int AtomNo = 1;
+    for (MoleculeList::const_iterator MolWalker = MolList->ListOfMolecules.begin(); MolWalker != MolList->ListOfMolecules.end(); MolWalker++) {
+      for(molecule::iterator AtomRunner = (*MolWalker)->begin(); AtomRunner != (*MolWalker)->end(); ++AtomRunner) {
+        LocalNotoGlobalNoMap.insert( pair<int,int>((*AtomRunner)->getId(), AtomNo++) );
+      }
+      MolCounter++;
+    }
+    ASSERT(MolCounter == MolList->ListOfMolecules.size(), "SaveTREMOLO: LocalNotoGlobalNoMap[] has not been correctly initialized for each molecule");
+  }
+
+  // write the file
+  {
+    int MolCounter = 0;
+    int AtomNo = 0;
+    for (MoleculeList::const_iterator MolWalker = MolList->ListOfMolecules.begin(); MolWalker != MolList->ListOfMolecules.end(); MolWalker++) {
+      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
+        *output << LocalNotoGlobalNoMap[ (*iter)->getId() ] << "\t";
+        *output << (*iter)->getName() << "\t";
+        *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";
+        for (BondList::iterator runner = (*iter)->ListOfBonds.begin(); runner != (*iter)->ListOfBonds.end(); runner++)
+          *output << LocalNotoGlobalNoMap[ (*runner)->GetOtherAtom((*iter))->getId() ] << "\t";
+        for(int i=(*iter)->ListOfBonds.size(); i < MaxNeighbours; i++)
+          *output << "-\t";
+        *output << endl;
+        AtomNo++;
+      }
+      MolCounter++;
+    }
+  }
+
+  // store & free
+  output->flush();
+  output->close();
+  delete(output);
+  delete(fname);
+
+  return true;
+};
+
+
+/** Tries given filename or standard on saving the config file.
+ * \param *ConfigFileName name of file
+ * \param *periode pointer to periodentafel structure with all the elements
+ * \param *molecules list of molecules structure with all the atoms and coordinates
+ */
+void config::SaveAll(char *ConfigFileName, periodentafel *periode, MoleculeListClass *molecules)
+{
+  char filename[MAXSTRINGSIZE];
+  ofstream output;
+  molecule *mol = NULL;
+
+  // first save as PDB data
+  if (ConfigFileName != NULL)
+    strcpy(filename, ConfigFileName);
+  if (output == NULL)
+    strcpy(filename,"main_pcp_linux");
+  Log() << Verbose(0) << "Saving as pdb input ... " << endl;
+  if (SavePDB(filename, molecules))
+    Log() << Verbose(0) << "\t... done." << endl;
+  else
+    Log() << Verbose(0) << "\t... failed." << endl;
+
+  // then save as tremolo data file
+  if (ConfigFileName != NULL)
+    strcpy(filename, ConfigFileName);
+  if (output == NULL)
+    strcpy(filename,"main_pcp_linux");
+  Log() << Verbose(0) << "Saving as tremolo data input ... " << endl;
+  if (SaveTREMOLO(filename, molecules))
+    Log() << Verbose(0) << "\t... done." << endl;
+  else
+    Log() << Verbose(0) << "\t... failed." << endl;
+
+  // translate each to its center and merge all molecules in MoleculeListClass into this molecule
+  int N = molecules->ListOfMolecules.size();
+  if (N != 1) { // don't do anything in case of only one molecule (shifts mol ids otherwise)
+    int *src = new int[N];
+    N=0;
+    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);
+  } else {
+    if (!molecules->ListOfMolecules.empty()) {
+      mol = *(molecules->ListOfMolecules.begin());
+      mol->doCountAtoms();
+      //mol->CalculateOrbitals(*this);
+    } else {
+      DoeLog(1) && (eLog() << Verbose(1) << "There are no molecules to save!" << endl);
+    }
+  }
+
+  Log() << Verbose(0) << "Storing configuration ... " << endl;
+  // get correct valence orbitals
+  if (ConfigFileName != NULL) { // test the file name
+    strcpy(filename, ConfigFileName);
+    output.open(filename, ios::trunc);
+  } else if (strlen(configname) != 0) {
+    strcpy(filename, configname);
+    output.open(configname, ios::trunc);
+    } else {
+      strcpy(filename, DEFAULTCONFIG);
+      output.open(DEFAULTCONFIG, ios::trunc);
+    }
+  output.close();
+  output.clear();
+  Log() << Verbose(0) << "Saving of config file ... " << endl;
+  if (Save(filename, periode, mol))
+    Log() << Verbose(0) << "\t... successful." << endl;
+  else
+    Log() << Verbose(0) << "\t... failed." << endl;
+
+  // and save to xyz file
+  if (ConfigFileName != NULL) {
+    strcpy(filename, ConfigFileName);
+    strcat(filename, ".xyz");
+    output.open(filename, ios::trunc);
+  }
+  if (output == NULL) {
+    strcpy(filename,"main_pcp_linux");
+    strcat(filename, ".xyz");
+    output.open(filename, ios::trunc);
+  }
+  Log() << Verbose(0) << "Saving of XYZ file ... " << endl;
+  if (mol->MDSteps <= 1) {
+    if (mol->OutputXYZ(&output))
+      Log() << Verbose(0) << "\t... successful." << endl;
+    else
+      Log() << Verbose(0) << "\t... failed." << endl;
+  } else {
+    if (mol->OutputTrajectoriesXYZ(&output))
+      Log() << Verbose(0) << "\t... successful." << endl;
+    else
+      Log() << Verbose(0) << "\t... failed." << endl;
+  }
+  output.close();
+  output.clear();
+
+  // and save as MPQC configuration
+  if (ConfigFileName != NULL)
+    strcpy(filename, ConfigFileName);
+  if (output == NULL)
+    strcpy(filename,"main_pcp_linux");
+  Log() << Verbose(0) << "Saving as mpqc input .. " << endl;
+  if (SaveMPQC(filename, mol))
+    Log() << Verbose(0) << "\t... done." << endl;
+  else
+    Log() << Verbose(0) << "\t... failed." << endl;
+
+  // don't destroy molecule as it contains all our atoms
+  //World::getInstance().destroyMolecule(mol);
+};
+
+/** Reads parameter from a parsed file.
+ * The file is either parsed for a certain keyword or if null is given for
+ * the value in row yth and column xth. If the keyword was necessity#critical,
+ * then an error is thrown and the programme aborted.
+ * \warning value is modified (both in contents and position)!
+ * \param verbose 1 - print found value to stderr, 0 - don't
+ * \param *file file to be parsed
+ * \param name Name of value in file (at least 3 chars!)
+ * \param sequential 1 - do not reset file pointer to begin of file, 0 - set to beginning
+ *        (if file is sequentially parsed this can be way faster! However, beware of multiple values per line, as whole line is read -
+ *         best approach: 0 0 0 1 (not resetted only on last value of line) - and of yth, which is now
+ *         counted from this unresetted position!)
+ * \param xth Which among a number of parameters it is (in grid case it's row number as grid is read as a whole!)
+ * \param yth In grid case specifying column number, otherwise the yth \a name matching line
+ * \param type Type of the Parameter to be read
+ * \param value address of the value to be read (must have been allocated)
+ * \param repetition determines, if the keyword appears multiply in the config file, which repetition shall be parsed, i.e. 1 if not multiply
+ * \param critical necessity of this keyword being specified (optional, critical)
+ * \return 1 - found, 0 - not found
+ * \note Routine is taken from the pcp project and hack-a-slack adapted to C++
+ */
+int ParseForParameter(const int verbose, ifstream * const file, const char * const name, const int sequential, const int xth, const int yth, const int type, void * value, const int repetition, const int critical) {
+  int i = 0;
+  int j = 0;  // loop variables
+  int length = 0;
+  int maxlength = -1;
+  long file_position = file->tellg(); // mark current position
+  char *dummy1 = NULL;
+  char *dummy = NULL;
+  char free_dummy[MAXSTRINGSIZE];    // pointers in the line that is read in per step
+  dummy1 = free_dummy;
+
+  //fprintf(stderr,"Parsing for %s\n",name);
+  if (repetition == 0)
+    //Error(SomeError, "ParseForParameter(): argument repetition must not be 0!");
+    return 0;
+
+  int line = 0; // marks line where parameter was found
+  int found = (type >= grid) ? 0 : (-yth + 1);  // marks if yth parameter name was found
+  while((found != repetition)) {
+    dummy1 = dummy = free_dummy;
+    do {
+      file->getline(dummy1, 256); // Read the whole line
+      if (file->eof()) {
+        if ((critical) && (found == 0)) {
+          //Error(InitReading, name);
+          fprintf(stderr,"Error:InitReading, critical %s not found\n", name);
+          exit(255);
+        } else {
+          //if (!sequential)
+          file->clear();
+          file->seekg(file_position, ios::beg);  // rewind to start position
+          return 0;
+        }
+      }
+      line++;
+    } while (dummy != NULL && dummy1 != NULL && ((dummy1[0] == '#') || (dummy1[0] == '\0'))); // skip commentary and empty lines
+
+    // C++ getline removes newline at end, thus re-add
+    if ((dummy1 != NULL) && (strchr(dummy1,'\n') == NULL)) {
+      i = strlen(dummy1);
+      dummy1[i] = '\n';
+      dummy1[i+1] = '\0';
+    }
+    //fprintf(stderr,"line %i ends at %i, newline at %i\n", line, strlen(dummy1), strchr(dummy1,'\n')-free_dummy);
+
+    if (dummy1 == NULL) {
+      if (verbose) fprintf(stderr,"Error reading line %i\n",line);
+    } else {
+      //fprintf(stderr,"Now parsing the line %i: %s\n", line, dummy1);
+    }
+    // Seek for possible end of keyword on line if given ...
+    if (name != NULL) {
+      dummy = strchr(dummy1,'\t');  // set dummy on first tab or space which ever's nearer
+      if (dummy == NULL) {
+        dummy = strchr(dummy1, ' ');  // if not found seek for space
+        while ((dummy != NULL) && ((*dummy == '\t') || (*dummy == ' ')))    // skip some more tabs and spaces if necessary
+          dummy++;
+      }
+      if (dummy == NULL) {
+        dummy = strchr(dummy1, '\n'); // set on line end then (whole line = keyword)
+        //fprintf(stderr,"Error: Cannot find tabs or spaces on line %i in search for %s\n", line, name);
+        //Error(FileOpenParams, NULL);
+      } else {
+        //fprintf(stderr,"found tab at %i\n",(char *)dummy-(char *)dummy1);
+      }
+    } else dummy = dummy1;
+    // ... and check if it is the keyword!
+    //fprintf(stderr,"name %p, dummy %i/%c, dummy1 %i/%c, strlen(name) %i\n", &name, dummy, *dummy, dummy1, *dummy1, strlen(name));
+    if ((name == NULL) || (((dummy-dummy1 >= 3) && (strncmp(dummy1, name, strlen(name)) == 0)) && ((unsigned int)(dummy-dummy1) == strlen(name)))) {
+      found++; // found the parameter!
+      //fprintf(stderr,"found %s at line %i between %i and %i\n", name, line, dummy1, dummy);
+
+      if (found == repetition) {
+        for (i=0;i<xth;i++) { // i = rows
+          if (type >= grid) {
+            // grid structure means that grid starts on the next line, not right after keyword
+            dummy1 = dummy = free_dummy;
+            do {
+              file->getline(dummy1, 256); // Read the whole line, skip commentary and empty ones
+              if (file->eof()) {
+                if ((critical) && (found == 0)) {
+                  //Error(InitReading, name);
+                  fprintf(stderr,"Error:InitReading, critical %s not found\n", name);
+                  exit(255);
+                } else {
+                  //if (!sequential)
+                  file->clear();
+                  file->seekg(file_position, ios::beg);  // rewind to start position
+                  return 0;
+                }
+              }
+              line++;
+            } while ((dummy1[0] == '#') || (dummy1[0] == '\n'));
+            if (dummy1 == NULL){
+              if (verbose) fprintf(stderr,"Error reading line %i\n", line);
+            } else {
+              //fprintf(stderr,"Reading next line %i: %s\n", line, dummy1);
+            }
+          } else { // simple int, strings or doubles start in the same line
+            while ((*dummy == '\t') || (*dummy == ' '))   // skip interjacent tabs and spaces
+              dummy++;
+          }
+          // C++ getline removes newline at end, thus re-add
+          if ((dummy1 != NULL) && (strchr(dummy1,'\n') == NULL)) {
+            j = strlen(dummy1);
+            dummy1[j] = '\n';
+            dummy1[j+1] = '\0';
+          }
+
+          int start = (type >= grid) ? 0 : yth-1 ;
+          for (j=start;j<yth;j++) { // j = columns
+            // check for lower triangular area and upper triangular area
+            if ( ((i > j) && (type == upper_trigrid)) || ((j > i) && (type == lower_trigrid))) {
+              *((double *)value) = 0.0;
+              fprintf(stderr,"%f\t",*((double *)value));
+              value = (void *)((long)value + sizeof(double));
+              //value += sizeof(double);
+            } else {
+              // otherwise we must skip all interjacent tabs and spaces and find next value
+              dummy1 = dummy;
+              dummy = strchr(dummy1, '\t'); // seek for tab or space
+              if (dummy == NULL)
+                dummy = strchr(dummy1, ' ');  // if not found seek for space
+              if (dummy == NULL) { // if still zero returned ...
+                dummy = strchr(dummy1, '\n');  // ... at line end then
+                if ((j < yth-1) && (type < 4)) {  // check if xth value or not yet
+                  if (critical) {
+                    if (verbose) fprintf(stderr,"Error: EoL at %i and still missing %i value(s) for parameter %s\n", line, yth-j, name);
+                    //return 0;
+                    exit(255);
+                    //Error(FileOpenParams, NULL);
+                  } else {
+                    //if (!sequential)
+                    file->clear();
+                    file->seekg(file_position, ios::beg);  // rewind to start position
+                    return 0;
+                  }
+                }
+              } else {
+                //fprintf(stderr,"found tab at %i\n",(char *)dummy-(char *)free_dummy);
+              }
+              if (*dummy1 == '#') {
+                // found comment, skipping rest of line
+                //if (verbose) fprintf(stderr,"Error: '#' at %i and still missing %i value(s) for parameter %s\n", line, yth-j, name);
+                if (!sequential) { // here we need it!
+                  file->seekg(file_position, ios::beg);  // rewind to start position
+                }
+                return 0;
+              }
+              //fprintf(stderr,"value from %i to %i\n",(char *)dummy1-(char *)free_dummy,(char *)dummy-(char *)free_dummy);
+              switch(type) {
+                case (row_int):
+                  *((int *)value) = atoi(dummy1);
+                  if ((verbose) && (i==0) && (j==0)) fprintf(stderr,"%s = ", name);
+                  if (verbose) fprintf(stderr,"%i\t",*((int *)value));
+                    value = (void *)((long)value + sizeof(int));
+                    //value += sizeof(int);
+                  break;
+                case(row_double):
+                case(grid):
+                case(lower_trigrid):
+                case(upper_trigrid):
+                  *((double *)value) = atof(dummy1);
+                  if ((verbose) && (i==0) && (j==0)) fprintf(stderr,"%s = ", name);
+                  if (verbose) fprintf(stderr,"%lg\t",*((double *)value));
+                  value = (void *)((long)value + sizeof(double));
+                  //value += sizeof(double);
+                  break;
+                case(double_type):
+                  *((double *)value) = atof(dummy1);
+                  if ((verbose) && (i == xth-1)) fprintf(stderr,"%s = %lg\n", name, *((double *) value));
+                  //value += sizeof(double);
+                  break;
+                case(int_type):
+                  *((int *)value) = atoi(dummy1);
+                  if ((verbose) && (i == xth-1)) fprintf(stderr,"%s = %i\n", name, *((int *) value));
+                  //value += sizeof(int);
+                  break;
+                default:
+                case(string_type):
+                  if (value != NULL) {
+                    //if (maxlength == -1) maxlength = strlen((char *)value); // get maximum size of string array
+                    maxlength = MAXSTRINGSIZE;
+                    length = maxlength > (dummy-dummy1) ? (dummy-dummy1) : maxlength; // cap at maximum
+                    strncpy((char *)value, dummy1, length);  // copy as much
+                    ((char *)value)[length] = '\0';  // and set end marker
+                    if ((verbose) && (i == xth-1)) fprintf(stderr,"%s is '%s' (%i chars)\n",name,((char *) value), length);
+                    //value += sizeof(char);
+                  } else {
+                  }
+                break;
+              }
+            }
+            while (*dummy == '\t')
+              dummy++;
+          }
+        }
+      }
+    }
+  }
+  if ((type >= row_int) && (verbose))
+    fprintf(stderr,"\n");
+  if (!sequential) {
+    file->clear();
+    file->seekg(file_position, ios::beg);  // rewind to start position
+  }
+  //fprintf(stderr, "End of Parsing\n\n");
+
+  return (found); // true if found, false if not
+}
+
+
+/** Reads parameter from a parsed file.
+ * The file is either parsed for a certain keyword or if null is given for
+ * the value in row yth and column xth. If the keyword was necessity#critical,
+ * then an error is thrown and the programme aborted.
+ * \warning value is modified (both in contents and position)!
+ * \param verbose 1 - print found value to stderr, 0 - don't
+ * \param *FileBuffer pointer to buffer structure
+ * \param name Name of value in file (at least 3 chars!)
+ * \param sequential 1 - do not reset file pointer to begin of file, 0 - set to beginning
+ *        (if file is sequentially parsed this can be way faster! However, beware of multiple values per line, as whole line is read -
+ *         best approach: 0 0 0 1 (not resetted only on last value of line) - and of yth, which is now
+ *         counted from this unresetted position!)
+ * \param xth Which among a number of parameters it is (in grid case it's row number as grid is read as a whole!)
+ * \param yth In grid case specifying column number, otherwise the yth \a name matching line
+ * \param type Type of the Parameter to be read
+ * \param value address of the value to be read (must have been allocated)
+ * \param repetition determines, if the keyword appears multiply in the config file, which repetition shall be parsed, i.e. 1 if not multiply
+ * \param critical necessity of this keyword being specified (optional, critical)
+ * \return 1 - found, 0 - not found
+ * \note Routine is taken from the pcp project and hack-a-slack adapted to C++
+ */
+int ParseForParameter(const int verbose, struct ConfigFileBuffer * const FileBuffer, const char * const name, const int sequential, const int xth, const int yth, const int type, void * value, const int repetition, const int critical) {
+  int i = 0;
+  int j = 0;  // loop variables
+  int length = 0;
+  int maxlength = -1;
+  int OldCurrentLine = FileBuffer->CurrentLine;
+  char *dummy1 = NULL;
+  char *dummy = NULL;    // pointers in the line that is read in per step
+
+  //fprintf(stderr,"Parsing for %s\n",name);
+  if (repetition == 0)
+    //Error(SomeError, "ParseForParameter(): argument repetition must not be 0!");
+    return 0;
+
+  int line = 0; // marks line where parameter was found
+  int found = (type >= grid) ? 0 : (-yth + 1);  // marks if yth parameter name was found
+  while((found != repetition)) {
+    dummy1 = dummy = NULL;
+    do {
+      dummy1 = FileBuffer->buffer[ FileBuffer->LineMapping[FileBuffer->CurrentLine++] ];
+      if (FileBuffer->CurrentLine >= FileBuffer->NoLines) {
+        if ((critical) && (found == 0)) {
+          //Error(InitReading, name);
+          fprintf(stderr,"Error:InitReading, critical %s not found\n", name);
+          exit(255);
+        } else {
+          FileBuffer->CurrentLine = OldCurrentLine; // rewind to start position
+          return 0;
+        }
+      }
+      if (dummy1 == NULL) {
+        if (verbose) fprintf(stderr,"Error reading line %i\n",line);
+      } else {
+        //fprintf(stderr,"Now parsing the line %i: %s\n", line, dummy1);
+      }
+      line++;
+    } while (dummy1 != NULL && ((dummy1[0] == '#') || (dummy1[0] == '\0'))); // skip commentary and empty lines
+
+    // Seek for possible end of keyword on line if given ...
+    if (name != NULL) {
+      dummy = strchr(dummy1,'\t');  // set dummy on first tab or space which ever's nearer
+      if (dummy == NULL) {
+        dummy = strchr(dummy1, ' ');  // if not found seek for space
+        while ((dummy != NULL) && ((*dummy == '\t') || (*dummy == ' ')))    // skip some more tabs and spaces if necessary
+          dummy++;
+      }
+      if (dummy == NULL) {
+        dummy = strchr(dummy1, '\n'); // set on line end then (whole line = keyword)
+        //fprintf(stderr,"Error: Cannot find tabs or spaces on line %i in search for %s\n", line, name);
+        //Error(FileOpenParams, NULL);
+      } else {
+        //fprintf(stderr,"found tab at %i\n",(char *)dummy-(char *)dummy1);
+      }
+    } else dummy = dummy1;
+    // ... and check if it is the keyword!
+    //fprintf(stderr,"name %p, dummy %i/%c, dummy1 %i/%c, strlen(name) %i\n", &name, dummy, *dummy, dummy1, *dummy1, strlen(name));
+    if ((name == NULL) || (((dummy-dummy1 >= 3) && (strncmp(dummy1, name, strlen(name)) == 0)) && ((unsigned int)(dummy-dummy1) == strlen(name)))) {
+      found++; // found the parameter!
+      //fprintf(stderr,"found %s at line %i between %i and %i\n", name, line, dummy1, dummy);
+
+      if (found == repetition) {
+        for (i=0;i<xth;i++) { // i = rows
+          if (type >= grid) {
+            // grid structure means that grid starts on the next line, not right after keyword
+            dummy1 = dummy = NULL;
+            do {
+              dummy1 = FileBuffer->buffer[ FileBuffer->LineMapping[ FileBuffer->CurrentLine++] ];
+              if (FileBuffer->CurrentLine >= FileBuffer->NoLines) {
+                if ((critical) && (found == 0)) {
+                  //Error(InitReading, name);
+                  fprintf(stderr,"Error:InitReading, critical %s not found\n", name);
+                  exit(255);
+                } else {
+                  FileBuffer->CurrentLine = OldCurrentLine; // rewind to start position
+                  return 0;
+                }
+              }
+              if (dummy1 == NULL) {
+                if (verbose) fprintf(stderr,"Error reading line %i\n", line);
+              } else {
+                //fprintf(stderr,"Reading next line %i: %s\n", line, dummy1);
+              }
+              line++;
+            } while ((dummy1 != NULL) && ((dummy1[0] == '#') || (dummy1[0] == '\n')));
+            dummy = dummy1;
+          } else { // simple int, strings or doubles start in the same line
+            while ((*dummy == '\t') || (*dummy == ' '))  // skip interjacent tabs and spaces
+              dummy++;
+          }
+
+          for (j=((type >= grid) ? 0 : yth-1);j<yth;j++) { // j = columns
+            // check for lower triangular area and upper triangular area
+            if ( ((i > j) && (type == upper_trigrid)) || ((j > i) && (type == lower_trigrid))) {
+              *((double *)value) = 0.0;
+              fprintf(stderr,"%f\t",*((double *)value));
+              value = (void *)((long)value + sizeof(double));
+              //value += sizeof(double);
+            } else {
+              // otherwise we must skip all interjacent tabs and spaces and find next value
+              dummy1 = dummy;
+              dummy = strchr(dummy1, '\t'); // seek for tab or space
+              if (dummy == NULL)
+                dummy = strchr(dummy1, ' ');  // if not found seek for space
+              if (dummy == NULL) { // if still zero returned ...
+                dummy = strchr(dummy1, '\n'); // ... at line end then
+                if ((j < yth-1) && (type < 4)) {  // check if xth value or not yet
+                  if (critical) {
+                    if (verbose) fprintf(stderr,"Error: EoL at %i and still missing %i value(s) for parameter %s\n", line, yth-j, name);
+                    //return 0;
+                    exit(255);
+                    //Error(FileOpenParams, NULL);
+                  } else {
+                    if (!sequential) { // here we need it!
+                      FileBuffer->CurrentLine = OldCurrentLine; // rewind to start position
+                    }
+                    return 0;
+                  }
+                }
+              } else {
+                //fprintf(stderr,"found tab at %i\n",(char *)dummy-(char *)free_dummy);
+              }
+              if (*dummy1 == '#') {
+                // found comment, skipping rest of line
+                //if (verbose) fprintf(stderr,"Error: '#' at %i and still missing %i value(s) for parameter %s\n", line, yth-j, name);
+                if (!sequential) { // here we need it!
+                  FileBuffer->CurrentLine = OldCurrentLine; // rewind to start position
+                }
+                return 0;
+              }
+              //fprintf(stderr,"value from %i to %i\n",(char *)dummy1-(char *)free_dummy,(char *)dummy-(char *)free_dummy);
+              switch(type) {
+                case (row_int):
+                  *((int *)value) = atoi(dummy1);
+                  if ((verbose) && (i==0) && (j==0)) fprintf(stderr,"%s = ", name);
+                  if (verbose) fprintf(stderr,"%i\t",*((int *)value));
+                    value = (void *)((long)value + sizeof(int));
+                    //value += sizeof(int);
+                  break;
+                case(row_double):
+                case(grid):
+                case(lower_trigrid):
+                case(upper_trigrid):
+                  *((double *)value) = atof(dummy1);
+                  if ((verbose) && (i==0) && (j==0)) fprintf(stderr,"%s = ", name);
+                  if (verbose) fprintf(stderr,"%lg\t",*((double *)value));
+                  value = (void *)((long)value + sizeof(double));
+                  //value += sizeof(double);
+                  break;
+                case(double_type):
+                  *((double *)value) = atof(dummy1);
+                  if ((verbose) && (i == xth-1)) fprintf(stderr,"%s = %lg\n", name, *((double *) value));
+                  //value += sizeof(double);
+                  break;
+                case(int_type):
+                  *((int *)value) = atoi(dummy1);
+                  if ((verbose) && (i == xth-1)) fprintf(stderr,"%s = %i\n", name, *((int *) value));
+                  //value += sizeof(int);
+                  break;
+                default:
+                case(string_type):
+                  if (value != NULL) {
+                    //if (maxlength == -1) maxlength = strlen((char *)value); // get maximum size of string array
+                    maxlength = MAXSTRINGSIZE;
+                    length = maxlength > (dummy-dummy1) ? (dummy-dummy1) : maxlength; // cap at maximum
+                    strncpy((char *)value, dummy1, length); // copy as much
+                    ((char *)value)[length] = '\0'; // and set end marker
+                    if ((verbose) && (i == xth-1)) fprintf(stderr,"%s is '%s' (%i chars)\n",name,((char *) value), length);
+                    //value += sizeof(char);
+                  } else {
+                  }
+                break;
+              }
+            }
+            while (*dummy == '\t')
+              dummy++;
+          }
+        }
+      }
+    }
+  }
+  if ((type >= row_int) && (verbose)) fprintf(stderr,"\n");
+  if (!sequential) {
+    FileBuffer->CurrentLine = OldCurrentLine; // rewind to start position
+  }
+  //fprintf(stderr, "End of Parsing\n\n");
+
+  return (found); // true if found, false if not
+}
+
+/** Reading of Thermostat related values from parameter file.
+ * \param *fb file buffer containing the config file
+ */
+void config::ParseThermostats(class ConfigFileBuffer * const fb)
+{
+  char * const thermo = new char[12];
+  const int verbose = 0;
+
+  // read desired Thermostat from file along with needed additional parameters
+  if (ParseForParameter(verbose,fb,"Thermostat", 0, 1, 1, string_type, thermo, 1, optional)) {
+    if (strcmp(thermo, Thermostats->ThermostatNames[0]) == 0) { // None
+      if (Thermostats->ThermostatImplemented[0] == 1) {
+        Thermostats->Thermostat = None;
+      } else {
+        DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
+        Thermostats->Thermostat = None;
+      }
+    } else if (strcmp(thermo, Thermostats->ThermostatNames[1]) == 0) { // Woodcock
+      if (Thermostats->ThermostatImplemented[1] == 1) {
+        Thermostats->Thermostat = Woodcock;
+        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &Thermostats->ScaleTempStep, 1, critical); // read scaling frequency
+      } else {
+        DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
+        Thermostats->Thermostat = None;
+      }
+    } else if (strcmp(thermo, Thermostats->ThermostatNames[2]) == 0) { // Gaussian
+      if (Thermostats->ThermostatImplemented[2] == 1) {
+        Thermostats->Thermostat = Gaussian;
+        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &Thermostats->ScaleTempStep, 1, critical); // read collision rate
+      } else {
+        DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
+        Thermostats->Thermostat = None;
+      }
+    } else if (strcmp(thermo, Thermostats->ThermostatNames[3]) == 0) { // Langevin
+      if (Thermostats->ThermostatImplemented[3] == 1) {
+        Thermostats->Thermostat = Langevin;
+        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->TempFrequency, 1, critical); // read gamma
+        if (ParseForParameter(verbose,fb,"Thermostat", 0, 3, 1, double_type, &Thermostats->alpha, 1, optional)) {
+          DoLog(2) && (Log() << Verbose(2) << "Extended Stochastic Thermostat detected with interpolation coefficient " << Thermostats->alpha << "." << endl);
+        } else {
+          Thermostats->alpha = 1.;
+        }
+      } else {
+        DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
+        Thermostats->Thermostat = None;
+      }
+    } else if (strcmp(thermo, Thermostats->ThermostatNames[4]) == 0) { // Berendsen
+      if (Thermostats->ThermostatImplemented[4] == 1) {
+        Thermostats->Thermostat = Berendsen;
+        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->TempFrequency, 1, critical); // read \tau_T
+      } else {
+        DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
+        Thermostats->Thermostat = None;
+      }
+    } else if (strcmp(thermo, Thermostats->ThermostatNames[5]) == 0) { // Nose-Hoover
+      if (Thermostats->ThermostatImplemented[5] == 1) {
+        Thermostats->Thermostat = NoseHoover;
+        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->HooverMass, 1, critical); // read Hoovermass
+        Thermostats->alpha = 0.;
+      } else {
+        DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
+        Thermostats->Thermostat = None;
+      }
+    } else {
+      DoLog(1) && (Log() << Verbose(1) << " Warning: thermostat name was not understood!" << endl);
+      Thermostats->Thermostat = None;
+    }
+  } else {
+    if ((Thermostats->TargetTemp != 0))
+      DoLog(2) && (Log() << Verbose(2) <<  "No thermostat chosen despite finite temperature MD, falling back to None." << endl);
+    Thermostats->Thermostat = None;
+  }
+  delete[](thermo);
+};
+
Index: src/config.hpp
===================================================================
--- src/config.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/config.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,139 @@
+/*
+ * config.hpp
+ *
+ *  Created on: Aug 3, 2009
+ *      Author: heber
+ */
+
+#ifndef CONFIG_HPP_
+#define CONFIG_HPP_
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string>
+
+/****************************************** forward declarations *****************************/
+
+class BondGraph;
+class ConfigFileBuffer;
+class molecule;
+class MoleculeListClass;
+class periodentafel;
+class ThermoStatContainer;
+
+/********************************************** declarations *******************************/
+
+/** The config file.
+ * The class contains all parameters that control a dft run also functions to load and save.
+ */
+class config {
+  public:
+    class BondGraph *BG;
+    class ThermoStatContainer *Thermostats;
+
+    int PsiType;
+    int MaxPsiDouble;
+    int PsiMaxNoUp;
+    int PsiMaxNoDown;
+    int MaxMinStopStep;
+    int InitMaxMinStopStep;
+    int ProcPEGamma;
+    int ProcPEPsi;
+    char *configname;
+    bool FastParsing;
+    double Deltat;
+    string basis;
+
+    char *databasepath;
+
+    int DoConstrainedMD;
+    int MaxOuterStep;
+
+  private:
+    char *mainname;
+    char *defaultpath;
+    char *pseudopotpath;
+
+    int DoOutVis;
+    int DoOutMes;
+    int DoOutNICS;
+    int DoOutOrbitals;
+    int DoOutCurrent;
+    int DoFullCurrent;
+    int DoPerturbation;
+    int DoWannier;
+    int CommonWannier;
+    double SawtoothStart;
+    int VectorPlane;
+    double VectorCut;
+    int UseAddGramSch;
+    int Seed;
+
+    int OutVisStep;
+    int OutSrcStep;
+    int MaxPsiStep;
+    double EpsWannier;
+
+    int MaxMinStep;
+    double RelEpsTotalEnergy;
+    double RelEpsKineticEnergy;
+    int MaxMinGapStopStep;
+    int MaxInitMinStep;
+    double InitRelEpsTotalEnergy;
+    double InitRelEpsKineticEnergy;
+    int InitMaxMinGapStopStep;
+
+    //double BoxLength[NDIM*NDIM];
+
+    double ECut;
+    int MaxLevel;
+    int RiemannTensor;
+    int LevRFactor;
+    int RiemannLevel;
+    int Lev0Factor;
+    int RTActualUse;
+    int AddPsis;
+
+    double RCut;
+    int StructOpt;
+    int IsAngstroem;
+    int RelativeCoord;
+    int MaxTypes;
+
+
+  public:
+  config();
+  ~config();
+
+  int TestSyntax(const char * const filename, const periodentafel * const periode) const;
+  void Load(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, MoleculeListClass * const &MolList);
+  void LoadOld(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, MoleculeListClass * const &MolList);
+  bool Save(const char * const filename, const periodentafel * const periode, molecule * const mol) const;
+  bool SaveMPQC(const char * const filename, const molecule * const mol) const;
+  bool SavePDB(const char * const filename, const MoleculeListClass * const MolList) const;
+  bool SavePDB(const char * const filename, const molecule * const mol) const;
+  bool SaveTREMOLO(const char * const filename, const molecule * const mol) const;
+  bool SaveTREMOLO(const char * const filename, const MoleculeListClass * const MolList) const;
+
+  void SaveAll(char *ConfigFileName, periodentafel *periode, MoleculeListClass *molecules);
+
+  void Edit();
+  bool GetIsAngstroem() const;
+  char *GetDefaultPath() const;
+  void SetDefaultPath(const char * const path);
+  void ParseThermostats(class ConfigFileBuffer * const fb);
+};
+
+int ParseForParameter(const int verbose, ifstream * const file, const char * const name, const int sequential, const int xth, const int yth, const int type, void * value, const int repetition, const int critical);
+int ParseForParameter(const int verbose, struct ConfigFileBuffer * const FileBuffer, const char * const name, const int sequential, const int xth, const int yth, const int type, void * value, const int repetition, const int critical);
+void LoadMolecule(molecule * const &mol, struct ConfigFileBuffer * const &FileBuffer, const periodentafel * const periode, const bool FastParsing);
+void PrepareFileBuffer(const char * const filename, struct ConfigFileBuffer *&FileBuffer);
+
+#endif /* CONFIG_HPP_ */
Index: src/datacreator.cpp
===================================================================
--- src/datacreator.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/datacreator.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,827 @@
+/** \file datacreator.cpp
+ *
+ * Declarations of assisting functions in creating data and plot files.
+ *
+ */
+
+//============================ INCLUDES ===========================
+
+#include "Helpers/MemDebug.hpp"
+
+#include "datacreator.hpp"
+#include "helpers.hpp"
+#include "parser.hpp"
+
+//=========================== FUNCTIONS============================
+
+/** Opens a file with \a *filename in \a *dir.
+ * \param output file handle on return
+ * \param *dir directory
+ * \param *filename name of file
+ * \return true if file has been opened
+ */
+bool OpenOutputFile(ofstream &output, const char *dir, const char *filename)
+{
+  stringstream name;
+  name << dir << "/" << filename;
+  output.open(name.str().c_str(), ios::out);
+  if (output == NULL) {
+    DoLog(0) && (Log() << Verbose(0) << "Unable to open " << name.str() << " for writing, is directory correct?" << endl);
+    return false;
+  }
+  return true;
+};
+
+/** Opens a file for appending with \a *filename in \a *dir.
+ * \param output file handle on return
+ * \param *dir directory
+ * \param *filename name of file
+ * \return true if file has been opened
+ */
+bool AppendOutputFile(ofstream &output, const char *dir, const char *filename)
+{
+  stringstream name;
+  name << dir << "/" << filename;
+  output.open(name.str().c_str(), ios::app);
+  if (output == NULL) {
+    DoLog(0) && (Log() << Verbose(0) << "Unable to open " << name.str() << " for writing, is directory correct?" << endl);
+    return false;
+  }
+  return true;
+};
+
+/** Plots an energy vs. order.
+ * \param &Fragments EnergyMatrix class containing matrix values
+ * \param KeySets KeySetContainer class holding bond KeySetContainer::Order
+ * \param *prefix prefix in filename (without ending)
+ * \param *msg message to be place in first line as a comment
+ * \return true if file was written successfully
+ */
+bool CreateDataEnergyOrder(class EnergyMatrix &Fragments, class KeySetsContainer &KeySets, const char *dir, const char *prefix, const char *msg, const char *datum)
+{
+  stringstream filename;
+  ofstream output;
+
+  filename << prefix << ".dat";
+  if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
+  DoLog(0) && (Log() << Verbose(0) << msg << endl);
+  output << "# " << msg << ", created on " << datum;
+  output << "#Order\tFrag.No.\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
+  for (int BondOrder=0;BondOrder<KeySets.Order;BondOrder++) {
+    for(int i=KeySets.FragmentsPerOrder[BondOrder];i--;) {
+      for(int j=Fragments.RowCounter[ KeySets.OrderSet[BondOrder][i] ];j--;)
+        for(int k=Fragments.ColumnCounter[ KeySets.OrderSet[BondOrder][i] ];k--;)
+          Fragments.Matrix[Fragments.MatrixCounter][j][k] += Fragments.Matrix[ KeySets.OrderSet[BondOrder][i] ][j][k];
+    }
+    output << BondOrder+1 << "\t" << KeySets.FragmentsPerOrder[BondOrder];
+    for (int l=0;l<Fragments.ColumnCounter[Fragments.MatrixCounter];l++)
+      output << scientific << "\t" << Fragments.Matrix[Fragments.MatrixCounter][ Fragments.RowCounter[Fragments.MatrixCounter]-1 ][l];
+    output << endl;
+  }
+  output.close();
+  return true;
+};
+
+/** Plots an energy error vs. order.
+ * \param &Energy EnergyMatrix class containing reference values (in MatrixCounter matrix)
+ * \param &Fragments EnergyMatrix class containing matrix values
+ * \param KeySets KeySetContainer class holding bond KeySetContainer::Order
+ * \param *prefix prefix in filename (without ending)
+ * \param *msg message to be place in first line as a comment
+ * \return true if file was written successfully
+ */
+bool CreateDataDeltaEnergyOrder(class EnergyMatrix &Energy, class EnergyMatrix &Fragments, class KeySetsContainer &KeySets, const char *dir, const char *prefix, const char *msg, const char *datum)
+{
+  stringstream filename;
+  ofstream output;
+
+  filename << prefix << ".dat";
+  if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
+  DoLog(0) && (Log() << Verbose(0) << msg << endl);
+  output << "# " << msg << ", created on " << datum;
+  output << "#Order\tFrag.No.\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
+  Fragments.SetLastMatrix(Energy.Matrix[Energy.MatrixCounter],0);
+  for (int BondOrder=0;BondOrder<KeySets.Order;BondOrder++) {
+    for(int i=KeySets.FragmentsPerOrder[BondOrder];i--;) {
+      for(int j=Fragments.RowCounter[ KeySets.OrderSet[BondOrder][i] ];j--;)
+        for(int k=Fragments.ColumnCounter[ KeySets.OrderSet[BondOrder][i] ];k--;)
+          Fragments.Matrix[Fragments.MatrixCounter][j][k] -= Fragments.Matrix[ KeySets.OrderSet[BondOrder][i] ][j][k];
+    }
+    output << BondOrder+1 << "\t" << KeySets.FragmentsPerOrder[BondOrder];
+    for (int l=0;l<Fragments.ColumnCounter[Energy.MatrixCounter];l++)
+      if (fabs(Energy.Matrix[Energy.MatrixCounter][ Energy.RowCounter[Energy.MatrixCounter]-1 ][l]) < MYEPSILON)
+        output << scientific << "\t" << Fragments.Matrix[Fragments.MatrixCounter][ Fragments.RowCounter[Fragments.MatrixCounter]-1 ][l];
+      else
+        output << scientific << "\t" << (Fragments.Matrix[Fragments.MatrixCounter][ Fragments.RowCounter[Fragments.MatrixCounter]-1 ][l] / Energy.Matrix[Energy.MatrixCounter][ Energy.RowCounter[Energy.MatrixCounter]-1 ][l]);
+    output << endl;
+  }
+  output.close();
+  return true;
+};
+
+/** Plot forces vs. order.
+ * \param &Fragments ForceMatrix class containing matrix values
+ * \param KeySets KeySetContainer class holding bond KeySetContainer::Order
+ * \param *prefix prefix in filename (without ending)
+ * \param *msg message to be place in first line as a comment
+ * \param *datum current date and time
+ * \return true if file was written successfully
+ */
+bool CreateDataForcesOrder(class ForceMatrix &Fragments, class KeySetsContainer &KeySets, const char *dir, const char *prefix,const  char *msg, const char *datum, void (*CreateForce)(class MatrixContainer &, int))
+{
+  stringstream filename;
+  ofstream output;
+
+  filename << prefix << ".dat";
+  if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
+  DoLog(0) && (Log() << Verbose(0) << msg << endl);
+  output << "# " << msg << ", created on " << datum;
+  output << "# Order\tFrag.No.\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
+  Fragments.SetLastMatrix(0.,0);
+  for (int BondOrder=0;BondOrder<KeySets.Order;BondOrder++) {
+    Fragments.SumSubForces(Fragments, KeySets, BondOrder, 1.);
+    output << BondOrder+1 << "\t" << KeySets.FragmentsPerOrder[BondOrder];
+    CreateForce(Fragments, Fragments.MatrixCounter);
+    for (int l=0;l<Fragments.ColumnCounter[Fragments.MatrixCounter];l++)
+       output << scientific << "\t" << Fragments.Matrix[Fragments.MatrixCounter][ Fragments.RowCounter[Fragments.MatrixCounter] ][l];
+    output << endl;
+  }
+  output.close();
+  return true;
+};
+
+/** Plot forces error vs. order.
+ * \param &Force ForceMatrix containing reference values (in MatrixCounter matrix)
+ * \param &Fragments ForceMatrix class containing matrix values
+ * \param KeySets KeySetContainer class holding bond KeySetContainer::Order
+ * \param *prefix prefix in filename (without ending)
+ * \param *msg message to be place in first line as a comment
+ * \param *datum current date and time
+ * \return true if file was written successfully
+ */
+bool CreateDataDeltaForcesOrder(class ForceMatrix &Force, class ForceMatrix &Fragments, class KeySetsContainer &KeySets, const char *dir, const char *prefix, const char *msg, const char *datum, void (*CreateForce)(class MatrixContainer &, int))
+{
+  stringstream filename;
+  ofstream output;
+
+  filename << prefix << ".dat";
+  if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
+  DoLog(0) && (Log() << Verbose(0) << msg << endl);
+  output << "# " << msg << ", created on " << datum;
+  output << "# Order\tFrag.No.\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
+  Fragments.SetLastMatrix(Force.Matrix[Force.MatrixCounter],0);
+  for (int BondOrder=0;BondOrder<KeySets.Order;BondOrder++) {
+    Fragments.SumSubForces(Fragments, KeySets, BondOrder, -1.);
+    output << BondOrder+1 << "\t" << KeySets.FragmentsPerOrder[BondOrder];
+    CreateForce(Fragments, Fragments.MatrixCounter);
+    for (int l=0;l<Fragments.ColumnCounter[Fragments.MatrixCounter];l++)
+       output << scientific << "\t" << Fragments.Matrix[Fragments.MatrixCounter][ Fragments.RowCounter[Fragments.MatrixCounter] ][l];
+    output << endl;
+  }
+  output.close();
+  return true;
+};
+
+/** Plot forces error vs. vs atom vs. order.
+ * \param &Force ForceMatrix containing reference values (in MatrixCounter matrix)
+ * \param &Fragments ForceMatrix class containing matrix values
+ * \param KeySets KeySetContainer class holding bond KeySetContainer::Order
+ * \param *prefix prefix in filename (without ending)
+ * \param *msg message to be place in first line as a comment
+ * \param *datum current date and time
+ * \return true if file was written successfully
+ */
+bool CreateDataDeltaForcesOrderPerAtom(class ForceMatrix &Force, class ForceMatrix &Fragments, class KeySetsContainer &KeySets, const char *dir, const char *prefix, const char *msg, const char *datum)
+{
+  stringstream filename;
+  ofstream output;
+  double norm = 0.;
+
+  filename << prefix << ".dat";
+  if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
+  DoLog(0) && (Log() << Verbose(0) << msg << endl);
+  output << "# " << msg << ", created on " << datum;
+  output << "# AtomNo\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
+  Fragments.SetLastMatrix(Force.Matrix[Force.MatrixCounter], 0);
+  for (int BondOrder=0;BondOrder<KeySets.Order;BondOrder++) {
+    //Log() << Verbose(0) << "Current order is " << BondOrder << "." << endl;
+    Fragments.SumSubForces(Fragments, KeySets, BondOrder, -1.);
+    // errors per atom
+    output << endl << "#Order\t" << BondOrder+1 << endl;
+    for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) {
+      output << Fragments.Indices[Fragments.MatrixCounter][j] << "\t";
+      for (int l=0;l<Fragments.ColumnCounter[ Fragments.MatrixCounter ];l++) {
+        if (((l+1) % 3) == 0) {
+          norm = 0.;
+          for (int m=0;m<NDIM;m++)
+            norm += Force.Matrix[Force.MatrixCounter][ j ][l+m]*Force.Matrix[Force.MatrixCounter][ j ][l+m];
+          norm = sqrt(norm);
+        }                                                                                                    
+//        if (norm < MYEPSILON)
+          output << scientific << Fragments.Matrix[Fragments.MatrixCounter][ j ][l] << "\t";
+//        else
+//          output << scientific << (Fragments.Matrix[Fragments.MatrixCounter][ j ][l] / norm) << "\t";
+      }
+      output << endl;
+    }
+    output << endl;
+  }
+  output.close();
+  return true;
+};
+
+/** Plot forces error vs. vs atom vs. order.
+ * \param &Fragments ForceMatrix class containing matrix values
+ * \param KeySets KeySetContainer class holding bond KeySetContainer::Order
+ * \param *prefix prefix in filename (without ending)
+ * \param *msg message to be place in first line as a comment
+ * \param *datum current date and time
+ * \return true if file was written successfully
+ */
+bool CreateDataForcesOrderPerAtom(class ForceMatrix &Fragments, class KeySetsContainer &KeySets, const char *dir, const char *prefix, const char *msg, const char *datum)
+{
+  stringstream filename;
+  ofstream output;
+
+  filename << prefix << ".dat";
+  if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
+  DoLog(0) && (Log() << Verbose(0) << msg << endl);
+  output << "# " << msg << ", created on " << datum;
+  output << "# AtomNo\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
+  for (int BondOrder=0;BondOrder<KeySets.Order;BondOrder++) {
+    //Log() << Verbose(0) << "Current order is " << BondOrder << "." << endl;
+    Fragments.SumSubForces(Fragments, KeySets, BondOrder, 1.);
+    // errors per atom
+    output << endl << "#Order\t" << BondOrder+1 << endl;
+    for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) {
+      output << Fragments.Indices[Fragments.MatrixCounter][j] << "\t";
+      for (int l=0;l<Fragments.ColumnCounter[ Fragments.MatrixCounter ];l++)
+        output << scientific << Fragments.Matrix[Fragments.MatrixCounter][ j ][l] << "\t";
+      output << endl;
+    }
+    output << endl;
+  }
+  output.close();
+  return true;
+};
+
+
+/** Plot hessian error vs. vs atom vs. order.
+ * \param &Hessian HessianMatrix containing reference values (in MatrixCounter matrix)
+ * \param &Fragments HessianMatrix class containing matrix values
+ * \param KeySets KeySetContainer class holding bond KeySetContainer::Order
+ * \param *prefix prefix in filename (without ending)
+ * \param *msg message to be place in first line as a comment
+ * \param *datum current date and time
+ * \return true if file was written successfully
+ */
+bool CreateDataDeltaHessianOrderPerAtom(class HessianMatrix &Hessian, class HessianMatrix &Fragments, class KeySetsContainer &KeySets, const char *dir, const char *prefix, const char *msg, const char *datum)
+{
+  stringstream filename;
+  ofstream output;
+
+  filename << prefix << ".dat";
+  if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 
+  DoLog(0) && (Log() << Verbose(0) << msg << endl);
+  output << "# " << msg << ", created on " << datum;
+  output << "# AtomNo\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
+  Fragments.SetLastMatrix(Hessian.Matrix[Hessian.MatrixCounter], 0);
+  for (int BondOrder=0;BondOrder<KeySets.Order;BondOrder++) {
+    //Log() << Verbose(0) << "Current order is " << BondOrder << "." << endl;
+    Fragments.SumSubHessians(Fragments, KeySets, BondOrder, -1.);
+    // errors per atom
+    output << endl << "#Order\t" << BondOrder+1 << endl;
+    for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) { 
+      output << Fragments.Indices[Fragments.MatrixCounter][j] << "\t";
+      for (int l=0;l<Fragments.ColumnCounter[ Fragments.MatrixCounter ];l++) {
+        output << scientific << Fragments.Matrix[Fragments.MatrixCounter][ j ][l] << "\t";
+      }
+      output << endl;
+    }
+    output << endl;
+  }
+  output.close();
+  return true;
+};
+
+/** Plot hessian error vs. vs atom vs. order in the frobenius norm.
+ * \param &Hessian HessianMatrix containing reference values (in MatrixCounter matrix)
+ * \param &Fragments HessianMatrix class containing matrix values
+ * \param KeySets KeySetContainer class holding bond KeySetContainer::Order
+ * \param *prefix prefix in filename (without ending)
+ * \param *msg message to be place in first line as a comment
+ * \param *datum current date and time
+ * \return true if file was written successfully
+ */
+bool CreateDataDeltaFrobeniusOrderPerAtom(class HessianMatrix &Hessian, class HessianMatrix &Fragments, class KeySetsContainer &KeySets, const char *dir, const char *prefix, const char *msg, const char *datum)
+{
+  stringstream filename;
+  ofstream output;
+  double norm = 0;
+  double tmp;
+
+  filename << prefix << ".dat";
+  if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 
+  DoLog(0) && (Log() << Verbose(0) << msg << endl);
+  output << "# " << msg << ", created on " << datum;
+  output << "# AtomNo\t";
+  Fragments.SetLastMatrix(Hessian.Matrix[Hessian.MatrixCounter], 0);
+  for (int BondOrder=0;BondOrder<KeySets.Order;BondOrder++) {
+    output << "Order" << BondOrder+1 << "\t";
+  }
+  output << endl;
+  output << Fragments.RowCounter[ Fragments.MatrixCounter ] << "\t";
+  for (int BondOrder=0;BondOrder<KeySets.Order;BondOrder++) {
+    //Log() << Verbose(0) << "Current order is " << BondOrder << "." << endl;
+    Fragments.SumSubHessians(Fragments, KeySets, BondOrder, -1.);
+    // frobenius norm of errors per atom
+    norm = 0.;
+    for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) { 
+      for (int l=0;l<Fragments.ColumnCounter[ Fragments.MatrixCounter ];l++) {
+        tmp = Fragments.Matrix[Fragments.MatrixCounter][ j ][l];
+        norm += tmp*tmp;
+      }
+    }
+    output << scientific << sqrt(norm)/(Fragments.RowCounter[ Fragments.MatrixCounter ]*Fragments.ColumnCounter[ Fragments.MatrixCounter] ) << "\t";
+  }
+  output << endl;
+  output.close();
+  return true;
+};
+
+/** Plot hessian error vs. vs atom vs. order.
+ * \param &Fragments HessianMatrix class containing matrix values
+ * \param KeySets KeySetContainer class holding bond KeySetContainer::Order
+ * \param *prefix prefix in filename (without ending)
+ * \param *msg message to be place in first line as a comment
+ * \param *datum current date and time
+ * \return true if file was written successfully
+ */
+bool CreateDataHessianOrderPerAtom(class HessianMatrix &Fragments, class KeySetsContainer &KeySets, const char *dir, const char *prefix, const char *msg, const char *datum)
+{
+  stringstream filename;
+  ofstream output;
+
+  filename << prefix << ".dat";
+  if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 
+  DoLog(0) && (Log() << Verbose(0) << msg << endl);
+  output << "# " << msg << ", created on " << datum;
+  output << "# AtomNo\t" << Fragments.Header[ Fragments.MatrixCounter ] << endl;
+  Fragments.SetLastMatrix(0., 0);
+  for (int BondOrder=0;BondOrder<KeySets.Order;BondOrder++) {
+    //Log() << Verbose(0) << "Current order is " << BondOrder << "." << endl;
+    Fragments.SumSubHessians(Fragments, KeySets, BondOrder, 1.);
+    // errors per atom
+    output << endl << "#Order\t" << BondOrder+1 << endl;
+    for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) { 
+      output << Fragments.Indices[Fragments.MatrixCounter][j] << "\t";
+      for (int l=0;l<Fragments.ColumnCounter[ Fragments.MatrixCounter ];l++)
+        output << scientific << Fragments.Matrix[Fragments.MatrixCounter][ j ][l] << "\t";
+      output << endl;
+    }
+    output << endl;
+  }
+  output.close();
+  return true;
+};
+
+/** Plot matrix vs. fragment.
+ */
+bool CreateDataFragment(class MatrixContainer &Fragment, class KeySetsContainer &KeySets, const char *dir, const char *prefix, const char *msg, const char *datum, void (*CreateFragment)(class MatrixContainer &, int))
+{
+  stringstream filename;
+  ofstream output;
+
+  filename << prefix << ".dat";
+  if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
+  DoLog(0) && (Log() << Verbose(0) << msg << endl);
+  output << "# " << msg << ", created on " << datum << endl;
+  output << "#Order\tFrag.No.\t" << Fragment.Header[ Fragment.MatrixCounter ] << endl;
+  for (int BondOrder=0;BondOrder<KeySets.Order;BondOrder++) {
+    for(int i=0;i<KeySets.FragmentsPerOrder[BondOrder];i++) {
+      output << BondOrder+1 << "\t" << KeySets.OrderSet[BondOrder][i]+1;
+      CreateFragment(Fragment, KeySets.OrderSet[BondOrder][i]);
+      for (int l=0;l<Fragment.ColumnCounter[ KeySets.OrderSet[BondOrder][i] ];l++)
+        output << scientific << "\t" << Fragment.Matrix[ KeySets.OrderSet[BondOrder][i] ][ Fragment.RowCounter[ KeySets.OrderSet[BondOrder][i] ] ][l];
+      output << endl;
+    }
+  }
+  output.close();
+  return true;
+};
+
+/** Copies fragment energy values into last matrix of \a Matrix with greatest total energy.
+ * \param &Matrix MatrixContainer with all fragment energy values
+ * \param &KeySets KeySetsContainer with associations of each fragment to a bond order
+ * \param BondOrder current bond order
+ */
+void CreateMaxFragmentOrder(class MatrixContainer &Fragments, class KeySetsContainer &KeySets, int BondOrder)
+{
+  for(int j=Fragments.RowCounter[ Fragments.MatrixCounter ];j--;) {
+    for(int i=KeySets.FragmentsPerOrder[BondOrder];i--;) {
+      if (fabs(Fragments.Matrix[ Fragments.MatrixCounter ][j][1]) < fabs(Fragments.Matrix[ KeySets.OrderSet[BondOrder][i] ][j][1])) {
+        for (int k=Fragments.ColumnCounter[ Fragments.MatrixCounter ];k--;)
+          Fragments.Matrix[ Fragments.MatrixCounter ][j][k] = Fragments.Matrix[ KeySets.OrderSet[BondOrder][i] ][j][k];
+      }
+    }
+  }
+};
+
+/** Copies fragment energy values into last matrix of \a Matrix with smallest total energy.
+ * \param &Matrix MatrixContainer with all fragment energy values
+ * \param &KeySets KeySetsContainer with associations of each fragment to a bond order
+ * \param BondOrder current bond order
+ */
+void CreateMinFragmentOrder(class MatrixContainer &Fragments, class KeySetsContainer &KeySets, int BondOrder)
+{
+  for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) {
+    int i=0;
+    do {  // first get a minimum value unequal to 0
+      for (int k=Fragments.ColumnCounter[ Fragments.MatrixCounter ];k--;)
+        Fragments.Matrix[ Fragments.MatrixCounter ][j][k] = Fragments.Matrix[ KeySets.OrderSet[BondOrder][i] ][j][k];
+      i++;
+    } while ((fabs(Fragments.Matrix[ Fragments.MatrixCounter ][j][1]) < MYEPSILON) && (i<KeySets.FragmentsPerOrder[BondOrder]));
+    for(;i<KeySets.FragmentsPerOrder[BondOrder];i++) { // then find lowest
+      if (fabs(Fragments.Matrix[ Fragments.MatrixCounter ][j][1]) > fabs(Fragments.Matrix[ KeySets.OrderSet[BondOrder][i] ][j][1])) {
+        for (int k=Fragments.ColumnCounter[ Fragments.MatrixCounter ];k--;)
+          Fragments.Matrix[ Fragments.MatrixCounter ][j][k] = Fragments.Matrix[ KeySets.OrderSet[BondOrder][i] ][j][k];
+      }
+    }
+  }
+};
+
+/** Plot matrix vs. fragment.
+ */
+bool CreateDataFragmentOrder(class MatrixContainer &Fragment, class KeySetsContainer &KeySets, const char *dir, const char *prefix, const char *msg, const char *datum, void (*CreateFragmentOrder)(class MatrixContainer &, class KeySetsContainer &, int))
+{
+  stringstream filename;
+  ofstream output;
+
+  filename << prefix << ".dat";
+  if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
+  DoLog(0) && (Log() << Verbose(0) << msg << endl);
+  output << "# " << msg << ", created on " << datum;
+  output << "#Order\tFrag.No.\t" << Fragment.Header[ Fragment.MatrixCounter ] << endl;
+  // max
+  for (int BondOrder=0;BondOrder<KeySets.Order;BondOrder++) {
+    Fragment.SetLastMatrix(0.,0);
+    CreateFragmentOrder(Fragment, KeySets, BondOrder);
+    output << BondOrder+1 << "\t" << KeySets.FragmentsPerOrder[BondOrder];
+    for (int l=0;l<Fragment.ColumnCounter[ Fragment.MatrixCounter ];l++)
+      output << scientific << "\t" << Fragment.Matrix[ Fragment.MatrixCounter ][ Fragment.RowCounter[ Fragment.MatrixCounter ]-1 ][l];
+    output << endl;
+  }
+  output.close();
+  return true;
+};
+
+/** Takes last but one row and copies into final row.
+ * \param Energy MatrixContainer with matrix values
+ * \param MatrixNumber the index for the ForceMatrix::matrix array
+ */
+void CreateEnergy(class MatrixContainer &Energy, int MatrixNumber)
+{
+  for(int k=0;k<Energy.ColumnCounter[MatrixNumber];k++)
+    Energy.Matrix[MatrixNumber][ Energy.RowCounter[MatrixNumber] ] [k] =  Energy.Matrix[MatrixNumber][ Energy.RowCounter[MatrixNumber]-1 ] [k];
+};
+
+/** Scans forces for the minimum in magnitude.
+ * Results are stored in the matrix ForceMatrix::MatrixCounter of \a Force.
+ * \param Force ForceMatrix class containing matrix values
+ * \param MatrixNumber the index for the ForceMatrix::matrix array
+ */
+void CreateMinimumForce(class MatrixContainer &Force, int MatrixNumber)
+{
+  for (int l=Force.ColumnCounter[MatrixNumber];l--;)
+    Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] = 0.;
+  for (int l=5;l<Force.ColumnCounter[MatrixNumber];l+=3) {
+    double stored = 0;
+    int k=0;
+    do {
+      for (int m=NDIM;m--;) {
+        stored += Force.Matrix[MatrixNumber][ k ][l+m]
+              * Force.Matrix[MatrixNumber][ k ][l+m];
+        Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l+m]  = Force.Matrix[MatrixNumber][ k ][l+m];
+      }
+      k++;
+    } while ((fabs(stored) < MYEPSILON) && (k<Force.RowCounter[MatrixNumber]));
+    for (;k<Force.RowCounter[MatrixNumber];k++) {
+      double tmp = 0;
+      for (int m=NDIM;m--;)
+        tmp += Force.Matrix[MatrixNumber][ k ][l+m]
+              * Force.Matrix[MatrixNumber][ k ][l+m];
+      if ((fabs(tmp) > MYEPSILON) && (tmp < stored)) {  // current force is greater than stored
+        for (int m=NDIM;m--;)
+          Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l+m]  = Force.Matrix[MatrixNumber][ k ][l+m];
+        stored = tmp;
+      }
+    }
+  }
+};
+
+/** Scans forces for the mean in magnitude.
+ * Results are stored in the matrix ForceMatrix::MatrixCounter of \a Force.
+ * \param Force ForceMatrix class containing matrix values
+  * \param MatrixNumber the index for the ForceMatrix::matrix array
+ */
+void CreateMeanForce(class MatrixContainer &Force, int MatrixNumber)
+{
+  int divisor = 0;
+  for (int l=Force.ColumnCounter[MatrixNumber];l--;)
+    Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] = 0.;
+  for (int l=5;l<Force.ColumnCounter[MatrixNumber];l+=3) {
+    double tmp = 0;
+    for (int k=Force.RowCounter[MatrixNumber];k--;) {
+      double norm = 0.;
+      for (int m=NDIM;m--;)
+        norm += Force.Matrix[MatrixNumber][ k ][l+m]
+              * Force.Matrix[MatrixNumber][ k ][l+m];
+      tmp += sqrt(norm);
+      if (fabs(norm) > MYEPSILON) divisor++;
+    }
+    tmp /= (double)divisor;
+    Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] = tmp;
+  }
+};
+
+/** Scans forces for the maximum in magnitude.
+ * Results are stored in the matrix ForceMatrix::MatrixCounter of \a Force.
+ * \param Force ForceMatrix class containing matrix values
+ * \param MatrixNumber the index for the ForceMatrix::matrix array
+ */
+void CreateMaximumForce(class MatrixContainer &Force, int MatrixNumber)
+{
+  for (int l=5;l<Force.ColumnCounter[MatrixNumber];l+=3) {
+    double stored = 0;
+    for (int k=Force.RowCounter[MatrixNumber];k--;) {
+      double tmp = 0;
+      for (int m=NDIM;m--;)
+        tmp += Force.Matrix[MatrixNumber][ k ][l+m]
+              * Force.Matrix[MatrixNumber][ k ][l+m];
+      if (tmp > stored) {  // current force is greater than stored
+        for (int m=NDIM;m--;)
+          Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l+m]  = Force.Matrix[MatrixNumber][ k ][l+m];
+        stored = tmp;
+      }
+    }
+  }
+};
+
+/** Leaves the Force.Matrix as it is.
+ * \param Force ForceMatrix class containing matrix values
+ * \param MatrixNumber the index for the ForceMatrix::matrix array
+*/
+void CreateSameForce(class MatrixContainer &Force, int MatrixNumber)
+{
+  // does nothing
+};
+
+/** Adds vectorwise all forces.
+ * Results are stored in the matrix ForceMatrix::MatrixCounter of \a Force.
+ * \param Force ForceMatrix class containing matrix values
+ * \param MatrixNumber the index for the ForceMatrix::matrix array
+ */
+void CreateVectorSumForce(class MatrixContainer &Force, int MatrixNumber)
+{
+  for (int l=Force.ColumnCounter[MatrixNumber];l--;)
+    Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] = 0.;
+  for (int l=0;l<Force.ColumnCounter[MatrixNumber];l++) {
+    for (int k=Force.RowCounter[MatrixNumber];k--;)
+      Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] += Force.Matrix[MatrixNumber][k][l];
+  }
+};
+
+/** Writes the standard pyxplot header info.
+ * \param keycolumns number of columns of the key
+ * \param *key position of key
+ * \param *logscale axis for logscale
+ * \param *extraline extra set lines if desired
+ * \param mxtics small tics at ...
+ * \param xtics large tics at ...
+ * \param *xlabel label for x axis
+ * \param *ylabel label for y axis
+ */
+void CreatePlotHeader(ofstream &output, const char *prefix, const int keycolumns, const char *key, const char *logscale, const char *extraline, const int mxtics, const int xtics, const char *xlabel, const char *ylabel)
+{
+  //output << "#!/home/heber/build/pyxplot/pyxplot" << endl << endl;
+  output << "reset" << endl;
+  output << "set keycolumns "<< keycolumns << endl;
+  output << "set key " << key << endl;
+  output << "set mxtics "<< mxtics << endl;
+  output << "set xtics "<< xtics << endl;
+  if (logscale != NULL)
+    output << "set logscale " << logscale << endl;
+  if (extraline != NULL)
+    output << extraline << endl;
+  output << "set xlabel '" << xlabel << "'" << endl;
+  output << "set ylabel '" << ylabel << "'" << endl;
+  output << "set terminal eps color" << endl;
+  output << "set output '"<< prefix << ".eps'" << endl;
+};
+
+/** Creates the pyxplotfile for energy data.
+ * \param Matrix MatrixContainer with matrix values
+ * \param KeySets contains bond order
+ * \param *dir directory
+ * \param *prefix prefix for all filenames (without ending)
+ * \param keycolumns number of columns of the key
+ * \param *key position of key
+ * \param logscale axis for logscale
+ * \param mxtics small tics at ...
+ * \param xtics large tics at ...
+ * \param xlabel label for x axis
+ * \param xlabel label for x axis
+ * \param *xrange xrange
+ * \param *yrange yrange
+ * \param *xargument number of column to plot against (x axis)
+ * \param uses using string for plot command
+ * \param (*CreatePlotLines) function reference that writes a single plot line
+ * \return true if file was written successfully
+ */
+bool CreatePlotOrder(class MatrixContainer &Matrix, const class KeySetsContainer &KeySets, const char *dir, const char *prefix, const int keycolumns, const char *key, const char *logscale, const char *extraline, const int mxtics, const int xtics, const char *xlabel, const char *ylabel, const char *xrange, const char *yrange, const char *xargument, const char *uses, void (*CreatePlotLines)(ofstream &, class MatrixContainer &, const char *, const char *, const char *))
+{
+  stringstream filename;
+  ofstream output;
+
+  filename << prefix << ".pyx";
+  if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
+  CreatePlotHeader(output, prefix, keycolumns, key, logscale, extraline, mxtics, xtics, xlabel, ylabel);
+  output << "plot " << xrange << " " << yrange << " \\" << endl;
+  CreatePlotLines(output, Matrix, prefix, xargument, uses);
+  output.close();
+  return true;
+};
+
+/** Writes plot lines for absolute energies.
+ * \param output file handler
+ * \param Energy MatrixContainer with matrix values
+ * \param *prefix prefix of data file
+ * \param *xargument number of column to plot against (x axis)
+ * \param *uses uses command
+ */
+void AbsEnergyPlotLine(ofstream &output, class MatrixContainer &Energy, const char *prefix, const char *xargument, const char *uses)
+{
+  stringstream line(Energy.Header[ Energy.MatrixCounter ]);
+  string token;
+
+  getline(line, token, '\t');
+  for (int i=2; i<= Energy.ColumnCounter[Energy.MatrixCounter];i++) {
+    getline(line, token, '\t');
+    while (token[0] == ' ') // remove leading white spaces
+      token.erase(0,1);
+    output << "'" << prefix << ".dat' title '" << token << "' using " << xargument << ":(abs($" << i+2 << ")) " << uses;
+    if (i != (Energy.ColumnCounter[Energy.MatrixCounter]))
+      output << ", \\";
+    output << endl;
+  }
+};
+
+/** Writes plot lines for energies.
+ * \param output file handler
+ * \param Energy MatrixContainer with matrix values
+ * \param *prefix prefix of data file
+ * \param *xargument number of column to plot against (x axis)
+ * \param *uses uses command
+ */
+void EnergyPlotLine(ofstream &output, class MatrixContainer &Energy, const char *prefix, const char *xargument, const char *uses)
+{
+  stringstream line(Energy.Header[Energy.MatrixCounter]);
+  string token;
+
+  getline(line, token, '\t');
+  for (int i=1; i<= Energy.ColumnCounter[Energy.MatrixCounter];i++) {
+    getline(line, token, '\t');
+    while (token[0] == ' ') // remove leading white spaces
+      token.erase(0,1);
+    output << "'" << prefix << ".dat' title '" << token << "' using " << xargument << ":" << i+2 << " " << uses;
+    if (i != (Energy.ColumnCounter[Energy.MatrixCounter]))
+      output << ", \\";
+    output << endl;
+  }
+};
+
+/** Writes plot lines for absolute force magnitudes.
+ * \param output file handler
+ * \param Force MatrixContainer with matrix values
+ * \param *prefix prefix of data file
+ * \param *xargument number of column to plot against (x axis)
+ * \param *uses uses command
+ */
+void ForceMagnitudePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses)
+{
+  stringstream line(Force.Header[Force.MatrixCounter]);
+  string token;
+
+  getline(line, token, '\t');
+  getline(line, token, '\t');
+  getline(line, token, '\t');
+  getline(line, token, '\t');
+  getline(line, token, '\t');
+  for (int i=7; i< Force.ColumnCounter[Force.MatrixCounter];i+=NDIM) {
+    getline(line, token, '\t');
+    while (token[0] == ' ') // remove leading white spaces
+      token.erase(0,1);
+    token.erase(token.length(), 1);  // kill residual index char (the '0')
+    output << "'" << prefix << ".dat' title '" << token << "' using " << xargument << ":(sqrt($" << i+1 << "*$" << i+1 << "+$" << i+2 << "*$" << i+2 << "+$" << i+3 << "*$" << i+3 << ")) " << uses;
+    if (i != (Force.ColumnCounter[Force.MatrixCounter]-1))
+      output << ", \\";
+    output << endl;
+    getline(line, token, '\t');
+    getline(line, token, '\t');
+  }
+};
+
+/** Writes plot lines for first component of force vector.
+ * \param output file handler
+ * \param Force MatrixContainer with matrix values
+ * \param *prefix prefix of data file
+ * \param *xargument number of column to plot against (x axis)
+ * \param *uses uses command
+ */
+void AbsFirstForceValuePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses)
+{
+  stringstream line(Force.Header[Force.MatrixCounter]);
+  string token;
+
+  getline(line, token, '\t');
+  getline(line, token, '\t');
+  getline(line, token, '\t');
+  getline(line, token, '\t');
+  getline(line, token, '\t');
+  for (int i=7; i< Force.ColumnCounter[Force.MatrixCounter];i+=NDIM) {
+    getline(line, token, '\t');
+    while (token[0] == ' ') // remove leading white spaces
+      token.erase(0,1);
+    token.erase(token.length(), 1);  // kill residual index char (the '0')
+    output << "'" << prefix << ".dat' title '" << token << "' using " << xargument << ":(abs($" << i+1 << ")) " << uses;
+    if (i != (Force.ColumnCounter[Force.MatrixCounter]-1))
+      output << ", \\";
+    output << endl;
+    getline(line, token, '\t');
+    getline(line, token, '\t');
+  }
+};
+
+/** Writes plot lines for force vector as boxes with a fillcolor.
+ * \param output file handler
+ * \param Force MatrixContainer with matrix values
+ * \param *prefix prefix of data file
+ * \param *xargument number of column to plot against (x axis)
+ * \param *uses uses command
+ */
+void BoxesForcePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses)
+{
+  stringstream line(Force.Header[Force.MatrixCounter]);
+  const char *fillcolor[5] = {"black", "red", "blue", "green", "cyan"};
+  string token;
+
+  getline(line, token, '\t');
+  getline(line, token, '\t');
+  getline(line, token, '\t');
+  getline(line, token, '\t');
+  getline(line, token, '\t');
+  for (int i=7; i< Force.ColumnCounter[Force.MatrixCounter];i+=NDIM) {
+    getline(line, token, '\t');
+    while (token[0] == ' ') // remove leading white spaces
+      token.erase(0,1);
+    token.erase(token.length(), 1);  // kill residual index char (the '0')
+    output << "'" << prefix << ".dat' title '" << token << "' using ($" << xargument << "+" << fixed << setprecision(1) << (double)((i-7)/3)*0.2 << "):(sqrt($" << i+1 << "*$" << i+1 << "+$" << i+2 << "*$" << i+2 << "+$" << i+3 << "*$" << i+3 << ")) " << uses << " " << fillcolor[(i-7)/3];
+    if (i != (Force.ColumnCounter[Force.MatrixCounter]-1))
+      output << ", \\";
+    output << endl;
+    getline(line, token, '\t');
+    getline(line, token, '\t');
+  }
+};
+
+/** Writes plot lines for first force vector component as boxes with a fillcolor.
+ * \param output file handler
+ * \param Force MatrixContainer with matrix values
+ * \param *prefix prefix of data file
+ * \param *xargument number of column to plot against (x axis)
+ * \param *uses uses command
+ */
+void BoxesFirstForceValuePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses)
+{
+  stringstream line(Force.Header[Force.MatrixCounter]);
+  const char *fillcolor[5] = {"black", "red", "blue", "green", "cyan"};
+  string token;
+
+  getline(line, token, '\t');
+  getline(line, token, '\t');
+  getline(line, token, '\t');
+  getline(line, token, '\t');
+  getline(line, token, '\t');
+  for (int i=7; i< Force.ColumnCounter[Force.MatrixCounter];i+=NDIM) {
+    getline(line, token, '\t');
+    while (token[0] == ' ') // remove leading white spaces
+      token.erase(0,1);
+    token.erase(token.length(), 1);  // kill residual index char (the '0')
+    output << "'" << prefix << ".dat' title '" << token << "' using ($" << xargument << "+" << fixed << setprecision(1) << (double)((i-7)/3)*0.2 << "):" << i+1 << " " << uses << " " << fillcolor[(i-7)/3];
+    if (i != (Force.ColumnCounter[Force.MatrixCounter]-1))
+      output << ", \\";
+    output << endl;
+    getline(line, token, '\t');
+    getline(line, token, '\t');
+  }
+};
Index: src/datacreator.hpp
===================================================================
--- src/datacreator.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/datacreator.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,58 @@
+/** \file datacreator.cpp
+ *
+ * Definitions of assisting functions in creating data and plot files.
+ *
+ */
+
+#ifndef DATACREATOR_HPP_
+#define DATACREATOR_HPP_
+
+using namespace std;
+
+#include <iostream>
+
+/****************************************** forward declarations *****************************/
+
+class EnergyMatrix;
+class ForceMatrix;
+class HessianMatrix;
+class KeySetsContainer;
+class MatrixContainer;
+
+/********************************************** declarations *******************************/
+
+bool OpenOutputFile(ofstream &output, const char *dir, const char *filename);
+bool AppendOutputFile(ofstream &output, const char *dir, const char *filename);
+
+bool CreateDataEnergyOrder(class EnergyMatrix &Fragments, class KeySetsContainer &KeySet, const char *dir, const char *prefix, const char *msg, const char *datum);
+bool CreateDataDeltaEnergyOrder(class EnergyMatrix &Energy, class EnergyMatrix &Fragments, class KeySetsContainer &KeySet, const char *dir, const char *prefix, const char *msg, const char *datum);
+bool CreateDataForcesOrder(class ForceMatrix &Fragments, class KeySetsContainer &KeySet, const char *dir, const char *prefix, const char *msg, const char *datum, void (*CreateForce)(class MatrixContainer &, int));
+bool CreateDataForcesOrderPerAtom(class ForceMatrix &Fragments, class KeySetsContainer &KeySet, const char *dir, const char *prefix, const char *msg, const char *datum);
+bool CreateDataDeltaForcesOrder(class ForceMatrix &Force, class ForceMatrix &Fragments, class KeySetsContainer &KeySet, const char *dir, const char *prefix, const char *msg, const char *datum, void (*CreateForce)(class MatrixContainer &, int));
+bool CreateDataDeltaForcesOrderPerAtom(class ForceMatrix &Force, class ForceMatrix &Fragments, class KeySetsContainer &KeySet, const char *dir, const char *prefix, const char *msg, const char *datum); 
+bool CreateDataHessianOrderPerAtom(class HessianMatrix &Fragments, class KeySetsContainer &KeySet, const char *dir, const char *prefix, const char *msg, const char *datum); 
+bool CreateDataDeltaHessianOrderPerAtom(class HessianMatrix &Hessian, class HessianMatrix &Fragments, class KeySetsContainer &KeySet, const char *dir, const char *prefix, const char *msg, const char *datum); 
+bool CreateDataDeltaFrobeniusOrderPerAtom(class HessianMatrix &Hessian, class HessianMatrix &Fragments, class KeySetsContainer &KeySet, const char *dir, const char *prefix, const char *msg, const char *datum); 
+bool CreateDataFragment(class MatrixContainer &ForceFragments, class KeySetsContainer &KeySet, const char *dir, const char *prefix, const char *msg, const char *datum, void (*CreateForce)(class MatrixContainer &, int));
+bool CreateDataFragmentOrder(class MatrixContainer &Fragment, class KeySetsContainer &KeySet, const char *dir, const char *prefix, const char *msg, const char *datum, void (*CreateFragmentOrder)(class MatrixContainer &, class KeySetsContainer &, int));
+
+void CreateEnergy(class MatrixContainer &Energy, int MatrixNumber);
+void CreateMaxFragmentOrder(class MatrixContainer &Matrix, class KeySetsContainer &KeySet, int BondOrder);
+void CreateMinFragmentOrder(class MatrixContainer &Matrix, class KeySetsContainer &KeySet, int BondOrder);
+void CreateMinimumForce(class MatrixContainer &Force, int MatrixNumber);
+void CreateMeanForce(class MatrixContainer &Force, int MatrixNumber);
+void CreateMaximumForce(class MatrixContainer &Force, int MatrixNumber);
+void CreateSameForce(class MatrixContainer &Force, int MatrixNumber);
+void CreateVectorSumForce(class MatrixContainer &Force, int MatrixNumber);
+
+void CreatePlotHeader(ofstream &output, const char *prefix, const int keycolumns, const char *key, const char *logscale, const char *extraline, const int mxtics, const int xtics, const char *xlabel, const char *ylabel);
+bool CreatePlotOrder(class MatrixContainer &Matrix, const class KeySetsContainer &KeySet, const char *dir, const char *prefix, const int keycolumns, const char *key, const char *logscale, const char *extraline, const int mxtics, const int xtics, const char *xlabel, const char *ylabel, const char *xrange, const char *yrange, const char *xargument, const char *uses, void (*CreatePlotLines)(ofstream &, class MatrixContainer &, const char *, const char *, const char *));
+
+void AbsEnergyPlotLine(ofstream &output, class MatrixContainer &Energy, const char *prefix, const char *xargument, const char *uses);
+void EnergyPlotLine(ofstream &output, class MatrixContainer &Energy, const char *prefix, const char *xargument, const char *uses);
+void ForceMagnitudePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses);
+void AbsFirstForceValuePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses);
+void BoxesForcePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses);
+void BoxesFirstForceValuePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses);
+
+#endif /*DATACREATOR_HPP_*/
Index: src/defs.hpp
===================================================================
--- src/defs.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/defs.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,86 @@
+/** \file defs.hpp
+ * 
+ * Constant definitons and enumerations.
+ * 
+ */
+
+#ifndef DEFS_HPP_
+#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
+
+#define VERSIONSTRING "v1.0"
+
+#define LocalPath "./"
+
+//enum BondOrderScheme { NoScheme, BottomUp, TopDown, ANOVA, Combined }; //!< Fragmentation scheme used in BOSS
+
+enum EdgeType { Undetermined, TreeEdge, BackEdge }; //!< edge type in a graph after Depth-First-Search analysis.
+
+enum Shading { white, lightgray, darkgray, black };  //!< color in Breadth-First-Search analysis
+
+
+
+//enum CutCyclicBond { KeepBond,  SaturateBond }; //!< Saturation scheme either atom- or bondwise 
+
+// Specifting whether a value in the parameter file must be specified or is optional
+enum necessity { optional,    //!< parameter is optional, if not given sensible value is chosen
+                 critical     //!< parameter must be given or programme won't initiate
+               };
+
+// Specifying the status of the on command line given config file
+enum ConfigStatus { absent, empty, present };
+
+// Specifying the cast type to be read of a parameter, see ParseForParameter()
+enum value_type { string_type, double_type, int_type, row_int, row_double, grid, lower_trigrid, upper_trigrid}; 
+
+// maximum length of any char array
+#define 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
+
+// some values
+#define SOLVENTDENSITY_A 0.6022142
+#define SOLVENTDENSITY_a0 0.089238936
+
+
+#define UPDATECOUNT 10  //!< update ten sites per BOSSANOVA interval
+
+#define STD_MENU_LENGTH 60
+#define STD_MENU_TITLE_SPACER '='
+#define STD_SEPERATOR_SPACER '-'
+
+#define MOLECUILDER_NAME "Molecuilder"
+
+#endif /*DEFS_HPP_*/
Index: src/element.cpp
===================================================================
--- src/element.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/element.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,71 @@
+/** \file element.cpp
+ * 
+ * Function implementations for the class element.
+ * 
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include <iomanip>
+#include <fstream>
+
+#include "element.hpp"
+
+using namespace std;
+
+/************************************* Functions for class element **********************************/
+
+/** Constructor of class element.
+ */
+element::element() :
+  mass(0),
+  CovalentRadius(0),
+  VanDerWaalsRadius(0),
+	Z(-1),
+	previous(NULL),
+	next(NULL),
+	sort(NULL),
+	No(-1),
+	Valence(0),
+	NoValenceOrbitals(0)
+{
+};
+
+/** Destructor of class element.
+ */
+element::~element() {};
+
+/** Prints element data to \a *out.
+ * \param *out outstream
+ */
+bool element::Output(ostream * const out) const
+{ 
+  if (out != NULL) {
+    *out << name << "\t" << symbol << "\t" << period << "\t" << group << "\t" << block << "\t" << Z << "\t" << mass << "\t" << CovalentRadius << "\t" << VanDerWaalsRadius << endl;
+    //*out << Z << "\t"  << fixed << setprecision(11) << showpoint << mass << "g/mol\t" << name << "\t" << symbol << "\t" << endl;
+    return true;
+  } else
+    return false;
+};
+
+/** Prints element data to \a *out.
+ * \param *out outstream
+ * \param No  cardinal number of element
+ * \param NoOfAtoms total number of atom of this element type
+ */
+bool element::Checkout(ostream * const out, const int Number, const int NoOfAtoms) const
+{ 
+  if (out != NULL) {
+    *out << "Ion_Type" << Number << "\t" << NoOfAtoms << "\t" << Z << "\t1.0\t3\t3\t" << fixed << setprecision(11) << showpoint << mass << "\t" << name << "\t" << symbol <<endl;
+    return true;
+  } else
+    return false;
+};
+
+atomicNumber_t element::getNumber() const{
+  return Z;
+}
+
+string element::getSymbol() const{
+  return string(symbol);
+}
Index: src/element.hpp
===================================================================
--- src/element.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/element.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,64 @@
+/*
+ * element.hpp
+ *
+ *  Created on: Aug 3, 2009
+ *      Author: heber
+ */
+
+#ifndef ELEMENT_HPP_
+#define ELEMENT_HPP_
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <iostream>
+#include <string>
+
+#include "defs.hpp"
+#include "types.hpp"
+
+/********************************************** declarations *******************************/
+
+/** Chemical element.
+ * Class incorporates data for a certain chemical element to be referenced from atom class.
+ */
+class element {
+  public:
+    double mass;    //!< mass in g/mol
+    double CovalentRadius;  //!< covalent radius
+    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()
+    double Valence;   //!< number of valence electrons for this element
+    int NoValenceOrbitals;  //!< number of valence orbitals, used for determining bond degree in molecule::CreateConnectmatrix()
+    double HBondDistance[NDIM]; //!< distance in Angstrom of this element to hydrogen  (for single, double and triple bonds)
+    double HBondAngle[NDIM];     //!< typical angle for one, two, three bonded hydrogen (in degrees)
+
+  element();
+  ~element();
+
+  // accessor functions
+  atomicNumber_t getNumber() const;
+  std::string getSymbol() 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:
+};
+
+
+#endif /* ELEMENT_HPP_ */
Index: src/elements.db
===================================================================
--- src/elements.db	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/elements.db	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,112 @@
+#	Covalent	radius	of	each	element	in	Angstroem	from	CSD	(binding	is:	[Rcov(A)+Rcov(B)-t,Rcov(A)+Rcov(B)+t]	with	t	=	0.4A
+#Element	Name	Symbol	Period	Group	Block	Atomic	Number	AtomicWeight	Covalent	Radius	vdW	Radius
+Hydrogen	H	1	1	s	1	1.008	0.23	1.09
+Helium	He	1	18	p	2	4.003	1.5	1.4
+Lithium	Li	2	1	s	3	6.941	0.68	1.82
+Beryllium	Be	2	2	s	4	9.012	0.35	2
+Boron	B	2	13	p	5	10.811	0.83	2
+Carbon	C	2	14	p	6	12.011	0.68	1.7
+Nitrogen	N	2	15	p	7	14.007	0.68	1.55
+Oxygen	O	2	16	p	8	15.999	0.68	1.52
+Fluorine	F	2	17	p	9	18.998	0.64	1.47
+Neon	Ne	2	18	p	10	20.18	1.5	1.54
+Sodium	Na	3	1	s	11	22.991	0.97	2.27
+Magnesium	Mg	3	2	s	12	24.305	1.1	1.73
+Aluminium	Al	3	13	p	13	26.982	1.35	2
+Silicon	Si	3	14	p	14	28.086	1.2	2.1
+Phosphorus	P	3	15	p	15	30.974	1.05	1.8
+Sulphur	S	3	16	p	16	32.066	1.02	1.8
+Chlorine	Cl	3	17	p	17	35.453	0.99	1.75
+Argon	Ar	3	18	p	18	39.948	1.51	1.88
+Potassium	K	4	1	s	19	39.098	1.33	2.75
+Calcium	Ca	4	2	s	20	40.078	0.99	2
+Scandium	Sc	4	3	d	21	44.956	1.44	2
+Titanium	Ti	4	4	d	22	47.867	1.47	2
+Vanadium	V	4	5	d	23	50.942	1.33	2
+Chromium	Cr	4	6	d	24	51.996	1.35	2
+Manganese	Mn	4	7	d	25	54.938	1.35	2
+Iron	Fe	4	8	d	26	55.845	1.34	2
+Cobalt	Co	4	9	d	27	58.933	1.33	2
+Nickel	Ni	4	10	d	28	58.693	1.5	1.63
+Copper	Cu	4	11	d	29	63.546	1.52	1.4
+Zinc	Zn	4	12	d	30	65.39	1.45	1.39
+Gallium	Ga	4	13	p	31	69.723	1.22	1.87
+Germanium	Ge	4	14	p	32	72.61	1.17	2
+Arsenic	As	4	15	p	33	74.922	1.21	1.85
+Selenium	Se	4	16	p	34	78.96	1.22	1.9
+Bromine	Br	4	17	p	35	79.904	1.21	1.85
+Krypton	Kr	4	18	p	36	83.8	1.5	2.02
+Rubidium	Rb	5	1	s	37	85.468	1.47	2
+Strontium	Sr	5	2	s	38	87.62	1.12	2
+Yttrium	Y	5	3	d	39	88.906	1.78	2
+Zirconium	Zr	5	4	d	40	91.224	1.56	2
+Niobium	Nb	5	5	d	41	92.906	1.48	2
+Molybdenum	Mo	5	6	d	42	95.94	1.47	2
+Technetium	Tc	5	7	d	43	98	1.35	2
+Ruthenium	Ru	5	8	d	44	101.07	1.4	2
+Rhodium	Rh	5	9	d	45	102.906	1.45	2
+Palladium	Pd	5	10	d	46	106.42	1.5	1.63
+Silver	Ag	5	11	d	47	107.868	1.59	1.72
+Cadmium	Cd	5	12	d	48	112.411	1.69	1.58
+Indium	In	5	13	p	49	114.818	1.63	1.93
+Tin	Sn	5	14	p	50	118.71	1.46	2.17
+Antimony	Sb	5	15	p	51	121.76	1.46	2
+Tellurium	Te	5	16	p	52	127.6	1.47	2.06
+Iodine	I	5	17	p	53	126.904	1.4	1.98
+Xenon	Xe	5	18	p	54	131.29	1.5	2.16
+Caesium	Cs	6	1	s	55	132.905	1.67	2
+Barium	Ba	6	2	s	56	137.327	1.34	2
+Lanthanum	La	6Lan	19	f	57	138.906	1.87	2
+Cerium	Ce	6Lan	19	f	58	140.116	1.83	2
+Praseodymium	Pr	6Lan	19	f	59	140.908	1.82	2
+Neodymium	Nd	6Lan	19	f	60	144.24	1.81	2
+Promethium	Pm	6Lan	19	f	61	145	1.8	2
+Samarium	Sm	6Lan	19	f	62	150.36	1.8	2
+Europium	Eu	6Lan	19	f	63	151.964	1.99	2
+Gadolinium	Gd	6Lan	19	f	64	157.25	1.79	2
+Terbium	Tb	6Lan	19	f	65	158.925	1.76	2
+Dysprosium	Dy	6Lan	19	f	66	162.5	1.75	2
+Holmium	Ho	6Lan	19	f	67	164.93	1.74	2
+Erbium	Er	6Lan	19	f	68	167.26	1.73	2
+Thulium	Tm	6Lan	19	f	69	168.934	1.72	2
+Ytterbium	Yb	6Lan	19	f	70	173.04	1.94	2
+Lutetium	Lu	6	3	d	71	174.967	1.72	2
+Hafnium	Hf	6	4	d	72	178.49	1.57	2
+Tantalum	Ta	6	5	d	73	180.948	1.43	2
+Tungsten	W	6	6	d	74	183.84	1.37	2
+Rhenium	Re	6	7	d	75	186.207	1.35	2
+Osmium	Os	6	8	d	76	190.23	1.37	2
+Iridium	Ir	6	9	d	77	192.217	1.32	2
+Platinum	Pt	6	10	d	78	195.078	1.5	1.72
+Gold	Au	6	11	d	79	196.967	1.5	1.66
+Mercury	Hg	6	12	d	80	200.59	1.7	1.55
+Thallium	Tl	6	13	p	81	204.383	1.55	1.96
+Lead	Pb	6	14	p	82	207.2	1.54	2.02
+Bismuth	Bi	6	15	p	83	208.98	1.54	2
+Polonium	Po	6	16	p	84	210	1.68	2
+Astatine	At	6	17	p	85	210	1.21	2
+Radon	Rn	6	18	p	86	222	1.5	2
+Francium	Fr	7	1	s	87	223	1.5	2
+Radium	Ra	7	2	s	88	226	1.9	2
+Actinium	Ac	7Act	20	f	89	227	1.88	2
+Thorium	Th	7Act	20	f	90	232.038	1.79	2
+Protactinium	Pa	7Act	20	f	91	231.036	1.61	2
+Uranium	U	7Act	20	f	92	238.029	1.58	1.86
+Neptunium	Np	7Act	20	f	93	237	1.55	2
+Plutonium	Pu	7Act	20	f	94	244	1.53	2
+Americium	Am	7Act	20	f	95	243	1.51	2
+Curium	Cm	7Act	20	f	96	247	0.99	2
+Berkelium	Bk	7Act	20	f	97	247	1.54	2
+Californium	Cf	7Act	20	f	98	251	1.83	2
+Einsteinium	Es	7Act	20	f	99	252	1.5	2
+Fermium	Fm	7Act	20	f	100	257	1.5	2
+Mendelevium	Md	7Act	20	f	101	258	1.5	2
+Nobelium	No	7Act	20	f	102	259	1.5	2
+Lawrencium	Lr	7	3	d	103	262	1.5	2
+Rutherfordium	Rf	7	4	d	104	261	1.5	2
+Dubnium	Db	7	5	d	105	262	1.5	2
+Seaborgium	Sg	7	6	d	106	266	1.5	2
+Bohrium	Bh	7	7	d	107	264	1.5	2
+Hassium	Hs	7	8	d	108	269	1.5	2
+Meitnerium	Mt	7	9	d	109	268	1.5	2
+Darmstadtium	Ds	7	10	d	110	271	1.5	2
Index: src/elements_db.cpp
===================================================================
--- src/elements_db.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/elements_db.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,319 @@
+/*
+ * elements_db.cpp
+ *
+ *  Created on: 17.05.2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+const char *elementsDB =\
+"#	Covalent	radius	of	each	element	in	Angstroem	from	CSD	(binding	is:	[Rcov(A)+Rcov(B)-t,Rcov(A)+Rcov(B)+t]	with	t	=	0.4A\n\
+#Element	Name	Symbol	Period	Group	Block	Atomic	Number	AtomicWeight	Covalent	Radius	vdW	Radius\n\
+Hydrogen	H	1	1	s	1	1.008	0.23	1.09\n\
+Helium	He	1	18	p	2	4.003	1.50	1.40\n\
+Lithium	Li	2	1	s	3	6.941	0.68	1.82\n\
+Beryllium	Be	2	2	s	4	9.012	0.35	2.00\n\
+Boron	B	2	13	p	5	10.811	0.83	2.00\n\
+Carbon	C	2	14	p	6	12.011	0.68	1.70\n\
+Nitrogen	N	2	15	p	7	14.007	0.68	1.55\n\
+Oxygen	O	2	16	p	8	15.999	0.68	1.52\n\
+Fluorine	F	2	17	p	9	18.998	0.64	1.47\n\
+Neon	Ne	2	18	p	10	20.180	1.50	1.54\n\
+Sodium	Na	3	1	s	11	22.991	0.97	2.27\n\
+Magnesium	Mg	3	2	s	12	24.305	1.10	1.73\n\
+Aluminium	Al	3	13	p	13	26.982	1.35	2.00\n\
+Silicon	Si	3	14	p	14	28.086	1.20	2.10\n\
+Phosphorus	P	3	15	p	15	30.974	1.05	1.80\n\
+Sulphur	S	3	16	p	16	32.066	1.02	1.80\n\
+Chlorine	Cl	3	17	p	17	35.453	0.99	1.75\n\
+Argon	Ar	3	18	p	18	39.948	1.51	1.88\n\
+Potassium	K	4	1	s	19	39.098	1.33	2.75\n\
+Calcium	Ca	4	2	s	20	40.078	0.99	2.00\n\
+Scandium	Sc	4	3	d	21	44.956	1.44	2.00\n\
+Titanium	Ti	4	4	d	22	47.867	1.47	2.00\n\
+Vanadium	V	4	5	d	23	50.942	1.33	2.00\n\
+Chromium	Cr	4	6	d	24	51.996	1.35	2.00\n\
+Manganese	Mn	4	7	d	25	54.938	1.35	2.00\n\
+Iron	Fe	4	8	d	26	55.845	1.34	2.00\n\
+Cobalt	Co	4	9	d	27	58.933	1.33	2.00\n\
+Nickel	Ni	4	10	d	28	58.693	1.50	1.63\n\
+Copper	Cu	4	11	d	29	63.546	1.52	1.40\n\
+Zinc	Zn	4	12	d	30	65.390	1.45	1.39\n\
+Gallium	Ga	4	13	p	31	69.723	1.22	1.87\n\
+Germanium	Ge	4	14	p	32	72.610	1.17	2.00\n\
+Arsenic	As	4	15	p	33	74.922	1.21	1.85\n\
+Selenium	Se	4	16	p	34	78.960	1.22	1.90\n\
+Bromine	Br	4	17	p	35	79.904	1.21	1.85\n\
+Krypton	Kr	4	18	p	36	83.800	1.50	2.02\n\
+Rubidium	Rb	5	1	s	37	85.468	1.47	2.00\n\
+Strontium	Sr	5	2	s	38	87.620	1.12	2.00\n\
+Yttrium	Y	5	3	d	39	88.906	1.78	2.00\n\
+Zirconium	Zr	5	4	d	40	91.224	1.56	2.00\n\
+Niobium	Nb	5	5	d	41	92.906	1.48	2.00\n\
+Molybdenum	Mo	5	6	d	42	95.940	1.47	2.00\n\
+Technetium	Tc	5	7	d	43	98	1.35	2.00\n\
+Ruthenium	Ru	5	8	d	44	101.070	1.40	2.00\n\
+Rhodium	Rh	5	9	d	45	102.906	1.45	2.00\n\
+Palladium	Pd	5	10	d	46	106.420	1.50	1.63\n\
+Silver	Ag	5	11	d	47	107.868	1.59	1.72\n\
+Cadmium	Cd	5	12	d	48	112.411	1.69	1.58\n\
+Indium	In	5	13	p	49	114.818	1.63	1.93\n\
+Tin	Sn	5	14	p	50	118.71	1.46	2.17\n\
+Antimony	Sb	5	15	p	51	121.760	1.46	2.00\n\
+Tellurium	Te	5	16	p	52	127.600	1.47	2.06\n\
+Iodine	I	5	17	p	53	126.904	1.40	1.98\n\
+Xenon	Xe	5	18	p	54	131.290	1.50	2.16\n\
+Caesium	Cs	6	1	s	55	132.905	1.67	2.00\n\
+Barium	Ba	6	2	s	56	137.327	1.34	2.00\n\
+Lutetium	Lu	6	3	d	71	174.967	1.72	2.00\n\
+Hafnium	Hf	6	4	d	72	178.490	1.57	2.00\n\
+Tantalum	Ta	6	5	d	73	180.948	1.43	2.00\n\
+Tungsten	W	6	6	d	74	183.840	1.37	2.00\n\
+Rhenium	Re	6	7	d	75	186.207	1.35	2.00\n\
+Osmium	Os	6	8	d	76	190.230	1.37	2.00\n\
+Iridium	Ir	6	9	d	77	192.217	1.32	2.00\n\
+Platinum	Pt	6	10	d	78	195.078	1.50	1.72\n\
+Gold	Au	6	11	d	79	196.967	1.50	1.66\n\
+Mercury	Hg	6	12	d	80	200.590	1.70	1.55\n\
+Thallium	Tl	6	13	p	81	204.383	1.55	1.96\n\
+Lead	Pb	6	14	p	82	207.200	1.54	2.02\n\
+Bismuth	Bi	6	15	p	83	208.980	1.54	2.00\n\
+Polonium	Po	6	16	p	84	210	1.68	2.00\n\
+Astatine	At	6	17	p	85	210	1.21	2.00\n\
+Radon	Rn	6	18	p	86	222	1.50	2.00\n\
+Cerium	Ce	6Lan	19	f	58	140.116	1.83	2.00\n\
+Dysprosium	Dy	6Lan	19	f	66	162.500	1.75	2.00\n\
+Erbium	Er	6Lan	19	f	68	167.260	1.73	2.00\n\
+Europium	Eu	6Lan	19	f	63	151.964	1.99	2.00\n\
+Gadolinium	Gd	6Lan	19	f	64	157.250	1.79	2.00\n\
+Holmium	Ho	6Lan	19	f	67	164.930	1.74	2.00\n\
+Lanthanum	La	6Lan	19	f	57	138.906	1.87	2.00\n\
+Neodymium	Nd	6Lan	19	f	60	144.240	1.81	2.00\n\
+Promethium	Pm	6Lan	19	f	61	145	1.80	2.00\n\
+Praseodymium	Pr	6Lan	19	f	59	140.908	1.82	2.00\n\
+Samarium	Sm	6Lan	19	f	62	150.360	1.80	2.00\n\
+Terbium	Tb	6Lan	19	f	65	158.925	1.76	2.00\n\
+Thulium	Tm	6Lan	19	f	69	168.934	1.72	2.00\n\
+Ytterbium	Yb	6Lan	19	f	70	173.040	1.94	2.00\n\
+Francium	Fr	7	1	s	87	223	1.50	2.00\n\
+Radium	Ra	7	2	s	88	226	1.90	2.00\n\
+Lawrencium	Lr	7	3	d	103	262	1.50	2.00\n\
+Rutherfordium	Rf	7	4	d	104	261	1.50	2.00\n\
+Dubnium	Db	7	5	d	105	262	1.50	2.00\n\
+Seaborgium	Sg	7	6	d	106	266	1.50	2.00\n\
+Bohrium	Bh	7	7	d	107	264	1.50	2.00\n\
+Hassium	Hs	7	8	d	108	269	1.50	2.00\n\
+Meitnerium	Mt	7	9	d	109	268	1.50	2.00\n\
+Darmstadtium	Ds	7	10	d	110	271	1.50	2.00\n\
+Actinium	Ac	7Act	20	f	89	227	1.88	2.00\n\
+Americium	Am	7Act	20	f	95	243	1.51	2.00\n\
+Berkelium	Bk	7Act	20	f	97	247	1.54	2.00\n\
+Californium	Cf	7Act	20	f	98	251	1.83	2.00\n\
+Curium	Cm	7Act	20	f	96	247	0.99	2.00\n\
+Einsteinium	Es	7Act	20	f	99	252	1.50	2.00\n\
+Fermium	Fm	7Act	20	f	100	257	1.50	2.00\n\
+Mendelevium	Md	7Act	20	f	101	258	1.50	2.00\n\
+Nobelium	No	7Act	20	f	102	259	1.50	2.00\n\
+Neptunium	Np	7Act	20	f	93	237	1.55	2.00\n\
+Protactinium	Pa	7Act	20	f	91	231.036	1.61	2.00\n\
+Plutonium	Pu	7Act	20	f	94	244	1.53	2.00\n\
+Thorium	Th	7Act	20	f	90	232.038	1.79	2.00\n\
+Uranium	U	7Act	20	f	92	238.029	1.58	1.86\n\
+";
+
+const char *HbonddistanceDB =\
+"#atomic number bond distances for single, double and triple bond (-1 no bond)\n\
+1	0.74	-1	-1\n\
+2	0.77429209	-1	-1\n\
+5	1.23	1.19	1.18\n\
+6	1.09	1.076	1.06\n\
+7	1.04	1.02	1.01\n\
+8	0.96	0.957	-1\n\
+14	1.48	1.48	1.48\n\
+15	1.42	-1	-1\n\
+16	1.35	-1	-1\n\
+17	1.29	-1	-1\n\
+20	1.09	1.09	-1\n\
+34	1.47	-1	-1\n\
+35	1.44	-1	-1\n\
+";
+
+const char *HbondangleDB =\
+"# atomicnumber angles for single, double and triple bond (-1 no angle)\n\
+1	180	-1	-1\n\
+5	180	131.0	109.2\n\
+6	180	120	109.47\n\
+7	180	110	106.67\n\
+8	180	104.5	-1\n\
+14	180	120	109.47\n\
+15	180	-1	-1\n\
+16	180	-1	-1\n\
+17	180 -1 -1\n\
+20	180	120	109.47\n\
+34	180 -1 -1\n\
+35	180 -1 -1\n\
+";
+
+const char *orbitalsDB =\
+"# atomicnumber	numberoforbitals\n\
+1	1\n\
+2	0\n\
+3	1\n\
+4	2\n\
+5	3\n\
+6	4\n\
+7	3\n\
+8	2\n\
+9	1\n\
+10	0\n\
+11	1\n\
+12	2\n\
+13	3\n\
+14	4\n\
+15	3\n\
+16	2\n\
+17	1\n\
+18	0\n\
+19	1\n\
+20	4\n\
+21	3\n\
+22	4\n\
+23	5\n\
+24	6\n\
+25	4\n\
+26	3\n\
+27	3\n\
+28	2\n\
+29	2\n\
+30	2\n\
+31	3\n\
+32	4\n\
+33	3\n\
+34	2\n\
+35	1\n\
+36	0\n\
+37	1\n\
+38	2\n\
+39	3\n\
+40	4\n\
+41	5\n\
+42	6\n\
+43	6\n\
+44	8\n\
+45	4\n\
+46	4\n\
+47	1\n\
+48	2\n\
+49	3\n\
+50	4\n\
+51	3\n\
+52	2\n\
+53	1\n\
+54	0\n\
+55	1\n\
+56	2\n\
+57	3\n\
+58	4\n\
+59	3\n\
+60	4\n\
+61	3\n\
+62	3\n\
+63	3\n\
+64	3\n\
+65	4\n\
+66	3\n\
+67	3\n\
+68	3\n\
+69	3	\n\
+70	3\n\
+71	3\n\
+72	4\n\
+73	5\n\
+74	6\n\
+75	7\n\
+76	8\n\
+77	6\n\
+78	6\n\
+79	3\n\
+80	2\n\
+81	3\n\
+82	4\n\
+83	3\n\
+84	4\n\
+86	0\n\
+88	2\n\
+89	3\n\
+90	4\n\
+91	5\n\
+92	6\n\
+";
+
+const char *valenceDB =\
+"#atomicnumber numberofvalenceorbitals\n\
+1	0.10000000000000E+01\n\
+2	0.20000000000000E+01\n\
+3	0.10000000000000E+01\n\
+4	0.20000000000000E+01\n\
+5	0.30000000000000E+01\n\
+6	0.40000000000000E+01\n\
+7	0.50000000000000E+01\n\
+8	0.60000000000000E+01\n\
+9	0.70000000000000E+01\n\
+10	0.80000000000000E+01\n\
+11	0.10000000000000E+01\n\
+12	0.40000000000000E+01\n\
+13	.3000000000000000E+01\n\
+14	0.40000000000000E+01\n\
+15	0.50000000000000E+01\n\
+16	0.60000000000000E+01\n\
+17	0.70000000000000E+01\n\
+18	0.80000000000000E+01\n\
+19	0.30000000000000E+01\n\
+20	0.40000000000000E+01\n\
+21	0.30000000000000E+01\n\
+22	0.40000000000000E+01\n\
+23	0.50000000000000E+01\n\
+24	0.60000000000000E+01\n\
+25	0.70000000000000E+01\n\
+26	0.80000000000000E+01\n\
+27	0.90000000000000E+01\n\
+28	0.10000000000000E+02\n\
+29	0.11000000000000E+02\n\
+30	0.12000000000000E+02\n\
+31	3.00000000000000000\n\
+32	0.40000000000000E+01\n\
+33	5.00000000000000000\n\
+34	0.60000000000000E+01\n\
+35	0.70000000000000E+01\n\
+36	0.80000000000000E+01\n\
+37	0.10000000000000E+01\n\
+38	0.20000000000000E+01\n\
+39	0.30000000000000E+01\n\
+40	0.40000000000000E+01\n\
+41	0.50000000000000E+01\n\
+42	0.60000000000000E+01\n\
+43	0.70000000000000E+01\n\
+44	0.80000000000000E+01\n\
+45	0.90000000000000E+01\n\
+46	0.10000000000000E+02\n\
+47	0.11000000000000E+02\n\
+48	0.12000000000000E+02\n\
+49	0.30000000000000E+01\n\
+50	0.40000000000000E+01\n\
+51	0.50000000000000E+01\n\
+52	0.60000000000000E+01\n\
+53	0.70000000000000E+01\n\
+54	0.80000000000000E+01\n\
+55	0.10000000000000E+01\n\
+56	0.20000000000000E+01\n\
+72	0.40000000000000E+01\n\
+73	0.50000000000000E+01\n\
+74	0.60000000000000E+01\n\
+75	0.70000000000000E+01\n\
+76	0.80000000000000E+01\n\
+77	0.90000000000000E+01\n\
+78	0.10000000000000E+02\n\
+79	0.11000000000000E+02\n\
+80	0.12000000000000E+02\n\
+";
Index: src/elements_db.hpp
===================================================================
--- src/elements_db.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/elements_db.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,17 @@
+/*
+ * elements_db.hpp
+ *
+ *  Created on: 17.05.2010
+ *      Author: heber
+ */
+
+#ifndef ELEMENTS_DB_HPP_
+#define ELEMENTS_DB_HPP_
+
+extern const char *elementsDB;
+extern const char *HbonddistanceDB;
+extern const char *HbondangleDB;
+extern const char *orbitalsDB;
+extern const char *valenceDB;
+
+#endif /* ELEMENTS_DB_HPP_ */
Index: src/ellipsoid.cpp
===================================================================
--- src/ellipsoid.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/ellipsoid.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,445 @@
+/*
+ * ellipsoid.cpp
+ *
+ *  Created on: Jan 20, 2009
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include <gsl/gsl_multimin.h>
+#include <gsl/gsl_vector.h>
+
+#include <iomanip>
+
+#include <set>
+
+#include "boundary.hpp"
+#include "ellipsoid.hpp"
+#include "linkedcell.hpp"
+#include "log.hpp"
+#include "tesselation.hpp"
+#include "vector.hpp"
+#include "verbose.hpp"
+
+/** Determines squared distance for a given point \a x to surface of ellipsoid.
+ * \param x given point
+ * \param EllipsoidCenter center of ellipsoid
+ * \param EllipsoidLength[3] three lengths of half axis of ellipsoid
+ * \param EllipsoidAngle[3] three rotation angles of ellipsoid
+ * \return squared distance from point to surface
+ */
+double SquaredDistanceToEllipsoid(Vector &x, Vector &EllipsoidCenter, double *EllipsoidLength, double *EllipsoidAngle)
+{
+  Vector helper, RefPoint;
+  double distance = -1.;
+  double Matrix[NDIM*NDIM];
+  double InverseLength[3];
+  double psi,theta,phi; // euler angles in ZX'Z'' convention
+
+  //Log() << Verbose(3) << "Begin of SquaredDistanceToEllipsoid" << endl;
+
+  for(int i=0;i<3;i++)
+    InverseLength[i] = 1./EllipsoidLength[i];
+
+  // 1. translate coordinate system so that ellipsoid center is in origin
+  RefPoint = helper = x - EllipsoidCenter;
+  //Log() << Verbose(4) << "Translated given point is at " << RefPoint << "." << endl;
+
+  // 2. transform coordinate system by inverse of rotation matrix and of diagonal matrix
+  psi = EllipsoidAngle[0];
+  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);
+  helper.ScaleAll(InverseLength);
+  //Log() << Verbose(4) << "Transformed RefPoint is at " << helper << "." << endl;
+
+  // 3. construct intersection point with unit sphere and ray between origin and x
+  helper.Normalize(); // is simply normalizes vector in distance direction
+  //Log() << Verbose(4) << "Transformed intersection is at " << helper << "." << endl;
+
+  // 4. transform back the constructed intersection point
+  psi = -EllipsoidAngle[0];
+  theta = -EllipsoidAngle[1];
+  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);
+  //Log() << Verbose(4) << "Intersection is at " << helper << "." << endl;
+
+  // 5. determine distance between backtransformed point and x
+  distance = RefPoint.DistanceSquared(helper);
+  //Log() << Verbose(4) << "Squared distance between intersection and RefPoint is " << distance << "." << endl;
+
+  return distance;
+  //Log() << Verbose(3) << "End of SquaredDistanceToEllipsoid" << endl;
+};
+
+/** structure for ellipsoid minimisation containing points to fit to.
+ */
+struct EllipsoidMinimisation {
+  int N;      //!< dimension of vector set
+  Vector *x;  //!< array of vectors
+};
+
+/** Sum of squared distance to ellipsoid to be minimised.
+ * \param *x parameters for the ellipsoid
+ * \param *params EllipsoidMinimisation with set of data points to minimise distance to and dimension
+ * \return sum of squared distance, \sa SquaredDistanceToEllipsoid()
+ */
+double SumSquaredDistance (const gsl_vector * x, void * params)
+{
+  Vector *set= ((struct EllipsoidMinimisation *)params)->x;
+  int N = ((struct EllipsoidMinimisation *)params)->N;
+  double SumDistance = 0.;
+  double distance;
+  Vector Center;
+  double EllipsoidLength[3], EllipsoidAngle[3];
+
+  // put parameters into suitable ellipsoid form
+  for (int i=0;i<3;i++) {
+    Center[i] = gsl_vector_get(x, i+0);
+    EllipsoidLength[i] = gsl_vector_get(x, i+3);
+    EllipsoidAngle[i] = gsl_vector_get(x, i+6);
+  }
+
+  // go through all points and sum distance
+  for (int i=0;i<N;i++) {
+    distance = SquaredDistanceToEllipsoid(set[i], Center, EllipsoidLength, EllipsoidAngle);
+    if (!isnan(distance)) {
+      SumDistance += distance;
+    } else {
+      SumDistance = GSL_NAN;
+      break;
+    }
+  }
+
+  //Log() << Verbose(0) << "Current summed distance is " << SumDistance << "." << endl;
+  return SumDistance;
+};
+
+/** Finds best fitting ellipsoid parameter set in Least square sense for a given point set.
+ * \param *out output stream for debugging
+ * \param *set given point set
+ * \param N number of points in set
+ * \param EllipsoidParamter[3] three parameters in ellipsoid equation
+ * \return true - fit successful, false - fit impossible
+ */
+bool FitPointSetToEllipsoid(Vector *set, int N, Vector *EllipsoidCenter, double *EllipsoidLength, double *EllipsoidAngle)
+{
+  int status = GSL_SUCCESS;
+  DoLog(2) && (Log() << Verbose(2) << "Begin of FitPointSetToEllipsoid " << endl);
+  if (N >= 3) { // check that enough points are given (9 d.o.f.)
+    struct EllipsoidMinimisation par;
+    const gsl_multimin_fminimizer_type *T = gsl_multimin_fminimizer_nmsimplex;
+    gsl_multimin_fminimizer *s = NULL;
+    gsl_vector *ss, *x;
+    gsl_multimin_function minex_func;
+
+    size_t iter = 0;
+    double size;
+
+    /* Starting point */
+    x = gsl_vector_alloc (9);
+    for (int i=0;i<3;i++) {
+      gsl_vector_set (x, i+0, EllipsoidCenter->at(i));
+      gsl_vector_set (x, i+3, EllipsoidLength[i]);
+      gsl_vector_set (x, i+6, EllipsoidAngle[i]);
+    }
+    par.x = set;
+    par.N = N;
+
+    /* Set initial step sizes */
+    ss = gsl_vector_alloc (9);
+    for (int i=0;i<3;i++) {
+      gsl_vector_set (ss, i+0, 0.1);
+      gsl_vector_set (ss, i+3, 1.0);
+      gsl_vector_set (ss, i+6, M_PI/20.);
+    }
+
+    /* Initialize method and iterate */
+    minex_func.n = 9;
+    minex_func.f = &SumSquaredDistance;
+    minex_func.params = (void *)&par;
+
+    s = gsl_multimin_fminimizer_alloc (T, 9);
+    gsl_multimin_fminimizer_set (s, &minex_func, 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) {
+        for (int i=0;i<3;i++) {
+          EllipsoidCenter->at(i) = gsl_vector_get (s->x,i+0);
+          EllipsoidLength[i] = gsl_vector_get (s->x, i+3);
+          EllipsoidAngle[i] = gsl_vector_get (s->x, i+6);
+        }
+        DoLog(4) && (Log() << Verbose(4) << setprecision(3) << "Converged fit at: " << *EllipsoidCenter << ", lengths " << EllipsoidLength[0] << ", " << EllipsoidLength[1] << ", " << EllipsoidLength[2] << ", angles " << EllipsoidAngle[0] << ", " << EllipsoidAngle[1] << ", " << EllipsoidAngle[2] << " with summed distance " << s->fval << "." << endl);
+      }
+
+    } while (status == GSL_CONTINUE && iter < 1000);
+
+    gsl_vector_free(x);
+    gsl_vector_free(ss);
+    gsl_multimin_fminimizer_free (s);
+
+  } else {
+    DoLog(3) && (Log() << Verbose(3) << "Not enough points provided for fit to ellipsoid." << endl);
+    return false;
+  }
+  DoLog(2) && (Log() << Verbose(2) << "End of FitPointSetToEllipsoid" << endl);
+  if (status == GSL_SUCCESS)
+    return true;
+  else
+    return false;
+};
+
+/** Picks a number of random points from a LC neighbourhood as a fitting set.
+ * \param *out output stream for debugging
+ * \param *T Tesselation containing boundary points
+ * \param *LC linked cell list of all atoms
+ * \param *&x random point set on return (not allocated!)
+ * \param PointsToPick number of points in set to pick
+ */
+void PickRandomNeighbouredPointSet(class Tesselation *T, class LinkedCell *LC, Vector *&x, size_t PointsToPick)
+{
+  size_t PointsLeft = 0;
+  size_t PointsPicked = 0;
+  int Nlower[NDIM], Nupper[NDIM];
+  set<int> PickedAtomNrs;   // ordered list of picked atoms
+  set<int>::iterator current;
+  int index;
+  TesselPoint *Candidate = NULL;
+  DoLog(2) && (Log() << Verbose(2) << "Begin of PickRandomPointSet" << endl);
+
+  // allocate array
+  if (x == NULL) {
+    x = new Vector[PointsToPick];
+  } else {
+    DoeLog(2) && (eLog()<< Verbose(2) << "Given pointer to vector array seems already allocated." << endl);
+  }
+
+  do {
+    for(int i=0;i<NDIM;i++) // pick three random indices
+      LC->n[i] = (rand() % LC->N[i]);
+    DoLog(2) && (Log() << Verbose(2) << "INFO: Center cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " ... ");
+    // get random cell
+    const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
+    if (List == NULL) {  // set index to it
+      continue;
+    }
+    DoLog(2) && (Log() << Verbose(2) << "with No. " << LC->index << "." << endl);
+
+    DoLog(2) && (Log() << Verbose(2) << "LC Intervals:");
+    for (int i=0;i<NDIM;i++) {
+      Nlower[i] = ((LC->n[i]-1) >= 0) ? LC->n[i]-1 : 0;
+      Nupper[i] = ((LC->n[i]+1) < LC->N[i]) ? LC->n[i]+1 : LC->N[i]-1;
+      DoLog(0) && (Log() << Verbose(0) << " [" << Nlower[i] << "," << Nupper[i] << "] ");
+    }
+    DoLog(0) && (Log() << Verbose(0) << endl);
+
+    // count whether there are sufficient atoms in this cell+neighbors
+    PointsLeft=0;
+    for (LC->n[0] = Nlower[0]; LC->n[0] <= Nupper[0]; LC->n[0]++)
+      for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
+        for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
+          const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
+          PointsLeft += List->size();
+        }
+    DoLog(2) && (Log() << Verbose(2) << "There are " << PointsLeft << " atoms in this neighbourhood." << endl);
+    if (PointsLeft < PointsToPick) {  // ensure that we can pick enough points in its neighbourhood at all.
+      continue;
+    }
+
+    // pre-pick a fixed number of atoms
+    PickedAtomNrs.clear();
+    do {
+      index = (rand() % PointsLeft);
+      current = PickedAtomNrs.find(index);  // not present?
+      if (current == PickedAtomNrs.end()) {
+        //Log() << Verbose(2) << "Picking atom nr. " << index << "." << endl;
+        PickedAtomNrs.insert(index);
+      }
+    } while (PickedAtomNrs.size() < PointsToPick);
+
+    index = 0; // now go through all and pick those whose from PickedAtomsNr
+    PointsPicked=0;
+    current = PickedAtomNrs.begin();
+    for (LC->n[0] = Nlower[0]; LC->n[0] <= Nupper[0]; LC->n[0]++)
+      for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
+        for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
+          const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
+//          Log() << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;
+          if (List != NULL) {
+//            if (List->begin() != List->end())
+//              Log() << Verbose(2) << "Going through candidates ... " << endl;
+//            else
+//              Log() << Verbose(2) << "Cell is empty ... " << endl;
+            for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
+              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
+                current++;    // next pre-picked atom
+              }
+              index++;  // next atom nr.
+            }
+//          } else {
+//            Log() << Verbose(2) << "List for this index not allocated!" << endl;
+          }
+        }
+    DoLog(2) && (Log() << Verbose(2) << "The following points were picked: " << endl);
+    for (size_t i=0;i<PointsPicked;i++)
+      DoLog(2) && (Log() << Verbose(2) << x[i] << endl);
+    if (PointsPicked == PointsToPick)  // break out of loop if we have all
+      break;
+  } while(1);
+
+  DoLog(2) && (Log() << Verbose(2) << "End of PickRandomPointSet" << endl);
+};
+
+/** Picks a number of random points from a set of boundary points as a fitting set.
+ * \param *out output stream for debugging
+ * \param *T Tesselation containing boundary points
+ * \param *&x random point set on return (not allocated!)
+ * \param PointsToPick number of points in set to pick
+ */
+void PickRandomPointSet(class Tesselation *T, Vector *&x, size_t PointsToPick)
+{
+  size_t PointsLeft = (size_t) T->PointsOnBoundaryCount;
+  size_t PointsPicked = 0;
+  double value, threshold;
+  PointMap *List = &T->PointsOnBoundary;
+  DoLog(2) && (Log() << Verbose(2) << "Begin of PickRandomPointSet" << endl);
+
+  // allocate array
+  if (x == NULL) {
+    x = new Vector[PointsToPick];
+  } else {
+    DoeLog(2) && (eLog()<< Verbose(2) << "Given pointer to vector array seems already allocated." << endl);
+  }
+
+  if (List != NULL)
+    for (PointMap::iterator Runner = List->begin(); Runner != List->end(); Runner++) {
+      threshold = 1. - (double)(PointsToPick - PointsPicked)/(double)PointsLeft;
+      value = (double)rand()/(double)RAND_MAX;
+      //Log() << Verbose(3) << "Current node is " << *Runner->second->node << " with " << value << " ... " << threshold << ": ";
+      if (value > threshold) {
+        x[PointsPicked] = (*Runner->second->node->node);
+        PointsPicked++;
+        //Log() << Verbose(0) << "IN." << endl;
+      } else {
+        //Log() << Verbose(0) << "OUT." << endl;
+      }
+      PointsLeft--;
+    }
+  DoLog(2) && (Log() << Verbose(2) << "The following points were picked: " << endl);
+  for (size_t i=0;i<PointsPicked;i++)
+    DoLog(3) && (Log() << Verbose(3) << x[i] << endl);
+
+  DoLog(2) && (Log() << Verbose(2) << "End of PickRandomPointSet" << endl);
+};
+
+/** Finds best fitting ellipsoid parameter set in least square sense for a given point set.
+ * \param *out output stream for debugging
+ * \param *T Tesselation containing boundary points
+ * \param *LCList linked cell list of all atoms
+ * \param N number of unique points in ellipsoid fit, must be greater equal 6
+ * \param number of fits (i.e. parameter sets in output file)
+ * \param *filename name for output file
+ */
+void FindDistributionOfEllipsoids(class Tesselation *T, class LinkedCell *LCList, int N, int number, const char *filename)
+{
+  ofstream output;
+  Vector *x = NULL;
+  Vector Center;
+  Vector EllipsoidCenter;
+  double EllipsoidLength[3];
+  double EllipsoidAngle[3];
+  double distance, MaxDistance, MinDistance;
+  DoLog(0) && (Log() << Verbose(0) << "Begin of FindDistributionOfEllipsoids" << endl);
+
+  // construct center of gravity of boundary point set for initial ellipsoid center
+  Center.Zero();
+  for (PointMap::iterator Runner = T->PointsOnBoundary.begin(); Runner != T->PointsOnBoundary.end(); Runner++)
+    Center += (*Runner->second->node->node);
+  Center.Scale(1./T->PointsOnBoundaryCount);
+  DoLog(1) && (Log() << Verbose(1) << "Center is at " << Center << "." << endl);
+
+  // Output header
+  output.open(filename, ios::trunc);
+  output << "# Nr.\tCenterX\tCenterY\tCenterZ\ta\tb\tc\tpsi\ttheta\tphi" << endl;
+
+  // loop over desired number of parameter sets
+  for (;number >0;number--) {
+    DoLog(1) && (Log() << Verbose(1) << "Determining data set " << number << " ... " << endl);
+    // pick the point set
+    x = NULL;
+    //PickRandomPointSet(T, LCList, x, N);
+    PickRandomNeighbouredPointSet(T, LCList, x, N);
+
+    // calculate some sensible starting values for parameter fit
+    MaxDistance = 0.;
+    MinDistance = x[0].ScalarProduct(x[0]);
+    for (int i=0;i<N;i++) {
+      distance = x[i].ScalarProduct(x[i]);
+      if (distance > MaxDistance)
+        MaxDistance = distance;
+      if (distance < MinDistance)
+        MinDistance = distance;
+    }
+    //Log() << Verbose(2) << "MinDistance " << MinDistance << ", MaxDistance " << MaxDistance << "." << endl;
+    EllipsoidCenter = Center;  // use Center of Gravity as initial center of ellipsoid
+    for (int i=0;i<3;i++)
+      EllipsoidAngle[i] = 0.;
+    EllipsoidLength[0] = sqrt(MaxDistance);
+    EllipsoidLength[1] = sqrt((MaxDistance+MinDistance)/2.);
+    EllipsoidLength[2] = sqrt(MinDistance);
+
+    // fit the parameters
+    if (FitPointSetToEllipsoid(x, N, &EllipsoidCenter, &EllipsoidLength[0], &EllipsoidAngle[0])) {
+      DoLog(1) && (Log() << Verbose(1) << "Picking succeeded!" << endl);
+      // output obtained parameter set
+      output << number << "\t";
+      for (int i=0;i<3;i++)
+        output << setprecision(9) << EllipsoidCenter[i] << "\t";
+      for (int i=0;i<3;i++)
+        output << setprecision(9) << EllipsoidLength[i] << "\t";
+      for (int i=0;i<3;i++)
+        output << setprecision(9) << EllipsoidAngle[i] << "\t";
+      output << endl;
+    } else { // increase N to pick one more
+      DoLog(1) && (Log() << Verbose(1) << "Picking failed!" << endl);
+      number++;
+    }
+    delete[](x);  // free allocated memory for point set
+  }
+  // close output and finish
+  output.close();
+
+  DoLog(0) && (Log() << Verbose(0) << "End of FindDistributionOfEllipsoids" << endl);
+};
Index: src/ellipsoid.hpp
===================================================================
--- src/ellipsoid.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/ellipsoid.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,36 @@
+/*
+ * ellipsoid.hpp
+ *
+ *  Created on: Jan 20, 2009
+ *      Author: heber
+ */
+
+#ifndef ELLIPSOID_HPP_
+#define ELLIPSOID_HPP_
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gsl/gsl_vector.h>
+
+/****************************************** forward declarations *****************************/
+
+class LinkedCell;
+class Vector;
+
+/********************************************** declarations *******************************/
+
+double SquaredDistanceToEllipsoid(Vector &x, Vector &EllipsoidCenter, double *EllipsoidLength, double *EllipsoidAngle);
+double SumSquaredDistance (const gsl_vector * x, void * params);
+bool FitPointSetToEllipsoid(Vector *set, int N, Vector *EllipsoidCenter, double *EllipsoidLength, double *EllipsoidAngle);
+void PickRandomPointSet(class Tesselation *T, Vector *&x, size_t PointsToPick);
+void PickRandomNeighbouredPointSet(class Tesselation *T, class LinkedCell *LC, Vector *&x, size_t PointsToPick);
+void FindDistributionOfEllipsoids(class Tesselation *T, class LinkedCell *LCList, int N, int number, const char *filename);
+
+#endif /* ELLIPSOID_HPP_ */
Index: src/errorlogger.cpp
===================================================================
--- src/errorlogger.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/errorlogger.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,102 @@
+/*
+ * 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: src/errorlogger.hpp
===================================================================
--- src/errorlogger.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/errorlogger.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,39 @@
+/*
+ * 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 ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/graph.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,127 @@
+/** \file graph.cpp
+ *
+ * Function implementations for the class graph.
+ *
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+using namespace std;
+
+#include "atom.hpp"
+#include "bond.hpp"
+#include "config.hpp"
+#include "graph.hpp"
+#include "log.hpp"
+#include "molecule.hpp"
+
+/***************************************** Implementations for graph classes ********************************/
+
+///** Constructor of class Graph.
+// */
+//Graph::Graph()
+//{
+//};
+//
+///** Destructor of class Graph.
+// * Destructor does release memory for nodes and edges contained in its lists as well.
+// */
+//Graph::~Graph()
+//{
+//};
+//
+///** Constructor of class SubGraph.
+// */
+//SubGraph::SubGraph()
+//{
+//};
+//
+///** Destructor of class SubGraph.
+// * Note that destructor does not deallocate either nodes or edges! (this is done by its subgraph!)
+// */
+//SubGraph::~SubGraph()
+//{
+//};
+//
+///** Constructor of class Node.
+// */
+//Node::Node()
+//{
+//};
+//
+///** Destructor of class Node.
+// */
+//Node::~Node()
+//{
+//};
+//
+///** Constructor of class Edge.
+// */
+//Edge::Edge()
+//{
+//};
+//
+///** Destructor of class Edge.
+// */
+//Edge::~Edge()
+//{
+//};
+
+
+//bool operator < (KeySet SubgraphA, KeySet SubgraphB)
+//{
+//  return KeyCompare(SubgraphA, SubgraphB);
+//};
+
+/** Checking whether KeySet is not already present in Graph, if so just adds factor.
+ * \param *out output stream for debugging
+ * \param &set KeySet to insert
+ * \param &graph Graph to insert into
+ * \param *counter pointer to unique fragment count
+ * \param factor energy factor for the fragment
+ */
+void InsertFragmentIntoGraph(struct UniqueFragments *Fragment)
+{
+  GraphTestPair testGraphInsert;
+
+  testGraphInsert = Fragment->Leaflet->insert(GraphPair (*Fragment->FragmentSet,pair<int,double>(Fragment->FragmentCounter,Fragment->TEFactor)));  // store fragment number and current factor
+  if (testGraphInsert.second) {
+    DoLog(2) && (Log() << Verbose(2) << "KeySet " << Fragment->FragmentCounter << " successfully inserted." << endl);
+    Fragment->FragmentCounter++;
+  } else {
+    DoLog(2) && (Log() << Verbose(2) << "KeySet " << Fragment->FragmentCounter << " failed to insert, present fragment is " << ((*(testGraphInsert.first)).second).first << endl);
+    ((*(testGraphInsert.first)).second).second += Fragment->TEFactor;  // increase the "created" counter
+    DoLog(2) && (Log() << Verbose(2) << "New factor is " << ((*(testGraphInsert.first)).second).second << "." << endl);
+  }
+};
+//void inline InsertIntoGraph(KeyStack &stack, Graph &graph, int *counter, double factor)
+//{
+//  // copy stack contents to set and call overloaded function again
+//  KeySet set;
+//  for(KeyStack::iterator runner = stack.begin(); runner != stack.begin(); runner++)
+//    set.insert((*runner));
+//  InsertIntoGraph(set, graph, counter, factor);
+//};
+
+/** Inserts each KeySet in \a graph2 into \a graph1.
+ * \param *out output stream for debugging
+ * \param graph1 first (dest) graph
+ * \param graph2 second (source) graph
+ * \param *counter keyset counter that gets increased
+ */
+void InsertGraphIntoGraph(Graph &graph1, Graph &graph2, int *counter)
+{
+  GraphTestPair testGraphInsert;
+
+  for(Graph::iterator runner = graph2.begin(); runner != graph2.end(); runner++) {
+    testGraphInsert = graph1.insert(GraphPair ((*runner).first,pair<int,double>((*counter)++,((*runner).second).second)));  // store fragment number and current factor
+    if (testGraphInsert.second) {
+      DoLog(2) && (Log() << Verbose(2) << "KeySet " << (*counter)-1 << " successfully inserted." << endl);
+    } else {
+      DoLog(2) && (Log() << Verbose(2) << "KeySet " << (*counter)-1 << " failed to insert, present fragment is " << ((*(testGraphInsert.first)).second).first << endl);
+      ((*(testGraphInsert.first)).second).second += (*runner).second.second;
+      DoLog(2) && (Log() << Verbose(2) << "New factor is " << (*(testGraphInsert.first)).second.second << "." << endl);
+    }
+  }
+};
+
Index: src/graph.hpp
===================================================================
--- src/graph.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/graph.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,113 @@
+/** \file graph.cpp
+ * 
+ * Function definitions for the class graph.
+ * 
+ */
+
+#ifndef GRAPH_HPP_
+#define GRAPH_HPP_
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+// STL headers
+#include <deque>
+#include <map>
+#include <set>
+
+/****************************************** forward declarations *****************************/
+
+class atom;
+class bond;
+class config;
+class molecule;
+
+class Graph;
+class SubGraph;
+class Node;
+class Edge;
+
+/********************************************** definitions *********************************/
+
+#define NodeMap pair < int, class Node* >
+#define EdgeMap multimap < class Node*, class Edge* >
+
+#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>
+
+
+/******************************** Some small functions and/or structures **********************************/
+
+struct KeyCompare
+{
+  bool operator() (const KeySet SubgraphA, const KeySet SubgraphB) const;
+};
+
+//bool operator < (KeySet SubgraphA, KeySet SubgraphB);   //note: this declaration is important, otherwise normal < is used (producing wrong order)
+void InsertFragmentIntoGraph(struct UniqueFragments *Fragment); // Insert a KeySet into a Graph
+void InsertGraphIntoGraph(Graph &graph1, Graph &graph2, int *counter);  // Insert all KeySet's in a Graph into another Graph
+
+/** Structure containing all values in power set combination generation.
+ */
+struct UniqueFragments {
+  config *configuration;
+  atom *Root;
+  Graph *Leaflet;
+  KeySet *FragmentSet;
+  int ANOVAOrder;
+  int FragmentCounter;
+  int CurrentIndex;
+  double TEFactor;
+  int *ShortestPathList;
+  bool **UsedList;
+  bond **BondsPerSPList;
+  int *BondsPerSPCount;
+};
+
+/********************************************** declarations *******************************/
+
+///** Graph class containing the graphs behind molecules.
+// */
+//class Graph
+//{
+//	NodeMap ListOfNodes;		//!< tree-list of all nodes in this graph
+//	EdgeMap ListOfEdges;		//!< tree-multi-list of all nodes, referenced to node id
+//};
+//
+///** Class describing subgraphs of the Class \a Graph.
+// * SubGraph has its own node and edge lists, however also a pointer to its father graph
+// * and hence access to its list as well.
+// */
+//class SubGraph : class Graph
+//{
+//	class Graph *FatherGraph;		//!< Graph whose subgraph we are
+//};
+//
+///** Class containing the nodes of a graph.
+// */
+//class Node
+//{
+//	int	id;				//!< individual id of the node
+//	char *Name;		//!< Name of the node for pretty printing
+//};
+//
+///** Class containing egdes in a Graph strructure.
+// */
+//class Edge
+//{
+//	class Node *leftnode;		//!< pointer to first node
+//	class Node *atomnode;		//!< pointer to second node
+//};
+
+
+
+#endif /*GRAPH_HPP_*/
Index: src/gslmatrix.cpp
===================================================================
--- src/gslmatrix.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/gslmatrix.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,248 @@
+/*
+ * 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: src/gslmatrix.hpp
===================================================================
--- src/gslmatrix.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/gslmatrix.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -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/gslvector.cpp
===================================================================
--- src/gslvector.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/gslvector.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,305 @@
+/*
+ * 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: src/gslvector.hpp
===================================================================
--- src/gslvector.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/gslvector.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -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 <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: src/helpers.cpp
===================================================================
--- src/helpers.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/helpers.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,188 @@
+/** \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: src/helpers.hpp
===================================================================
--- src/helpers.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/helpers.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,199 @@
+/** \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: src/info.cpp
===================================================================
--- src/info.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/info.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,43 @@
+/*
+ * 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: src/info.hpp
===================================================================
--- src/info.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/info.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -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/joiner.cpp
===================================================================
--- src/joiner.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/joiner.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,252 @@
+/** \file joiner.cpp
+ *
+ * Takes evaluated fragments (energy and forces) and by reading the factors files determines total energy
+ * and each force for the whole molecule.
+ *
+ */
+
+//============================ INCLUDES ===========================
+
+#include "Helpers/MemDebug.hpp"
+
+#include <cstring>
+
+#include "datacreator.hpp"
+#include "helpers.hpp"
+#include "memoryallocator.hpp"
+#include "parser.hpp"
+#include "periodentafel.hpp"
+
+//============================== MAIN =============================
+
+int main(int argc, char **argv)
+{
+  periodentafel *periode = NULL; // and a period table of all elements
+  EnergyMatrix Energy;
+  EnergyMatrix EnergyFragments;
+  
+  EnergyMatrix Hcorrection;
+  EnergyMatrix HcorrectionFragments;
+  
+  ForceMatrix Force;
+  ForceMatrix ForceFragments;
+
+  HessianMatrix Hessian;
+  HessianMatrix HessianFragments;
+  
+  ForceMatrix Shielding;
+  ForceMatrix ShieldingPAS;
+  ForceMatrix ShieldingFragments;
+  ForceMatrix ShieldingPASFragments;
+  ForceMatrix Chi;
+  ForceMatrix ChiPAS;
+  ForceMatrix ChiFragments;
+  ForceMatrix ChiPASFragments;
+  KeySetsContainer KeySet;  
+  stringstream prefix;
+  char *dir = NULL;
+  bool NoHCorrection = false;
+  bool NoHessian = false;
+
+  DoLog(0) && (Log() << Verbose(0) << "Joiner" << endl);
+  DoLog(0) && (Log() << Verbose(0) << "======" << endl);
+
+  // Get the command line options
+  if (argc < 3) {
+    DoLog(0) && (Log() << Verbose(0) << "Usage: " << argv[0] << " <inputdir> <prefix> [elementsdb]" << endl);
+    DoLog(0) && (Log() << Verbose(0) << "<inputdir>\ttherein the output of a molecuilder fragmentation is expected, each fragment with a subdir containing an energy.all and a forces.all file." << endl);
+    DoLog(0) && (Log() << Verbose(0) << "<prefix>\tprefix of energy and forces file." << endl);
+    DoLog(0) && (Log() << Verbose(0) << "[elementsdb]\tpath to elements database, needed for shieldings." << endl);
+    return 1;
+  } else {
+    dir = new char[strlen(argv[2]) + 2];
+    strcpy(dir, "/");
+    strcat(dir, argv[2]);
+  }
+  if (argc > 3) {
+    periode = new periodentafel;
+    periode->LoadPeriodentafel(argv[3]);
+  }
+
+  // Test the given directory
+  if (!TestParams(argc, argv))
+    return 1;
+
+  // +++++++++++++++++ PARSING +++++++++++++++++++++++++++++++
+
+  // ------------- Parse through all Fragment subdirs --------
+  if (!Energy.ParseFragmentMatrix(argv[1], dir, EnergySuffix, 0,0)) return 1;
+  if (!Hcorrection.ParseFragmentMatrix(argv[1], "", HCORRECTIONSUFFIX, 0,0)) {
+    NoHCorrection = true;
+    DoLog(0) && (Log() << Verbose(0) << "No HCorrection matrices found, skipping these." << endl);
+  }
+  if (!Force.ParseFragmentMatrix(argv[1], dir, ForcesSuffix, 0,0)) return 1;
+  if (!Hessian.ParseFragmentMatrix(argv[1], dir, HessianSuffix, 0,0)) {
+    NoHessian = true;
+    DoLog(0) && (Log() << Verbose(0) << "No hessian matrices found, skipping these." << endl);
+  }
+  if (periode != NULL) { // also look for PAS values
+    if (!Shielding.ParseFragmentMatrix(argv[1], dir, ShieldingSuffix, 1, 0)) return 1;
+    if (!ShieldingPAS.ParseFragmentMatrix(argv[1], dir, ShieldingPASSuffix, 1, 0)) return 1;
+    if (!Chi.ParseFragmentMatrix(argv[1], dir, ChiSuffix, 1, 0)) return 1;
+    if (!ChiPAS.ParseFragmentMatrix(argv[1], dir, ChiPASSuffix, 1, 0)) return 1;
+  }
+
+  // ---------- Parse the TE Factors into an array -----------------
+  if (!Energy.InitialiseIndices()) return 1;
+  if (!NoHCorrection) 
+    Hcorrection.InitialiseIndices();
+  
+  // ---------- Parse the Force indices into an array ---------------
+  if (!Force.ParseIndices(argv[1])) return 1;
+
+  // ---------- Parse the Hessian (=force) indices into an array ---------------
+  if (!NoHessian)
+    if (!Hessian.InitialiseIndices((class MatrixContainer *)&Force)) return 1;
+
+  // ---------- Parse the shielding indices into an array ---------------
+  if (periode != NULL) { // also look for PAS values
+    if(!Shielding.ParseIndices(argv[1])) return 1;
+    if(!ShieldingPAS.ParseIndices(argv[1])) return 1;
+    if(!Chi.ParseIndices(argv[1])) return 1;
+    if(!ChiPAS.ParseIndices(argv[1])) return 1;
+  }
+
+  // ---------- Parse the KeySets into an array ---------------
+  if (!KeySet.ParseKeySets(argv[1], Force.RowCounter, Force.MatrixCounter)) return 1;
+
+  if (!KeySet.ParseManyBodyTerms()) return 1;
+
+  if (!EnergyFragments.AllocateMatrix(Energy.Header, Energy.MatrixCounter, Energy.RowCounter, Energy.ColumnCounter)) return 1;
+  if (!NoHCorrection)  
+    HcorrectionFragments.AllocateMatrix(Hcorrection.Header, Hcorrection.MatrixCounter, Hcorrection.RowCounter, Hcorrection.ColumnCounter);
+  if (!ForceFragments.AllocateMatrix(Force.Header, Force.MatrixCounter, Force.RowCounter, Force.ColumnCounter)) return 1;
+  if (!NoHessian)
+    if (!HessianFragments.AllocateMatrix(Hessian.Header, Hessian.MatrixCounter, Hessian.RowCounter, Hessian.ColumnCounter)) return 1;
+  if (periode != NULL) { // also look for PAS values
+    if (!ShieldingFragments.AllocateMatrix(Shielding.Header, Shielding.MatrixCounter, Shielding.RowCounter, Shielding.ColumnCounter)) return 1;
+    if (!ShieldingPASFragments.AllocateMatrix(ShieldingPAS.Header, ShieldingPAS.MatrixCounter, ShieldingPAS.RowCounter, ShieldingPAS.ColumnCounter)) return 1;
+    if (!ChiFragments.AllocateMatrix(Chi.Header, Chi.MatrixCounter, Chi.RowCounter, Chi.ColumnCounter)) return 1;
+    if (!ChiPASFragments.AllocateMatrix(ChiPAS.Header, ChiPAS.MatrixCounter, ChiPAS.RowCounter, ChiPAS.ColumnCounter)) return 1;
+  }
+
+  // ----------- Resetting last matrices (where full QM values are stored right now)
+  if(!Energy.SetLastMatrix(0., 0)) return 1;
+  if(!Force.SetLastMatrix(0., 2)) return 1;
+  if (!NoHessian)
+    if (!Hessian.SetLastMatrix(0., 0)) return 1;
+  if (periode != NULL) { // also look for PAS values
+    if(!Shielding.SetLastMatrix(0., 2)) return 1;
+    if(!ShieldingPAS.SetLastMatrix(0., 2)) return 1;
+    if(!Chi.SetLastMatrix(0., 2)) return 1;
+    if(!ChiPAS.SetLastMatrix(0., 2)) return 1;
+  }
+
+  // +++++++++++++++++ SUMMING +++++++++++++++++++++++++++++++
+
+  // --------- sum up and write for each order----------------
+  for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
+    // --------- sum up energy --------------------
+    DoLog(0) && (Log() << Verbose(0) << "Summing energy of order " << BondOrder+1 << " ..." << endl);
+    if (!EnergyFragments.SumSubManyBodyTerms(Energy, KeySet, BondOrder)) return 1;
+    if (!NoHCorrection) { 
+      HcorrectionFragments.SumSubManyBodyTerms(Hcorrection, KeySet, BondOrder);
+      if (!Energy.SumSubEnergy(EnergyFragments, &HcorrectionFragments, KeySet, BondOrder, 1.)) return 1;
+      Hcorrection.SumSubEnergy(HcorrectionFragments, NULL, KeySet, BondOrder, 1.);
+    } else 
+      if (!Energy.SumSubEnergy(EnergyFragments, NULL, KeySet, BondOrder, 1.)) return 1;
+    // --------- sum up Forces --------------------
+    DoLog(0) && (Log() << Verbose(0) << "Summing forces of order " << BondOrder+1 << " ..." << endl);
+    if (!ForceFragments.SumSubManyBodyTerms(Force, KeySet, BondOrder)) return 1;
+    if (!Force.SumSubForces(ForceFragments, KeySet, BondOrder, 1.)) return 1;
+    // --------- sum up Hessian --------------------
+    if (!NoHessian) {
+      DoLog(0) && (Log() << Verbose(0) << "Summing Hessian of order " << BondOrder+1 << " ..." << endl);
+      if (!HessianFragments.SumSubManyBodyTerms(Hessian, KeySet, BondOrder)) return 1;
+      if (!Hessian.SumSubHessians(HessianFragments, KeySet, BondOrder, 1.)) return 1;
+    }
+    if (periode != NULL) { // also look for PAS values
+      DoLog(0) && (Log() << Verbose(0) << "Summing shieldings and susceptibilities of order " << BondOrder+1 << " ..." << endl);
+      if (!ShieldingFragments.SumSubManyBodyTerms(Shielding, KeySet, BondOrder)) return 1;
+      if (!Shielding.SumSubForces(ShieldingFragments, KeySet, BondOrder, 1.)) return 1;
+      if (!ShieldingPASFragments.SumSubManyBodyTerms(ShieldingPAS, KeySet, BondOrder)) return 1;
+      if (!ShieldingPAS.SumSubForces(ShieldingPASFragments, KeySet, BondOrder, 1.)) return 1;
+      if (!ChiFragments.SumSubManyBodyTerms(Chi, KeySet, BondOrder)) return 1;
+      if (!Chi.SumSubForces(ChiFragments, KeySet, BondOrder, 1.)) return 1;
+      if (!ChiPASFragments.SumSubManyBodyTerms(ChiPAS, KeySet, BondOrder)) return 1;
+      if (!ChiPAS.SumSubForces(ChiPASFragments, KeySet, BondOrder, 1.)) return 1;
+    }
+
+    // --------- write the energy and forces file --------------------
+    prefix.str(" ");
+    prefix << dir << OrderSuffix << (BondOrder+1);
+    DoLog(0) && (Log() << Verbose(0) << "Writing files " << argv[1] << prefix.str() << ". ..." << endl);
+    // energy
+    if (!Energy.WriteLastMatrix(argv[1], (prefix.str()).c_str(), EnergySuffix)) return 1;
+    // forces
+    if (!Force.WriteLastMatrix(argv[1], (prefix.str()).c_str(), ForcesSuffix)) return 1;
+    // hessian
+    if (!NoHessian)
+      if (!Hessian.WriteLastMatrix(argv[1], (prefix.str()).c_str(), HessianSuffix)) return 1;
+    // shieldings
+    if (periode != NULL) { // also look for PAS values
+      if (!Shielding.WriteLastMatrix(argv[1], (prefix.str()).c_str(), ShieldingSuffix)) return 1;
+      if (!ShieldingPAS.WriteLastMatrix(argv[1], (prefix.str()).c_str(), ShieldingPASSuffix)) return 1;
+      if (!Chi.WriteLastMatrix(argv[1], (prefix.str()).c_str(), ChiSuffix)) return 1;
+      if (!ChiPAS.WriteLastMatrix(argv[1], (prefix.str()).c_str(), ChiPASSuffix)) return 1;
+    }
+  }
+  // fragments
+  prefix.str(" ");
+  prefix << dir << EnergyFragmentSuffix;
+  if (!EnergyFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1;
+  if (!NoHCorrection) {
+    prefix.str(" ");
+    prefix << dir << HcorrectionFragmentSuffix;
+    if (!HcorrectionFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1;
+  }
+  prefix.str(" ");
+  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;
+  if (!NoHessian) {
+    prefix.str(" ");
+    prefix << dir << HessianFragmentSuffix;
+    if (!HessianFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1;
+  }
+  if (periode != NULL) { // also look for PAS values
+    prefix.str(" ");
+    prefix << dir << ShieldingFragmentSuffix;
+    if (!ShieldingFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1;
+    prefix.str(" ");
+    prefix << dir << ShieldingPASFragmentSuffix;
+    if (!ShieldingPASFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1;
+    prefix.str(" ");
+    prefix << dir << ChiFragmentSuffix;
+    if (!ChiFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1;
+    prefix.str(" ");
+    prefix << dir << ChiPASFragmentSuffix;
+    if (!ChiPASFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1;
+  }
+
+  // write last matrices as fragments into central dir (not subdir as above), for analyzer to know index bounds
+  if (!Energy.WriteLastMatrix(argv[1], dir, EnergyFragmentSuffix)) return 1;
+  if (!NoHCorrection) Hcorrection.WriteLastMatrix(argv[1], dir, HcorrectionFragmentSuffix);
+  if (!Force.WriteLastMatrix(argv[1], dir, ForceFragmentSuffix)) return 1;
+  if (!NoHessian)
+    if (!Hessian.WriteLastMatrix(argv[1], dir, HessianFragmentSuffix)) return 1;
+  if (periode != NULL) { // also look for PAS values
+    if (!Shielding.WriteLastMatrix(argv[1], dir, ShieldingFragmentSuffix)) return 1;
+    if (!ShieldingPAS.WriteLastMatrix(argv[1], dir, ShieldingPASFragmentSuffix)) return 1;
+    if (!Chi.WriteLastMatrix(argv[1], dir, ChiFragmentSuffix)) return 1;
+    if (!ChiPAS.WriteLastMatrix(argv[1], dir, ChiPASFragmentSuffix)) return 1;
+  }
+
+  // exit
+  delete(periode);
+  delete[](dir);
+  DoLog(0) && (Log() << Verbose(0) << "done." << endl);
+  return 0;
+};
+
+//============================ END ===========================
Index: src/leastsquaremin.cpp
===================================================================
--- src/leastsquaremin.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/leastsquaremin.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,34 @@
+/*
+ * leastsquaremin.cpp
+ *
+ *  Created on: Aug 18, 2009
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include <iostream>
+
+#include "leastsquaremin.hpp"
+#include "vector.hpp"
+
+/** Determines sum of squared distances of \a X to all \a **vectors.
+ * \param *x reference vector
+ * \param *params
+ * \return sum of square distances
+ */
+double LSQ (const gsl_vector * const x, void * params)
+{
+  double sum = 0.;
+  struct LSQ_params *par = (struct LSQ_params *)params;
+  const Vector ** vectors = par->vectors;
+  int num = par->num;
+
+  for (int i=num;i--;) {
+    for(int j=NDIM;j--;)
+      sum += (gsl_vector_get(x,j) - (vectors[i])->at(j))*(gsl_vector_get(x,j) - (vectors[i])->at(j));
+  }
+
+  return sum;
+};
+
Index: src/leastsquaremin.hpp
===================================================================
--- src/leastsquaremin.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/leastsquaremin.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,49 @@
+/*
+ * leastsquaremin.hpp
+ *
+ *  Created on: Aug 18, 2009
+ *      Author: heber
+ */
+
+#ifndef LEASTSQUAREMIN_HPP_
+#define LEASTSQUAREMIN_HPP_
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gsl/gsl_vector.h>
+
+/****************************************** forward declarations *****************************/
+
+class element;
+class molecule;
+class Vector;
+
+/********************************************** declarations *******************************/
+
+/** Parameter structure for least square minimsation.
+ */
+struct LSQ_params {
+  const Vector **vectors;
+  int num;
+};
+
+double LSQ(const gsl_vector * const x, void * params);
+
+/** Parameter structure for least square minimsation.
+ */
+struct lsq_params {
+  gsl_vector *x;
+  const molecule *mol;
+  const element *type;
+};
+
+
+
+#endif /* LEASTSQUAREMIN_HPP_ */
Index: src/linearsystemofequations.cpp
===================================================================
--- src/linearsystemofequations.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/linearsystemofequations.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,131 @@
+/*
+ * 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: src/linearsystemofequations.hpp
===================================================================
--- src/linearsystemofequations.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/linearsystemofequations.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,56 @@
+/*
+ * 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 ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/linkedcell.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,413 @@
+/** \file linkedcell.cpp
+ *
+ * Function implementations for the class LinkedCell.
+ *
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "atom.hpp"
+#include "helpers.hpp"
+#include "linkedcell.hpp"
+#include "log.hpp"
+#include "molecule.hpp"
+#include "tesselation.hpp"
+#include "vector.hpp"
+
+// ========================================================= class LinkedCell ===========================================
+
+
+/** Constructor for class LinkedCell.
+ */
+LinkedCell::LinkedCell()
+{
+  LC = NULL;
+  for(int i=0;i<NDIM;i++)
+    N[i] = 0;
+  index = -1;
+  RADIUS = 0.;
+  max.Zero();
+  min.Zero();
+};
+
+/** Puts all atoms in \a *mol into a linked cell list with cell's lengths of \a RADIUS
+ * \param *set LCNodeSet class with all LCNode's
+ * \param RADIUS edge length of cells
+ */
+LinkedCell::LinkedCell(const PointCloud * const set, const double radius)
+{
+  TesselPoint *Walker = NULL;
+
+  RADIUS = radius;
+  LC = NULL;
+  for(int i=0;i<NDIM;i++)
+    N[i] = 0;
+  index = -1;
+  max.Zero();
+  min.Zero();
+  DoLog(1) && (Log() << Verbose(1) << "Begin of LinkedCell" << endl);
+  if ((set == NULL) || (set->IsEmpty())) {
+    DoeLog(1) && (eLog()<< Verbose(1) << "set is NULL or contains no linked cell nodes!" << endl);
+    return;
+  }
+  // 1. find max and min per axis of atoms
+  set->GoToFirst();
+  Walker = set->GetPoint();
+  for (int i=0;i<NDIM;i++) {
+    max[i] = Walker->node->at(i);
+    min[i] = Walker->node->at(i);
+  }
+  set->GoToFirst();
+  while (!set->IsEnd()) {
+    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);
+    }
+    set->GoToNext();
+  }
+  DoLog(2) && (Log() << Verbose(2) << "Bounding box is " << min << " and " << max << "." << endl);
+
+  // 2. find then number of cells per axis
+  for (int i=0;i<NDIM;i++) {
+    N[i] = static_cast<int>(floor((max[i] - min[i])/RADIUS)+1);
+  }
+  DoLog(2) && (Log() << Verbose(2) << "Number of cells per axis are " << N[0] << ", " << N[1] << " and " << N[2] << "." << endl);
+
+  // 3. allocate the lists
+  DoLog(2) && (Log() << Verbose(2) << "Allocating cells ... ");
+  if (LC != NULL) {
+    DoeLog(1) && (eLog()<< Verbose(1) << "Linked Cell list is already allocated, I do nothing." << endl);
+    return;
+  }
+  LC = new LinkedNodes[N[0]*N[1]*N[2]];
+  for (index=0;index<N[0]*N[1]*N[2];index++) {
+    LC [index].clear();
+  }
+  DoLog(0) && (Log() << Verbose(0) << "done."  << endl);
+
+  // 4. put each atom into its respective cell
+  DoLog(2) && (Log() << Verbose(2) << "Filling cells ... ");
+  set->GoToFirst();
+  while (!set->IsEnd()) {
+    Walker = set->GetPoint();
+    for (int i=0;i<NDIM;i++) {
+      n[i] = static_cast<int>(floor((Walker->node->at(i) - min[i])/RADIUS));
+    }
+    index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2];
+    LC[index].push_back(Walker);
+    //Log() << Verbose(2) << *Walker << " goes into cell " << n[0] << ", " << n[1] << ", " << n[2] << " with No. " << index << "." << endl;
+    set->GoToNext();
+  }
+  DoLog(0) && (Log() << Verbose(0) << "done."  << endl);
+  DoLog(1) && (Log() << Verbose(1) << "End of LinkedCell" << endl);
+};
+
+
+/** Puts all atoms in \a *mol into a linked cell list with cell's lengths of \a RADIUS
+ * \param *set LCNodeSet class with all LCNode's
+ * \param RADIUS edge length of cells
+ */
+LinkedCell::LinkedCell(LinkedNodes *set, const double radius)
+{
+  class TesselPoint *Walker = NULL;
+  RADIUS = radius;
+  LC = NULL;
+  for(int i=0;i<NDIM;i++)
+    N[i] = 0;
+  index = -1;
+  max.Zero();
+  min.Zero();
+  DoLog(1) && (Log() << Verbose(1) << "Begin of LinkedCell" << endl);
+  if (set->empty()) {
+    DoeLog(1) && (eLog()<< Verbose(1) << "set contains no linked cell nodes!" << endl);
+    return;
+  }
+  // 1. find max and min per axis of atoms
+  LinkedNodes::iterator Runner = set->begin();
+  for (int i=0;i<NDIM;i++) {
+    max[i] = (*Runner)->node->at(i);
+    min[i] = (*Runner)->node->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);
+    }
+  }
+  DoLog(2) && (Log() << Verbose(2) << "Bounding box is " << min << " and " << max << "." << endl);
+
+  // 2. find then number of cells per axis
+  for (int i=0;i<NDIM;i++) {
+    N[i] = static_cast<int>(floor((max[i] - min[i])/RADIUS)+1);
+  }
+  DoLog(2) && (Log() << Verbose(2) << "Number of cells per axis are " << N[0] << ", " << N[1] << " and " << N[2] << "." << endl);
+
+  // 3. allocate the lists
+  DoLog(2) && (Log() << Verbose(2) << "Allocating cells ... ");
+  if (LC != NULL) {
+    DoeLog(1) && (eLog()<< Verbose(1) << "Linked Cell list is already allocated, I do nothing." << endl);
+    return;
+  }
+  LC = new LinkedNodes[N[0]*N[1]*N[2]];
+  for (index=0;index<N[0]*N[1]*N[2];index++) {
+    LC [index].clear();
+  }
+  DoLog(0) && (Log() << Verbose(0) << "done."  << endl);
+
+  // 4. put each atom into its respective cell
+  DoLog(2) && (Log() << Verbose(2) << "Filling cells ... ");
+  for (LinkedNodes::iterator Runner = set->begin(); Runner != set->end(); Runner++) {
+    Walker = *Runner;
+    for (int i=0;i<NDIM;i++) {
+      n[i] = static_cast<int>(floor((Walker->node->at(i) - min[i])/RADIUS));
+    }
+    index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2];
+    LC[index].push_back(Walker);
+    //Log() << Verbose(2) << *Walker << " goes into cell " << n[0] << ", " << n[1] << ", " << n[2] << " with No. " << index << "." << endl;
+  }
+  DoLog(0) && (Log() << Verbose(0) << "done."  << endl);
+  DoLog(1) && (Log() << Verbose(1) << "End of LinkedCell" << endl);
+};
+
+/** Destructor for class LinkedCell.
+ */
+LinkedCell::~LinkedCell()
+{
+  if (LC != NULL)
+  for (index=0;index<N[0]*N[1]*N[2];index++)
+    LC[index].clear();
+  delete[](LC);
+  for(int i=0;i<NDIM;i++)
+    N[i] = 0;
+  index = -1;
+};
+
+/** Checks whether LinkedCell::n[] is each within [0,N[]].
+ * \return if all in intervals - true, else -false
+ */
+bool LinkedCell::CheckBounds() const
+{
+  bool status = true;
+  for(int i=0;i<NDIM;i++)
+    status = status && ((n[i] >=0) && (n[i] < N[i]));
+//  if (!status)
+//    DoeLog(1) && (eLog()<< Verbose(1) << "indices are out of bounds!" << endl);
+  return status;
+};
+
+/** Checks whether LinkedCell::n[] plus relative offset is each within [0,N[]].
+ * Note that for this check we don't admonish if out of bounds.
+ * \param relative[NDIM] relative offset to current cell
+ * \return if all in intervals - true, else -false
+ */
+bool LinkedCell::CheckBounds(const int relative[NDIM]) const
+{
+  bool status = true;
+  for(int i=0;i<NDIM;i++)
+    status = status && ((n[i]+relative[i] >=0) && (n[i]+relative[i] < N[i]));
+  return status;
+};
+
+
+/** Returns a pointer to the current cell.
+ * \return LinkedAtoms pointer to current cell, NULL if LinkedCell::n[] are out of bounds.
+ */
+const LinkedCell::LinkedNodes* LinkedCell::GetCurrentCell() const
+{
+  if (CheckBounds()) {
+    index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2];
+    return (&(LC[index]));
+  } else {
+    return NULL;
+  }
+};
+
+/** Returns a pointer to the current cell.
+ * \param relative[NDIM] offset for each axis with respect to the current cell LinkedCell::n[NDIM]
+ * \return LinkedAtoms pointer to current cell, NULL if LinkedCell::n[]+relative[] are out of bounds.
+ */
+const LinkedCell::LinkedNodes* LinkedCell::GetRelativeToCurrentCell(const int relative[NDIM]) const
+{
+  if (CheckBounds(relative)) {
+    index = (n[0]+relative[0]) * N[1] * N[2] + (n[1]+relative[1]) * N[2] + (n[2]+relative[2]);
+    return (&(LC[index]));
+  } else {
+    return NULL;
+  }
+};
+
+/** Set the index to the cell containing a given Vector *x.
+ * \param *x Vector with coordinates
+ * \return Vector is inside bounding box - true, else - false
+ */
+bool LinkedCell::SetIndexToVector(const Vector * const x) const
+{
+  for (int i=0;i<NDIM;i++)
+    n[i] = (int)floor((x->at(i) - min[i])/RADIUS);
+
+  return CheckBounds();
+};
+
+/** Calculates the index for a given LCNode *Walker.
+ * \param *Walker LCNode to set index tos
+ * \return if the atom is also found in this cell - true, else - false
+ */
+bool LinkedCell::SetIndexToNode(const TesselPoint * const Walker) const
+{
+  bool status = false;
+  for (int i=0;i<NDIM;i++) {
+    n[i] = static_cast<int>(floor((Walker->node->at(i) - min[i])/RADIUS));
+  }
+  index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2];
+  if (CheckBounds()) {
+    for (LinkedNodes::iterator Runner = LC[index].begin(); Runner != LC[index].end(); Runner++)
+      status = status || ((*Runner) == Walker);
+    return status;
+  } else {
+    DoeLog(1) && (eLog()<< Verbose(1) << "Node at " << *Walker << " is out of bounds." << endl);
+    return false;
+  }
+};
+
+/** Calculates the interval bounds of the linked cell grid.
+ * \param lower lower bounds
+ * \param upper upper bounds
+ * \param step how deep to check the neighbouring cells (i.e. number of layers to check)
+ */
+void LinkedCell::GetNeighbourBounds(int lower[NDIM], int upper[NDIM], int step) const
+{
+  for (int i=0;i<NDIM;i++) {
+    lower[i] = n[i]-step;
+    if (lower[i] < 0)
+      lower[i] = 0;
+    if (lower[i] >= N[i])
+      lower[i] = N[i]-1;
+    upper[i] = n[i]+step;
+    if (upper[i] >= N[i])
+      upper[i] = N[i]-1;
+    if (upper[i] < 0)
+      upper[i] = 0;
+    //Log() << Verbose(0) << "axis " << i << " has bounds [" << lower[i] << "," << upper[i] << "]" << endl;
+  }
+};
+
+/** Returns a list with all neighbours from the current LinkedCell::index.
+ * \param distance (if no distance, then adjacent cells are taken)
+ * \return list of tesselpoints
+ */
+LinkedCell::LinkedNodes* LinkedCell::GetallNeighbours(const double distance) const
+{
+  int Nlower[NDIM], Nupper[NDIM];
+  TesselPoint *Walker = NULL;
+  LinkedNodes *TesselList = new LinkedNodes;
+
+  // then go through the current and all neighbouring cells and check the contained points for possible candidates
+  const int step = (distance == 0) ? 1 : (int)floor(distance/RADIUS + 1.);
+  GetNeighbourBounds(Nlower, Nupper, step);
+
+  //Log() << Verbose(0) << endl;
+  for (n[0] = Nlower[0]; n[0] <= Nupper[0]; n[0]++)
+    for (n[1] = Nlower[1]; n[1] <= Nupper[1]; n[1]++)
+      for (n[2] = Nlower[2]; n[2] <= Nupper[2]; n[2]++) {
+        const LinkedNodes *List = GetCurrentCell();
+        //Log() << Verbose(1) << "Current cell is " << n[0] << ", " << n[1] << ", " << n[2] << " with No. " << index << "." << endl;
+        if (List != NULL) {
+          for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
+            Walker = *Runner;
+            TesselList->push_back(Walker);
+          }
+        }
+      }
+  return TesselList;
+};
+
+/** Set the index to the cell containing a given Vector *x, which is not inside the LinkedCell's domain
+ * Note that as we have to check distance from every corner of the closest cell, this function is faw more
+ * expensive and if Vector is known to be inside LinkedCell's domain, then SetIndexToVector() should be used.
+ * \param *x Vector with coordinates
+ * \return minimum squared distance of cell to given vector (if inside of domain, distance is 0)
+ */
+double LinkedCell::SetClosestIndexToOutsideVector(const Vector * const x) const
+{
+  for (int i=0;i<NDIM;i++) {
+    n[i] = (int)floor((x->at(i) - min[i])/RADIUS);
+    if (n[i] < 0)
+      n[i] = 0;
+    if (n[i] >= N[i])
+      n[i] = N[i]-1;
+  }
+
+  // calculate distance of cell to vector
+  double distanceSquared = 0.;
+  bool outside = true;  // flag whether x is found in- or outside of LinkedCell's domain/closest cell
+  Vector corner; // current corner of closest cell
+  Vector tester; // Vector pointing from corner to center of closest cell
+  Vector Distance;  // Vector from corner of closest cell to x
+
+  Vector center;  // center of the closest cell
+  for (int i=0;i<NDIM;i++)
+    center[i] = min[i]+((double)n[i]+.5)*RADIUS;
+
+  int c[NDIM];
+  for (c[0]=0;c[0]<=1;c[0]++)
+    for (c[1]=0; c[1]<=1;c[1]++)
+      for (c[2]=0; c[2]<=1;c[2]++) {
+        // set up corner
+        for (int i=0;i<NDIM;i++)
+          corner[i] = min[i]+RADIUS*((double)n[i]+c[i]);
+        // set up distance vector
+        Distance = (*x) - corner;
+        const double dist = Distance.NormSquared();
+        // check whether distance is smaller
+        if (dist< distanceSquared)
+          distanceSquared = dist;
+        // check whether distance vector goes inside or outside
+        tester = center -corner;
+        if (tester.ScalarProduct(Distance) < 0)
+          outside = false;
+      }
+  return (outside ? distanceSquared : 0.);
+};
+
+/** Returns a list of all TesselPoint with distance less than \a radius to \a *Center.
+ * \param radius radius of sphere
+ * \param *center center of sphere
+ * \return list of all points inside sphere
+ */
+LinkedCell::LinkedNodes* LinkedCell::GetPointsInsideSphere(const double radius, const Vector * const center) const
+{
+  const double radiusSquared = radius*radius;
+  TesselPoint *Walker = NULL;
+  LinkedNodes *TesselList = new LinkedNodes;
+  LinkedNodes *NeighbourList = NULL;
+
+  // set index of LC to center of sphere
+  const double dist = SetClosestIndexToOutsideVector(center);
+  if (dist > 2.*radius) {
+    DoeLog(1) && (eLog()<< Verbose(1) << "Vector " << *center << " is too far away from any atom in LinkedCell's bounding box." << endl);
+    return TesselList;
+  } else
+    DoLog(1) && (Log() << Verbose(1) << "Distance of closest cell to center of sphere with radius " << radius << " is " << dist << "." << endl);
+
+  // gather all neighbours first, then look who fulfills distance criteria
+  NeighbourList = GetallNeighbours(2.*radius-dist);
+  //Log() << Verbose(1) << "I found " << NeighbourList->size() << " neighbours to check." << endl;
+  if (NeighbourList != NULL) {
+    for (LinkedNodes::const_iterator Runner = NeighbourList->begin(); Runner != NeighbourList->end(); Runner++) {
+      Walker = *Runner;
+      //Log() << Verbose(1) << "Current neighbour is at " << *Walker->node << "." << endl;
+      if ((center->DistanceSquared(*Walker->node) - radiusSquared) < MYEPSILON) {
+        TesselList->push_back(Walker);
+      }
+    }
+    delete(NeighbourList);
+  } else
+    DoeLog(2) && (eLog()<< Verbose(2) << "Around vector " << *center << " there are no atoms." << endl);
+  return TesselList;
+};
Index: src/linkedcell.hpp
===================================================================
--- src/linkedcell.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/linkedcell.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,76 @@
+/*
+ * linkedcell.hpp
+ *
+ *  If the linked cell should be usable, the class has to inherit LCNodeSet and the nodes (containing the Vectors) have to inherit LCNode. This works well
+ *  for molecule and atom classes.
+ *
+ *  Created on: Aug 3, 2009
+ *      Author: heber
+ */
+
+#ifndef LINKEDCELL_HPP_
+#define LINKEDCELL_HPP_
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <list>
+
+#include "defs.hpp"
+#include "vector.hpp"
+
+/****************************************** forward declarations *****************************/
+
+class PointCloud;
+class TesselPoint;
+
+/********************************************** definitions *********************************/
+
+
+/********************************************** declarations *******************************/
+
+/** Linked Cell class for containing Vectors in real space efficiently.
+ */
+class LinkedCell {
+private:
+
+public:
+  typedef list<TesselPoint *> LinkedNodes;
+
+
+    Vector max;       // upper boundary
+    Vector min;       // lower boundary
+    LinkedNodes *LC;  // linked cell list
+    double RADIUS;    // cell edge length
+    int N[NDIM];      // number of cells per axis
+    mutable int n[NDIM];      // temporary variable for current cell per axis
+    mutable int index;        // temporary index variable , access by index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2];
+
+    LinkedCell();
+    LinkedCell(const  PointCloud * const set, const double RADIUS);
+    LinkedCell(LinkedNodes *set, const double radius);
+    ~LinkedCell();
+    const LinkedCell::LinkedNodes* GetCurrentCell()const ;
+    const LinkedCell::LinkedNodes* GetRelativeToCurrentCell(const int relative[NDIM])const ;
+    bool SetIndexToNode(const TesselPoint * const Walker)const ;
+    bool SetIndexToVector(const Vector * const x)const ;
+    double SetClosestIndexToOutsideVector(const Vector * const x) const;
+    bool CheckBounds()const ;
+    bool CheckBounds(const int relative[NDIM])const ;
+    void GetNeighbourBounds(int lower[NDIM], int upper[NDIM], int step = 1)const ;
+
+    LinkedCell::LinkedNodes* GetallNeighbours(const double distance = 0) const;
+    LinkedCell::LinkedNodes* GetPointsInsideSphere(const double radius, const Vector * const center) const;
+    // not implemented yet
+    bool AddNode(Vector *Walker);
+    bool DeleteNode(Vector *Walker);
+    bool MoveNode(Vector *Walker);
+};
+
+#endif /*LINKEDCELL_HPP_*/
Index: src/lists.hpp
===================================================================
--- src/lists.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/lists.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,136 @@
+/*
+ * lists.hpp
+ *
+ *  Created on: Oct 9, 2009
+ *      Author: heber
+ */
+
+#ifndef LISTS_HPP_
+#define LISTS_HPP_
+
+class atom;
+
+/******************************** Some templates for list management ***********************************/
+
+/** Adds linking of an item to a list.
+ * \param *walker
+ * \return true - adding succeeded, false - error in list
+ */
+template <typename X> void link(X *walker, X *end)
+{
+  X *vorher = end->previous;
+  if (vorher != 0)
+    vorher->next = walker;
+  end->previous = walker;
+  walker->previous = vorher;
+  walker->next = end;
+};
+
+/** Removes linking of an item in a list.
+ * \param *walker
+ * \return true - removing succeeded, false - given item not found in list
+ */
+template <typename X> void unlink(X *walker)
+{
+  if (walker->next != 0)
+    walker->next->previous = walker->previous;
+  if (walker->previous != 0)
+    walker->previous->next = walker->next;
+  walker->next = 0;
+  walker->previous= 0;
+};
+
+/** Adds new item before an item \a *end in a list.
+ * \param *pointer   item to be added
+ * \param *end  end of list
+ * \return true - addition succeeded, false - unable to add item to list
+ */
+template <typename X>  bool add(X *pointer, X *end)
+{
+  if (end != 0) {
+    link(pointer, end);
+  } else {
+    pointer->previous = 0;
+    pointer->next = 0;
+  }
+  return true;
+};
+
+/** Finds item in list
+ * \param *suche  search criteria
+ * \param *start  begin of list
+ * \param *end  end of list
+ * \return X - if found, 0 - if not found
+ */
+template <typename X, typename Y> X * find(Y *suche, X *start, X *end)
+{
+  X *walker = start;
+  while (walker->next != end) { // go through list
+    walker = walker->next; // step onward beforehand
+    if (*walker->sort == *suche) return (walker);
+  }
+  return 0;
+};
+
+/** Removes an item from the list without check.
+ * \param *walker item to be removed
+ * \return true - removing succeeded, false - given item not found in list
+ */
+template <typename X> void removewithoutcheck(X *walker)
+{
+  if (walker != 0) {
+    unlink(walker);
+    delete(walker);
+    walker = 0;
+  }
+};
+
+/** Removes an item from the list without check.
+ *  specialized for atoms, because these have to be removed from the world as well
+ *  the implementation for this declaration is in lists.cpp
+ * \param *walker item to be removed
+ * \return true - removing succeeded, false - given item not found in list
+ */
+template <> void removewithoutcheck<atom>(atom *walker);
+
+/** Removes an item from the list, checks if exists.
+ * Checks beforehand if atom is really within molecule list.
+ * \param *pointer   item to be removed
+ * \param *start  begin of list
+ * \param *end  end of list
+ * \return true - removing succeeded, false - given item not found in list
+ */
+template <typename X> bool remove(X *pointer, X *start, X *end)
+{
+  X *walker = find (pointer->sort, start, end);
+/*  while (walker->next != pointer) { // search through list
+    walker = walker->next;
+    if (walker == end) return false;  // item not found in list
+  }*/
+  // atom found, now unlink
+  if (walker != 0)
+    removewithoutcheck(walker);
+  else
+    return false;
+  return true;
+};
+
+/** Cleans the whole list.
+ * \param *start begin of list
+ * \param *end end of list
+ * \return true - list was cleaned successfully, false - error in list structure
+ */
+template <typename X> bool cleanup(X *start, X *end)
+{
+  X *pointer = start->next;
+  X *walker = 0;
+  while (pointer != end) { // go through list
+    walker = pointer; // mark current
+    pointer = pointer->next; // step onward beforehand
+    // remove walker
+    removewithoutcheck(walker);
+  }
+  return true;
+};
+
+#endif /* LISTS_HPP_ */
Index: src/log.cpp
===================================================================
--- src/log.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/log.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,60 @@
+/*
+ * 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: src/log.hpp
===================================================================
--- src/log.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/log.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,20 @@
+/*
+ * 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: src/logger.cpp
===================================================================
--- src/logger.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/logger.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,77 @@
+/*
+ * 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: src/logger.hpp
===================================================================
--- src/logger.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/logger.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,38 @@
+/*
+ * 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: src/memoryallocator.cpp
===================================================================
--- src/memoryallocator.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/memoryallocator.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,38 @@
+/*
+ * 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: src/memoryallocator.hpp
===================================================================
--- src/memoryallocator.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/memoryallocator.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,139 @@
+/** \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: src/memoryusageobserver.cpp
===================================================================
--- src/memoryusageobserver.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/memoryusageobserver.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,126 @@
+/*
+ * \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: src/memoryusageobserver.hpp
===================================================================
--- src/memoryusageobserver.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/memoryusageobserver.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,50 @@
+/*
+ * \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 ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/molecule.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,1201 @@
+/** \file molecules.cpp
+ *
+ * Functions for the class molecule.
+ *
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include <cstring>
+#include <boost/bind.hpp>
+
+#include "World.hpp"
+#include "atom.hpp"
+#include "bond.hpp"
+#include "config.hpp"
+#include "element.hpp"
+#include "graph.hpp"
+#include "helpers.hpp"
+#include "leastsquaremin.hpp"
+#include "linkedcell.hpp"
+#include "lists.hpp"
+#include "log.hpp"
+#include "molecule.hpp"
+#include "memoryallocator.hpp"
+#include "periodentafel.hpp"
+#include "stackclass.hpp"
+#include "tesselation.hpp"
+#include "vector.hpp"
+#include "World.hpp"
+#include "Plane.hpp"
+#include "Exceptions/LinearDependenceException.hpp"
+
+
+/************************************* Functions for class molecule *********************************/
+
+/** Constructor of class molecule.
+ * Initialises molecule list with correctly referenced start and end, and sets molecule::last_atom to zero.
+ */
+molecule::molecule(const periodentafel * const teil) :
+  Observable("molecule"),
+  elemente(teil),  MDSteps(0),  BondCount(0), ElementCount(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());
+};
+
+molecule *NewMolecule(){
+  return new molecule(World::getInstance().getPeriode());
+}
+
+/** Destructor of class molecule.
+ * Initialises molecule list with correctly referenced start and end, and sets molecule::last_atom to zero.
+ */
+molecule::~molecule()
+{
+  CleanupMolecule();
+};
+
+
+void DeleteMolecule(molecule *mol){
+  delete mol;
+}
+
+// getter and setter
+const std::string molecule::getName(){
+  return std::string(name);
+}
+
+int molecule::getAtomCount() const{
+  return *AtomCount;
+}
+
+void molecule::setName(const std::string _name){
+  OBSERVE;
+  cout << "Set name of molecule " << getId() << " to " << _name << endl;
+  strncpy(name,_name.c_str(),MAXSTRINGSIZE);
+}
+
+moleculeId_t molecule::getId(){
+  return id;
+}
+
+void molecule::setId(moleculeId_t _id){
+  id =_id;
+}
+
+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();
+}
+
+/************************** Access to the List of Atoms ****************/
+
+
+molecule::iterator molecule::begin(){
+  return molecule::iterator(atoms.begin(),this);
+}
+
+molecule::const_iterator molecule::begin() const{
+  return atoms.begin();
+}
+
+molecule::iterator molecule::end(){
+  return molecule::iterator(atoms.end(),this);
+}
+
+molecule::const_iterator molecule::end() const{
+  return atoms.end();
+}
+
+bool molecule::empty() const
+{
+  return (begin() == end());
+}
+
+size_t molecule::size() const
+{
+  size_t counter = 0;
+  for (molecule::const_iterator iter = begin(); iter != end (); ++iter)
+    counter++;
+  return counter;
+}
+
+molecule::const_iterator molecule::erase( const_iterator loc )
+{
+  molecule::const_iterator iter = loc;
+  iter--;
+  atom* atom = *loc;
+  atomIds.erase( atom->getId() );
+  atoms.remove( atom );
+  atom->removeFromMolecule();
+  return iter;
+}
+
+molecule::const_iterator molecule::erase( atom * key )
+{
+  molecule::const_iterator iter = find(key);
+  if (iter != end()){
+    atomIds.erase( key->getId() );
+    atoms.remove( key );
+    key->removeFromMolecule();
+  }
+  return iter;
+}
+
+molecule::const_iterator molecule::find ( atom * key ) const
+{
+  molecule::const_iterator iter;
+  for (molecule::const_iterator Runner = begin(); Runner != end(); ++Runner) {
+    if (*Runner == key)
+      return molecule::const_iterator(Runner);
+  }
+  return molecule::const_iterator(atoms.end());
+}
+
+pair<molecule::iterator,bool> molecule::insert ( atom * const key )
+{
+  pair<atomIdSet::iterator,bool> res = atomIds.insert(key->getId());
+  if (res.second) { // push atom if went well
+    atoms.push_back(key);
+    return pair<iterator,bool>(molecule::iterator(--end()),res.second);
+  } else {
+    return pair<iterator,bool>(molecule::iterator(end()),res.second);
+  }
+}
+
+bool molecule::containsAtom(atom* key){
+  return (find(key) != end());
+}
+
+/** Adds given atom \a *pointer from molecule list.
+ * Increases molecule::last_atom and gives last number to added atom and names it according to its element::abbrev and molecule::AtomCount
+ * \param *pointer allocated and set atom
+ * \return true - succeeded, false - atom not found in list
+ */
+bool molecule::AddAtom(atom *pointer)
+{
+  OBSERVE;
+  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)
+        NoNonHydrogen++;
+      if(pointer->getName() == "Unknown"){
+        stringstream sstr;
+        sstr << pointer->type->symbol << pointer->nr+1;
+        pointer->setName(sstr.str());
+      }
+    }
+    insert(pointer);
+    pointer->setMolecule(this);
+  }
+  return true;
+};
+
+/** Adds a copy of the given atom \a *pointer from molecule list.
+ * Increases molecule::last_atom and gives last number to added atom.
+ * \param *pointer allocated and set atom
+ * \return pointer to the newly added atom
+ */
+atom * molecule::AddCopyAtom(atom *pointer)
+{
+  atom *retval = NULL;
+  OBSERVE;
+  if (pointer != NULL) {
+    atom *walker = pointer->clone();
+    walker->setName(pointer->getName());
+    walker->nr = last_atom++;  // increase number within molecule
+    insert(walker);
+    if ((pointer->type != NULL) && (pointer->type->Z != 1))
+      NoNonHydrogen++;
+    retval=walker;
+  }
+  return retval;
+};
+
+/** Adds a Hydrogen atom in replacement for the given atom \a *partner in bond with a *origin.
+ * Here, we have to distinguish between single, double or triple bonds as stated by \a BondDegree, that each demand
+ * a different scheme when adding \a *replacement atom for the given one.
+ * -# Single Bond: Simply add new atom with bond distance rescaled to typical hydrogen one
+ * -# Double Bond: Here, we need the **BondList of the \a *origin atom, by scanning for the other bonds instead of
+ *    *Bond, we use the through these connected atoms to determine the plane they lie in, vector::MakeNormalvector().
+ *    The orthonormal vector to this plane along with the vector in *Bond direction determines the plane the two
+ *    replacing hydrogens shall lie in. Now, all remains to do is take the usual hydrogen double bond angle for the
+ *    element of *origin and form the sin/cos admixture of both plane vectors for the new coordinates of the two
+ *    hydrogens forming this angle with *origin.
+ * -# Triple Bond: The idea is to set up a tetraoid (C1-H1-H2-H3) (however the lengths \f$b\f$ of the sides of the base
+ *    triangle formed by the to be added hydrogens are not equal to the typical bond distance \f$l\f$ but have to be
+ *    determined from the typical angle \f$\alpha\f$ for a hydrogen triple connected to the element of *origin):
+ *    We have the height \f$d\f$ as the vector in *Bond direction (from triangle C1-H1-H2).
+ *    \f[ h = l \cdot \cos{\left (\frac{\alpha}{2} \right )} \qquad b = 2l \cdot \sin{\left (\frac{\alpha}{2} \right)} \quad \rightarrow \quad d = l \cdot \sqrt{\cos^2{\left (\frac{\alpha}{2} \right)}-\frac{1}{3}\cdot\sin^2{\left (\frac{\alpha}{2}\right )}}
+ *    \f]
+ *    vector::GetNormalvector() creates one orthonormal vector from this *Bond vector and vector::MakeNormalvector creates
+ *    the third one from the former two vectors. The latter ones form the plane of the base triangle mentioned above.
+ *    The lengths for these are \f$f\f$ and \f$g\f$ (from triangle H1-H2-(center of H1-H2-H3)) with knowledge that
+ *    the median lines in an isosceles triangle meet in the center point with a ratio 2:1.
+ *    \f[ f = \frac{b}{\sqrt{3}} \qquad g = \frac{b}{2}
+ *    \f]
+ *    as the coordination of all three atoms in the coordinate system of these three vectors:
+ *    \f$\pmatrix{d & f & 0}\f$, \f$\pmatrix{d & -0.5 \cdot f & g}\f$ and \f$\pmatrix{d & -0.5 \cdot f & -g}\f$.
+ *
+ * \param *out output stream for debugging
+ * \param *Bond pointer to bond between \a *origin and \a *replacement
+ * \param *TopOrigin son of \a *origin of upper level molecule (the atom added to this molecule as a copy of \a *origin)
+ * \param *origin pointer to atom which acts as the origin for scaling the added hydrogen to correct bond length
+ * \param *replacement pointer to the atom which shall be copied as a hydrogen atom in this molecule
+ * \param isAngstroem whether the coordination of the given atoms is in AtomicLength (false) or Angstrom(true)
+ * \return number of atoms added, if < bond::BondDegree then something went wrong
+ * \todo double and triple bonds splitting (always use the tetraeder angle!)
+ */
+bool molecule::AddHydrogenReplacementAtom(bond *TopBond, atom *BottomOrigin, atom *TopOrigin, atom *TopReplacement, bool IsAngstroem)
+{
+  bool AllWentWell = true;    // flag gathering the boolean return value of molecule::AddAtom and other functions, as return value on exit
+  OBSERVE;
+  double bondlength;  // bond length of the bond to be replaced/cut
+  double bondangle;  // bond angle of the bond to be replaced/cut
+  double BondRescale;   // rescale value for the hydrogen bond length
+  bond *FirstBond = NULL, *SecondBond = NULL; // Other bonds in double bond case to determine "other" plane
+  atom *FirstOtherAtom = NULL, *SecondOtherAtom = NULL, *ThirdOtherAtom = NULL; // pointer to hydrogen atoms to be added
+  double b,l,d,f,g, alpha, factors[NDIM];    // hold temporary values in triple bond case for coordination determination
+  Vector Orthovector1, Orthovector2;  // temporary vectors in coordination construction
+  Vector InBondvector;    // vector in direction of *Bond
+  double *matrix = NULL;
+  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;
+  bondlength = InBondvector.Norm();
+
+   // is greater than typical bond distance? Then we have to correct periodically
+   // the problem is not the H being out of the box, but InBondvector have the wrong direction
+   // due to TopReplacement or Origin being on the wrong side!
+  if (bondlength > BondDistance) {
+//    Log() << Verbose(4) << "InBondvector is: ";
+//    InBondvector.Output(out);
+//    Log() << Verbose(0) << endl;
+    Orthovector1.Zero();
+    for (int i=NDIM;i--;) {
+      l = TopReplacement->x[i] - TopOrigin->x[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);
+    InBondvector -= Orthovector1; // subtract just the additional translation
+    delete[](matrix);
+    bondlength = InBondvector.Norm();
+//    Log() << Verbose(4) << "Corrected InBondvector is now: ";
+//    InBondvector.Output(out);
+//    Log() << Verbose(0) << endl;
+  } // periodic correction finished
+
+  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];
+  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);
+    return false;
+    BondRescale = bondlength;
+  } else {
+    if (!IsAngstroem)
+      BondRescale /= (1.*AtomicLengthToAngstroem);
+  }
+
+  // discern single, double and triple bonds
+  switch(TopBond->BondDegree) {
+    case 1:
+      FirstOtherAtom = World::getInstance().createAtom();    // new atom
+      FirstOtherAtom->type = elemente->FindElement(1);  // element is Hydrogen
+      FirstOtherAtom->v = TopReplacement->v; // copy velocity
+      FirstOtherAtom->FixedIon = TopReplacement->FixedIon;
+      if (TopReplacement->type->Z == 1) { // neither rescale nor replace if it's already hydrogen
+        FirstOtherAtom->father = TopReplacement;
+        BondRescale = bondlength;
+      } else {
+        FirstOtherAtom->father = NULL;  // if we replace hydrogen, we mark it as our father, otherwise we are just an added hydrogen with no father
+      }
+      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
+      AllWentWell = AllWentWell && AddAtom(FirstOtherAtom);
+//      Log() << Verbose(4) << "Added " << *FirstOtherAtom << " at: ";
+//      FirstOtherAtom->x.Output(out);
+//      Log() << Verbose(0) << endl;
+      Binder = AddBond(BottomOrigin, FirstOtherAtom, 1);
+      Binder->Cyclic = false;
+      Binder->Type = TreeEdge;
+      break;
+    case 2:
+      // determine two other bonds (warning if there are more than two other) plus valence sanity check
+      for (BondList::const_iterator Runner = TopOrigin->ListOfBonds.begin(); Runner != TopOrigin->ListOfBonds.end(); (++Runner)) {
+        if ((*Runner) != TopBond) {
+          if (FirstBond == NULL) {
+            FirstBond = (*Runner);
+            FirstOtherAtom = (*Runner)->GetOtherAtom(TopOrigin);
+          } else if (SecondBond == NULL) {
+            SecondBond = (*Runner);
+            SecondOtherAtom = (*Runner)->GetOtherAtom(TopOrigin);
+          } else {
+            DoeLog(2) && (eLog()<< Verbose(2) << "Detected more than four bonds for atom " << TopOrigin->getName());
+          }
+        }
+      }
+      if (SecondOtherAtom == NULL) {  // then we have an atom with valence four, but only 3 bonds: one to replace and one which is TopBond (third is FirstBond)
+        SecondBond = TopBond;
+        SecondOtherAtom = TopReplacement;
+      }
+      if (FirstOtherAtom != NULL) { // then we just have this double bond and the plane does not matter at all
+//        Log() << Verbose(3) << "Regarding the double bond (" << TopOrigin->Name << "<->" << TopReplacement->Name << ") to be constructed: Taking " << FirstOtherAtom->Name << " and " << SecondOtherAtom->Name << " along with " << TopOrigin->Name << " to determine orthogonal plane." << endl;
+
+        // determine the plane of these two with the *origin
+        try {
+          Orthovector1 =Plane(TopOrigin->x, FirstOtherAtom->x, SecondOtherAtom->x).getNormal();
+        }
+        catch(LinearDependenceException &excp){
+          Log() << Verbose(0) << excp;
+          // TODO: figure out what to do with the Orthovector in this case
+          AllWentWell = false;
+        }
+      } else {
+        Orthovector1.GetOneNormalVector(InBondvector);
+      }
+      //Log() << Verbose(3)<< "Orthovector1: ";
+      //Orthovector1.Output(out);
+      //Log() << Verbose(0) << endl;
+      // orthogonal vector and bond vector between origin and replacement form the new plane
+      Orthovector1.MakeNormalTo(InBondvector);
+      Orthovector1.Normalize();
+      //Log() << Verbose(3) << "ReScaleCheck: " << Orthovector1.Norm() << " and " << InBondvector.Norm() << "." << endl;
+
+      // create the two Hydrogens ...
+      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->FixedIon = TopReplacement->FixedIon;
+      SecondOtherAtom->v = TopReplacement->v; // 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];
+      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);
+        return false;
+        bondangle = 0;
+      }
+      bondangle *= M_PI/180./2.;
+//      Log() << Verbose(3) << "ReScaleCheck: InBondvector ";
+//      InBondvector.Output(out);
+//      Log() << Verbose(0) << endl;
+//      Log() << Verbose(3) << "ReScaleCheck: Orthovector ";
+//      Orthovector1.Output(out);
+//      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();
+      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;
+      //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];
+      }
+      // ... and add to molecule
+      AllWentWell = AllWentWell && AddAtom(FirstOtherAtom);
+      AllWentWell = AllWentWell && AddAtom(SecondOtherAtom);
+//      Log() << Verbose(4) << "Added " << *FirstOtherAtom << " at: ";
+//      FirstOtherAtom->x.Output(out);
+//      Log() << Verbose(0) << endl;
+//      Log() << Verbose(4) << "Added " << *SecondOtherAtom << " at: ";
+//      SecondOtherAtom->x.Output(out);
+//      Log() << Verbose(0) << endl;
+      Binder = AddBond(BottomOrigin, FirstOtherAtom, 1);
+      Binder->Cyclic = false;
+      Binder->Type = TreeEdge;
+      Binder = AddBond(BottomOrigin, SecondOtherAtom, 1);
+      Binder->Cyclic = false;
+      Binder->Type = TreeEdge;
+      break;
+    case 3:
+      // take the "usual" tetraoidal angle and add the three Hydrogen in direction of the bond (height of the tetraoid)
+      FirstOtherAtom = World::getInstance().createAtom();
+      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->FixedIon = TopReplacement->FixedIon;
+      SecondOtherAtom->v = TopReplacement->v; // copy velocity
+      SecondOtherAtom->FixedIon = TopReplacement->FixedIon;
+      ThirdOtherAtom->v = TopReplacement->v; // copy velocity
+      ThirdOtherAtom->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
+      ThirdOtherAtom->father = NULL;  //  we are just an added hydrogen with no father
+
+      // we need to vectors orthonormal the InBondvector
+      AllWentWell = AllWentWell && Orthovector1.GetOneNormalVector(InBondvector);
+//      Log() << Verbose(3) << "Orthovector1: ";
+//      Orthovector1.Output(out);
+//      Log() << Verbose(0) << endl;
+      try{
+        Orthovector2 = Plane(InBondvector, Orthovector1,0).getNormal();
+      }
+      catch(LinearDependenceException &excp) {
+        Log() << Verbose(0) << excp;
+        AllWentWell = false;
+      }
+//      Log() << Verbose(3) << "Orthovector2: ";
+//      Orthovector2.Output(out);
+//      Log() << Verbose(0) << endl;
+
+      // create correct coordination for the three atoms
+      alpha = (TopOrigin->type->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
+      d = l*sqrt(cos(alpha)*cos(alpha) - sin(alpha)*sin(alpha)/3.);   // length for InBondvector
+      f = b/sqrt(3.);   // length for Orthvector1
+      g = b/2.;         // length for Orthvector2
+//      Log() << Verbose(3) << "Bond length and half-angle: " << l << ", " << alpha << "\t (b,d,f,g) = " << b << ", " << d << ", " << f << ", " << g << ", " << endl;
+//      Log() << Verbose(3) << "The three Bond lengths: " << sqrt(d*d+f*f) << ", " << sqrt(d*d+(-0.5*f)*(-0.5*f)+g*g) << ", "  << sqrt(d*d+(-0.5*f)*(-0.5*f)+g*g) << endl;
+      factors[0] = d;
+      factors[1] = f;
+      factors[2] = 0.;
+      FirstOtherAtom->x.LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
+      factors[1] = -0.5*f;
+      factors[2] = g;
+      SecondOtherAtom->x.LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
+      factors[2] = -g;
+      ThirdOtherAtom->x.LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
+
+      // rescale each to correct BondDistance
+//      FirstOtherAtom->x.Scale(&BondRescale);
+//      SecondOtherAtom->x.Scale(&BondRescale);
+//      ThirdOtherAtom->x.Scale(&BondRescale);
+
+      // and relative to *origin atom
+      FirstOtherAtom->x += TopOrigin->x;
+      SecondOtherAtom->x += TopOrigin->x;
+      ThirdOtherAtom->x += TopOrigin->x;
+
+      // ... and add to molecule
+      AllWentWell = AllWentWell && AddAtom(FirstOtherAtom);
+      AllWentWell = AllWentWell && AddAtom(SecondOtherAtom);
+      AllWentWell = AllWentWell && AddAtom(ThirdOtherAtom);
+//      Log() << Verbose(4) << "Added " << *FirstOtherAtom << " at: ";
+//      FirstOtherAtom->x.Output(out);
+//      Log() << Verbose(0) << endl;
+//      Log() << Verbose(4) << "Added " << *SecondOtherAtom << " at: ";
+//      SecondOtherAtom->x.Output(out);
+//      Log() << Verbose(0) << endl;
+//      Log() << Verbose(4) << "Added " << *ThirdOtherAtom << " at: ";
+//      ThirdOtherAtom->x.Output(out);
+//      Log() << Verbose(0) << endl;
+      Binder = AddBond(BottomOrigin, FirstOtherAtom, 1);
+      Binder->Cyclic = false;
+      Binder->Type = TreeEdge;
+      Binder = AddBond(BottomOrigin, SecondOtherAtom, 1);
+      Binder->Cyclic = false;
+      Binder->Type = TreeEdge;
+      Binder = AddBond(BottomOrigin, ThirdOtherAtom, 1);
+      Binder->Cyclic = false;
+      Binder->Type = TreeEdge;
+      break;
+    default:
+      DoeLog(1) && (eLog()<< Verbose(1) << "BondDegree does not state single, double or triple bond!" << endl);
+      AllWentWell = false;
+      break;
+  }
+  delete[](matrix);
+
+//  Log() << Verbose(3) << "End of AddHydrogenReplacementAtom." << endl;
+  return AllWentWell;
+};
+
+/** Adds given atom \a *pointer from molecule list.
+ * Increases molecule::last_atom and gives last number to added atom.
+ * \param filename name and path of xyz file
+ * \return true - succeeded, false - file not found
+ */
+bool molecule::AddXYZFile(string filename)
+{
+
+  istringstream *input = NULL;
+  int NumberOfAtoms = 0; // atom number in xyz read
+  int i, j; // loop variables
+  atom *Walker = NULL;  // pointer to added atom
+  char shorthand[3];  // shorthand for atom name
+  ifstream xyzfile;   // xyz file
+  string line;    // currently parsed line
+  double x[3];    // atom coordinates
+
+  xyzfile.open(filename.c_str());
+  if (!xyzfile)
+    return false;
+
+  OBSERVE;
+  getline(xyzfile,line,'\n'); // Read numer of atoms in file
+  input = new istringstream(line);
+  *input >> NumberOfAtoms;
+  DoLog(0) && (Log() << Verbose(0) << "Parsing " << NumberOfAtoms << " atoms in file." << endl);
+  getline(xyzfile,line,'\n'); // Read comment
+  DoLog(1) && (Log() << Verbose(1) << "Comment: " << line << endl);
+
+  if (MDSteps == 0) // no atoms yet present
+    MDSteps++;
+  for(i=0;i<NumberOfAtoms;i++){
+    Walker = World::getInstance().createAtom();
+    getline(xyzfile,line,'\n');
+    istringstream *item = new istringstream(line);
+    //istringstream input(line);
+    //Log() << Verbose(1) << "Reading: " << line << endl;
+    *item >> shorthand;
+    *item >> x[0];
+    *item >> x[1];
+    *item >> x[2];
+    Walker->type = elemente->FindElement(shorthand);
+    if (Walker->type == NULL) {
+      DoeLog(1) && (eLog()<< Verbose(1) << "Could not parse the element at line: '" << line << "', setting to H.");
+      Walker->type = elemente->FindElement(1);
+    }
+    if (Walker->Trajectory.R.size() <= (unsigned int)MDSteps) {
+      Walker->Trajectory.R.resize(MDSteps+10);
+      Walker->Trajectory.U.resize(MDSteps+10);
+      Walker->Trajectory.F.resize(MDSteps+10);
+    }
+    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;
+      Walker->Trajectory.F.at(MDSteps-1)[j] = 0;
+    }
+    AddAtom(Walker);  // add to molecule
+    delete(item);
+  }
+  xyzfile.close();
+  delete(input);
+  return true;
+};
+
+/** Creates a copy of this molecule.
+ * \return copy of molecule
+ */
+molecule *molecule::CopyMolecule()
+{
+  molecule *copy = World::getInstance().createMolecule();
+  atom *LeftAtom = NULL, *RightAtom = NULL;
+
+  // copy all atoms
+  ActOnCopyWithEachAtom ( &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);
+
+        // 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);
+        NewBond->Cyclic = Binder->Cyclic;
+        if (Binder->Cyclic)
+          copy->NoCyclicBonds++;
+        NewBond->Type = Binder->Type;
+      }
+  // correct fathers
+  ActOnAllAtoms( &atom::CorrectFather );
+
+  // copy values
+  copy->CountElements();
+  if (hasBondStructure()) {  // if adjaceny list is present
+    copy->BondDistance = BondDistance;
+  }
+
+  return copy;
+};
+
+
+/**
+ * Copies all atoms of a molecule which are within the defined parallelepiped.
+ *
+ * @param offest for the origin of the parallelepiped
+ * @param three vectors forming the matrix that defines the shape of the parallelpiped
+ */
+molecule* molecule::CopyMoleculeFromSubRegion(const Vector offset, const double *parallelepiped) const {
+  molecule *copy = World::getInstance().createMolecule();
+
+  ActOnCopyWithEachAtomIfTrue ( &molecule::AddCopyAtom, copy, &atom::IsInParallelepiped, offset, parallelepiped );
+
+  //TODO: copy->BuildInducedSubgraph(this);
+
+  return copy;
+}
+
+/** Adds a bond to a the molecule specified by two atoms, \a *first and \a *second.
+ * Also updates molecule::BondCount and molecule::NoNonBonds.
+ * \param *first first atom in bond
+ * \param *second atom in bond
+ * \return pointer to bond or NULL on failure
+ */
+bond * molecule::AddBond(atom *atom1, atom *atom2, int degree)
+{
+  OBSERVE;
+  bond *Binder = NULL;
+
+  // some checks to make sure we are able to create the bond
+  ASSERT(atom1, "First atom in bond-creation was an invalid pointer");
+  ASSERT(atom2, "Second atom in bond-creation was an invalid pointer");
+  ASSERT(FindAtom(atom1->nr),"First atom in bond-creation was not part of molecule");
+  ASSERT(FindAtom(atom2->nr),"Second atom in bond-creation was not parto of molecule");
+
+  Binder = new bond(atom1, atom2, degree, BondCount++);
+  atom1->RegisterBond(Binder);
+  atom2->RegisterBond(Binder);
+  if ((atom1->type != NULL) && (atom1->type->Z != 1) && (atom2->type != NULL) && (atom2->type->Z != 1))
+    NoNonBonds++;
+
+  return Binder;
+};
+
+/** Remove bond from bond chain list and from the both atom::ListOfBonds.
+ * \todo Function not implemented yet
+ * \param *pointer bond pointer
+ * \return true - bound found and removed, false - bond not found/removed
+ */
+bool molecule::RemoveBond(bond *pointer)
+{
+  //DoeLog(1) && (eLog()<< Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl);
+  delete(pointer);
+  return true;
+};
+
+/** Remove every bond from bond chain list that atom \a *BondPartner is a constituent of.
+ * \todo Function not implemented yet
+ * \param *BondPartner atom to be removed
+ * \return true - bounds found and removed, false - bonds not found/removed
+ */
+bool molecule::RemoveBonds(atom *BondPartner)
+{
+  //DoeLog(1) && (eLog()<< Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl);
+  BondList::const_iterator ForeRunner;
+  while (!BondPartner->ListOfBonds.empty()) {
+    ForeRunner = BondPartner->ListOfBonds.begin();
+    RemoveBond(*ForeRunner);
+  }
+  return false;
+};
+
+/** Set molecule::name from the basename without suffix in the given \a *filename.
+ * \param *filename filename
+ */
+void molecule::SetNameFromFilename(const char *filename)
+{
+  int length = 0;
+  const char *molname = strrchr(filename, '/');
+  if (molname != NULL)
+    molname += sizeof(char);  // search for filename without dirs
+  else
+    molname = filename; // contains no slashes
+  const char *endname = strchr(molname, '.');
+  if ((endname == NULL) || (endname < molname))
+    length = strlen(molname);
+  else
+    length = strlen(molname) - strlen(endname);
+  cout << "Set name of molecule " << getId() << " to " << molname << endl;
+  strncpy(name, molname, length);
+  name[length]='\0';
+};
+
+/** Sets the molecule::cell_size to the components of \a *dim (rectangular box)
+ * \param *dim vector class
+ */
+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.
+ * \param *pointer atom to be removed
+ * \return true - succeeded, false - atom not found in list
+ */
+bool molecule::RemoveAtom(atom *pointer)
+{
+  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);
+  return true;
+};
+
+/** Removes atom from molecule list, but does not delete it.
+ * \param *pointer atom to be removed
+ * \return true - succeeded, false - atom not found in list
+ */
+bool molecule::UnlinkAtom(atom *pointer)
+{
+  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;
+};
+
+/** Removes every atom from molecule list.
+ * \return true - succeeded, false - atom not found in list
+ */
+bool molecule::CleanupMolecule()
+{
+  for (molecule::iterator iter = begin(); !empty(); iter = begin())
+      erase(iter);
+  return empty();
+};
+
+/** Finds an atom specified by its continuous number.
+ * \param Nr number of atom withim molecule
+ * \return pointer to atom or NULL
+ */
+atom * molecule::FindAtom(int Nr)  const
+{
+  molecule::const_iterator iter = begin();
+  for (; iter != end(); ++iter)
+    if ((*iter)->nr == Nr)
+      break;
+  if (iter != end()) {
+    //Log() << Verbose(0) << "Found Atom Nr. " << walker->nr << endl;
+    return (*iter);
+  } else {
+    DoLog(0) && (Log() << Verbose(0) << "Atom not found in list." << endl);
+    return NULL;
+  }
+};
+
+/** Asks for atom number, and checks whether in list.
+ * \param *text question before entering
+ */
+atom * molecule::AskAtom(string text)
+{
+  int No;
+  atom *ion = NULL;
+  do {
+    //Log() << Verbose(0) << "============Atom list==========================" << endl;
+    //mol->Output((ofstream *)&cout);
+    //Log() << Verbose(0) << "===============================================" << endl;
+    DoLog(0) && (Log() << Verbose(0) << text);
+    cin >> No;
+    ion = this->FindAtom(No);
+  } while (ion == NULL);
+  return ion;
+};
+
+/** Checks if given coordinates are within cell volume.
+ * \param *x array of coordinates
+ * \return true - is within, false - out of cell
+ */
+bool molecule::CheckBounds(const Vector *x) const
+{
+  double * const cell_size = World::getInstance().getDomain();
+  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]));
+  }
+  //return result;
+  return true; /// probably not gonna use the check no more
+};
+
+/** Prints molecule to *out.
+ * \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;
+  }
+  if (output == NULL) {
+    return false;
+  } else {
+    *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 );
+    return true;
+  }
+};
+
+/** Prints molecule with all atomic trajectory positions to *out.
+ * \param *out output stream
+ */
+bool molecule::OutputTrajectories(ofstream * const output)
+{
+  int ElementNo[MAX_ELEMENTS], AtomNo[MAX_ELEMENTS];
+  CountElements();
+
+  if (output == NULL) {
+    return false;
+  } else {
+    for (int step = 0; step < MDSteps; step++) {
+      if (step == 0) {
+        *output << "#Ion_TypeNr._Nr.R[0]    R[1]    R[2]    MoveType (0 MoveIon, 1 FixedIon)" << endl;
+      } else {
+        *output << "# ====== MD step " << step << " =========" << endl;
+      }
+      for (int i=0;i<MAX_ELEMENTS;++i) {
+        AtomNo[i] = 0;
+        ElementNo[i] = 0;
+      }
+      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::OutputTrajectory, output, (const int *)ElementNo, AtomNo, (const int)step );
+    }
+    return true;
+  }
+};
+
+/** Outputs contents of each atom::ListOfBonds.
+ * \param *out output stream
+ */
+void molecule::OutputListOfBonds() const
+{
+  DoLog(2) && (Log() << Verbose(2) << endl << "From Contents of ListOfBonds, all non-hydrogen atoms:" << endl);
+  ActOnAllAtoms (&atom::OutputBondOfAtom );
+  DoLog(0) && (Log() << Verbose(0) << endl);
+};
+
+/** Output of element before the actual coordination list.
+ * \param *out stream pointer
+ */
+bool molecule::Checkout(ofstream * const output)  const
+{
+  return elemente->Checkout(output, ElementsInMolecule);
+};
+
+/** Prints molecule with all its trajectories to *out as xyz file.
+ * \param *out output stream
+ */
+bool molecule::OutputTrajectoriesXYZ(ofstream * const output)
+{
+  time_t now;
+
+  if (output != NULL) {
+    now = time((time_t *)NULL);   // Get the system time and put it into 'now' as 'calender time'
+    for (int step=0;step<MDSteps;step++) {
+      *output << getAtomCount() << "\n\tCreated by molecuilder, step " << step << ", on " << ctime(&now);
+      ActOnAllAtoms( &atom::OutputTrajectoryXYZ, output, step );
+    }
+    return true;
+  } else
+    return false;
+};
+
+/** Prints molecule to *out as xyz file.
+* \param *out output stream
+ */
+bool molecule::OutputXYZ(ofstream * const output) const
+{
+  time_t now;
+
+  if (output != NULL) {
+    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 );
+    return true;
+  } else
+    return false;
+};
+
+/** Brings molecule::AtomCount and atom::*Name up-to-date.
+ * \param *out output stream for debugging
+ */
+int molecule::doCountAtoms()
+{
+  int res = size();
+  int i = 0;
+  NoNonHydrogen = 0;
+  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
+      NoNonHydrogen++;
+    stringstream sstr;
+    sstr << (*iter)->type->symbol << (*iter)->nr+1;
+    (*iter)->setName(sstr.str());
+    DoLog(3) && (Log() << Verbose(3) << "Naming atom nr. " << (*iter)->nr << " " << (*iter)->getName() << "." << endl);
+    i++;
+  }
+  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;
+  }
+};
+
+/** Returns an index map for two father-son-molecules.
+ * The map tells which atom in this molecule corresponds to which one in the other molecul with their fathers.
+ * \param *out output stream for debugging
+ * \param *OtherMolecule corresponding molecule with fathers
+ * \return allocated map of size molecule::AtomCount with map
+ * \todo make this with a good sort O(n), not O(n^2)
+ */
+int * molecule::GetFatherSonAtomicMap(molecule *OtherMolecule)
+{
+  DoLog(3) && (Log() << Verbose(3) << "Begin of GetFatherAtomicMap." << endl);
+  int *AtomicMap = new int[getAtomCount()];
+  for (int i=getAtomCount();i--;)
+    AtomicMap[i] = -1;
+  if (OtherMolecule == this) {  // same molecule
+    for (int i=getAtomCount();i--;) // no need as -1 means already that there is trivial correspondence
+      AtomicMap[i] = i;
+    DoLog(4) && (Log() << Verbose(4) << "Map is trivial." << endl);
+  } else {
+    DoLog(4) && (Log() << Verbose(4) << "Map is ");
+    for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+      if ((*iter)->father == NULL) {
+        AtomicMap[(*iter)->nr] = -2;
+      } else {
+        for (molecule::const_iterator runner = OtherMolecule->begin(); runner != OtherMolecule->end(); ++runner) {
+      //for (int i=0;i<AtomCount;i++) { // search atom
+        //for (int j=0;j<OtherMolecule->getAtomCount();j++) {
+          //Log() << Verbose(4) << "Comparing father " << (*iter)->father << " with the other one " << (*runner)->father << "." << endl;
+          if ((*iter)->father == (*runner))
+            AtomicMap[(*iter)->nr] = (*runner)->nr;
+        }
+      }
+      DoLog(0) && (Log() << Verbose(0) << AtomicMap[(*iter)->nr] << "\t");
+    }
+    DoLog(0) && (Log() << Verbose(0) << endl);
+  }
+  DoLog(3) && (Log() << Verbose(3) << "End of GetFatherAtomicMap." << endl);
+  return AtomicMap;
+};
+
+/** Stores the temperature evaluated from velocities in molecule::Trajectories.
+ * We simply use the formula equivaleting temperature and kinetic energy:
+ * \f$k_B T = \sum_i m_i v_i^2\f$
+ * \param *output output stream of temperature file
+ * \param startstep first MD step in molecule::Trajectories
+ * \param endstep last plus one MD step in molecule::Trajectories
+ * \return file written (true), failure on writing file (false)
+ */
+bool molecule::OutputTemperatureFromTrajectories(ofstream * const output, int startstep, int endstep)
+{
+  double temperature;
+  // test stream
+  if (output == NULL)
+    return false;
+  else
+    *output << "# Step Temperature [K] Temperature [a.u.]" << endl;
+  for (int step=startstep;step < endstep; step++) { // loop over all time steps
+    temperature = 0.;
+    ActOnAllAtoms( &TrajectoryParticle::AddKineticToTemperature, &temperature, step);
+    *output << step << "\t" << temperature*AtomicEnergyToKelvin << "\t" << temperature << endl;
+  }
+  return true;
+};
+
+void molecule::SetIndexedArrayForEachAtomTo ( atom **array, int ParticleInfo::*index) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    array[((*iter)->*index)] = (*iter);
+  }
+};
+
+void molecule::flipActiveFlag(){
+  ActiveFlag = !ActiveFlag;
+}
Index: src/molecule.hpp
===================================================================
--- src/molecule.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/molecule.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,438 @@
+/** \file molecule.hpp
+ *
+ * Class definitions of atom and molecule, element and periodentafel
+ */
+
+#ifndef MOLECULES_HPP_
+#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>
+
+//// STL headers
+#include <map>
+#include <set>
+#include <deque>
+#include <list>
+#include <vector>
+
+#include <string>
+
+#include "types.hpp"
+#include "graph.hpp"
+#include "stackclass.hpp"
+#include "tesselation.hpp"
+#include "Patterns/Observer.hpp"
+#include "Patterns/ObservedIterator.hpp"
+#include "Patterns/Cacheable.hpp"
+
+#include "Descriptors/MoleculeDescriptor_impl.hpp"
+
+/****************************************** forward declarations *****************************/
+
+class atom;
+class bond;
+class BondedParticle;
+class BondGraph;
+class element;
+class ForceMatrix;
+class LinkedCell;
+class molecule;
+class MoleculeLeafClass;
+class MoleculeListClass;
+class periodentafel;
+class Vector;
+
+/******************************** Some definitions for easier reading **********************************/
+
+#define MoleculeList list <molecule *>
+#define MoleculeListTest pair <MoleculeList::iterator, bool>
+
+#define DistancePair pair < double, atom* >
+#define DistanceMap multimap < double, atom* >
+#define DistanceTestPair pair < DistanceMap::iterator, bool>
+
+
+/************************************* Class definitions ****************************************/
+
+/** Structure to contain parameters needed for evaluation of constraint potential.
+ */
+struct EvaluatePotential
+{
+  int startstep;              //!< start configuration (MDStep in atom::trajectory)
+  int endstep;                //!< end configuration (MDStep in atom::trajectory)
+  atom **PermutationMap;      //!< gives target ptr for each atom, array of size molecule::AtomCount (this is "x" in \f$ V^{con}(x) \f$ )
+  DistanceMap **DistanceList; //!< distance list of each atom to each atom
+  DistanceMap::iterator *StepList; //!< iterator to ascend through NearestNeighbours \a **DistanceList
+  int *DoubleList;            //!< count of which sources want to move to this target, basically the injective measure (>1 -> not injective)
+  DistanceMap::iterator *DistanceIterators; //!< marks which was the last picked target as injective candidate with smallest distance
+  bool IsAngstroem;           //!< whether coordinates are in angstroem (true) or bohrradius (false)
+  double *PenaltyConstants;   //!<  penalty constant in front of each term
+};
+
+/** The complete molecule.
+ * Class incorporates number of types
+ */
+class molecule : public PointCloud , public Observable {
+  friend molecule *NewMolecule();
+  friend void DeleteMolecule(molecule *);
+
+  public:
+    typedef std::list<atom*> atomSet;
+    typedef std::set<atomId_t> atomIdSet;
+    typedef ObservedIterator<atomSet> iterator;
+    typedef atomSet::const_iterator const_iterator;
+
+    const periodentafel * const elemente; //!< periodic table with each element
+    // old deprecated atom handling
+    //atom *start;        //!< start of atom list
+    //atom *end;          //!< end of atom list
+    //bond *first;        //!< start of bond list
+    //bond *last;         //!< end of bond list
+    int MDSteps;        //!< The number of MD steps in Trajectories
+    //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
+    mutable int NoCyclicBonds;  //!< number of cyclic bonds in molecule, by DepthFirstSearchAnalysis()
+    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
+    int IndexNr;        //!< index of molecule in a MoleculeListClass
+    char name[MAXSTRINGSIZE];         //!< arbitrary name
+
+  private:
+    Cacheable<string> formula;
+    Cacheable<int>    AtomCount;
+    moleculeId_t id;
+    atomSet atoms; //<!list of atoms
+    atomIdSet atomIds; //<!set of atomic ids to check uniqueness of atoms
+  protected:
+    //void CountAtoms();
+    /**
+     * this iterator type should be used for internal variables, \
+     * since it will not lock
+     */
+    typedef atomSet::iterator internal_iterator;
+
+
+    molecule(const periodentafel * const teil);
+    virtual ~molecule();
+
+
+public:
+  //getter and setter
+  const std::string getName();
+  int getAtomCount() const;
+  int doCountAtoms();
+  moleculeId_t getId();
+  void setId(moleculeId_t);
+  void setName(const std::string);
+  const std::string getFormula();
+  std::string calcFormula();
+
+  iterator begin();
+  const_iterator begin() const;
+  iterator end();
+  const_iterator end() const;
+  bool empty() const;
+  size_t size() const;
+  const_iterator erase( const_iterator loc );
+  const_iterator erase( atom * key );
+  const_iterator find (  atom * key ) const;
+  pair<iterator,bool> insert ( atom * const key );
+  bool containsAtom(atom* key);
+
+
+  // re-definition of virtual functions from PointCloud
+  const char * const GetName() const;
+  Vector *GetCenter() const ;
+  TesselPoint *GetPoint() const ;
+  int GetMaxId() const;
+  void GoToNext() const ;
+  void GoToFirst() const ;
+  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
+  template <typename res> void ActWithEachAtom( res (molecule::*f)(atom *) ) const;
+  template <typename res> void ActWithEachAtom( res (molecule::*f)(atom *) const) const;
+
+  // templates for allowing global copying of molecule with each atom as single argument
+  template <typename res> void ActOnCopyWithEachAtom( res (molecule::*f)(atom *) , molecule *copy) const;
+  template <typename res> void ActOnCopyWithEachAtom( res (molecule::*f)(atom *) const, molecule *copy) const;
+
+  // templates for allowing global manipulation of all atoms
+  template <typename res, typename typ> void ActOnAllAtoms( res (typ::*f)() ) const;
+  template <typename res, typename typ> void ActOnAllAtoms( res (typ::*f)() const) const;
+  template <typename res, typename typ, typename T> void ActOnAllAtoms( res (typ::*f)(T), T t ) const;
+  template <typename res, typename typ, typename T> void ActOnAllAtoms( res (typ::*f)(T) const, T t ) const;
+  template <typename res, typename typ, typename T, typename U> void ActOnAllAtoms( res (typ::*f)(T, U), T t, U u ) const;
+  template <typename res, typename typ, typename T, typename U> void ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u ) const;
+  template <typename res, typename typ, typename T, typename U, typename V> void ActOnAllAtoms( res (typ::*f)(T, U, V), T t, U u, V v) const;
+  template <typename res, typename typ, typename T, typename U, typename V> void ActOnAllAtoms( res (typ::*f)(T, U, V) const, T t, U u, V v) const;
+  template <typename res, typename typ, typename T, typename U, typename V, typename W> void ActOnAllAtoms( res (typ::*f)(T, U, V, W), T t, U u, V v, W w) const;
+  template <typename res, typename typ, typename T, typename U, typename V, typename W> void ActOnAllAtoms( res (typ::*f)(T, U, V, W) const, T t, U u, V v, W w) const;
+
+  // templates for allowing conditional global copying of molecule with each atom as single argument
+  template <typename res> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () ) const;
+  template <typename res> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () const ) const;
+  template <typename res> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) () ) const;
+  template <typename res> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) () const ) const;
+  template <typename res, typename T> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T), T t ) const;
+  template <typename res, typename T> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T) const, T t ) const;
+  template <typename res, typename T> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) (T), T t ) const;
+  template <typename res, typename T> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) (T) const, T t ) const;
+  template <typename res, typename T, typename U> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U), T t, U u ) const;
+  template <typename res, typename T, typename U> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U) const, T t, U u ) const;
+  template <typename res, typename T, typename U> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) (T, U), T t, U u ) const;
+  template <typename res, typename T, typename U> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) (T, U) const, T t, U u ) const;
+  template <typename res, typename T, typename U, typename V> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v ) const;
+  template <typename res, typename T, typename U, typename V> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V) const, T t, U u, V v ) const;
+  template <typename res, typename T, typename U, typename V> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v ) const;
+  template <typename res, typename T, typename U, typename V> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) (T, U, V) const, T t, U u, V v ) const;
+
+  // templates for allowing global manipulation of an array with one entry per atom
+  void SetIndexedArrayForEachAtomTo ( atom **array, int ParticleInfo::* index) const;
+  template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::* index, void (*Setor)(T *, T *)) const;
+  template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::* index, void (*Setor)(T *, T *), T t) const;
+  template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::* index, void (*Setor)(T *, T *), T *t) const;
+  template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int element::* index, void (*Setor)(T *, T *)) const;
+  template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int element::* index, void (*Setor)(T *, T *), T t) const;
+  template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int element::* index, void (*Setor)(T *, T *), T *t) const;
+  template <typename T, typename typ> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ atom::*value) const;
+  template <typename T, typename typ> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ atom::*value) const;
+  template <typename T, typename typ> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ &vect ) const;
+  template <typename T, typename typ> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ &vect ) const;
+
+  // templates for allowing global manipulation of each atom by entries in an array
+  template <typename T, typename typ, typename typ2> void SetAtomValueToIndexedArray ( T *array, int typ::*index, T typ2::*value ) const;
+  template <typename T, typename typ> void SetAtomValueToValue ( T value, T typ::*ptr ) const;
+
+  template <typename res, typename typ> res SumPerAtom(res (typ::*f)() ) const;
+  template <typename res, typename typ> res SumPerAtom(res (typ::*f)() const ) const;
+  template <typename res, typename typ, typename T> res SumPerAtom(res (typ::*f)(T) , T t ) const;
+  template <typename res, typename typ, typename T> res SumPerAtom(res (typ::*f)(T) const, T t ) const;
+
+  /// remove atoms from molecule.
+  bool AddAtom(atom *pointer);
+  bool RemoveAtom(atom *pointer);
+  bool UnlinkAtom(atom *pointer);
+  bool CleanupMolecule();
+
+  /// Add/remove atoms to/from molecule.
+  atom * AddCopyAtom(atom *pointer);
+  bool AddXYZFile(string filename);
+  bool AddHydrogenReplacementAtom(bond *Bond, atom *BottomOrigin, atom *TopOrigin, atom *TopReplacement, bool IsAngstroem);
+  bond * AddBond(atom *first, atom *second, int degree = 1);
+  bool RemoveBond(bond *pointer);
+  bool RemoveBonds(atom *BondPartner);
+  bool hasBondStructure();
+  unsigned int CountBonds() const;
+
+  /// Find atoms.
+  atom * FindAtom(int Nr) const;
+  atom * AskAtom(string text);
+
+  /// Count and change present atoms' coordination.
+  void CountElements();
+  bool CenterInBox();
+  bool BoundInBox();
+  void CenterEdge(Vector *max);
+  void CenterOrigin();
+  void CenterPeriodic();
+  void CenterAtVector(Vector *newcenter);
+  void Translate(const Vector *x);
+  void TranslatePeriodically(const Vector *trans);
+  void Mirror(const Vector *x);
+  void Align(Vector *n);
+  void Scale(const double ** const factor);
+  void DeterminePeriodicCenter(Vector &center);
+  Vector * DetermineCenterOfGravity();
+  Vector * DetermineCenterOfAll() const;
+  Vector * DetermineCenterOfBox() const;
+  void SetNameFromFilename(const char *filename);
+  void SetBoxDimension(Vector *dim);
+  void ScanForPeriodicCorrection();
+  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);
+
+  double ConstrainedPotential(struct EvaluatePotential &Params);
+  double MinimiseConstrainedPotential(atom **&permutation, int startstep, int endstep, bool IsAngstroem);
+  void EvaluateConstrainedForces(int startstep, int endstep, atom **PermutationMap, ForceMatrix *Force);
+  bool LinearInterpolationBetweenConfiguration(int startstep, int endstep, std::string &prefix, config &configuration, bool MapByIdentity);
+	
+  bool CheckBounds(const Vector *x) const;
+  void GetAlignvector(struct lsq_params * par) const;
+
+  /// Initialising routines in fragmentation
+  void CreateAdjacencyListFromDbondFile(ifstream *output);
+  void CreateAdjacencyList(double bonddistance, bool IsAngstroem, void (BondGraph::*f)(BondedParticle * const , BondedParticle * const , double &, double &, bool), BondGraph *BG = NULL);
+  int CorrectBondDegree() const;
+  void OutputBondsList() const;
+  void CyclicBondAnalysis() const;
+  void OutputGraphInfoPerAtom() const;
+  void OutputGraphInfoPerBond() const;
+
+
+  // Graph analysis
+  MoleculeLeafClass * DepthFirstSearchAnalysis(class StackClass<bond *> *&BackEdgeStack) const;
+  void CyclicStructureAnalysis(class StackClass<bond *> *BackEdgeStack, int *&MinimumRingSize) const;
+  bool PickLocalBackEdges(atom **ListOfLocalAtoms, class StackClass<bond *> *&ReferenceStack, class StackClass<bond *> *&LocalStack) const;
+  bond * FindNextUnused(atom *vertex) const;
+  void SetNextComponentNumber(atom *vertex, int nr) const;
+  void ResetAllBondsToUnused() const;
+  int CountCyclicBonds();
+  bool CheckForConnectedSubgraph(KeySet *Fragment);
+  string GetColor(enum Shading color) const;
+  bond * CopyBond(atom *left, atom *right, bond *CopyBond);
+
+
+  molecule *CopyMolecule();
+  molecule* CopyMoleculeFromSubRegion(const Vector offset, const double *parallelepiped) const;
+
+  /// Fragment molecule by two different approaches:
+  int FragmentMolecule(int Order, std::string &prefix);
+  bool CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, std::string path = "");
+  bool StoreBondsToFile(std::string &filename, std::string path = "");
+  bool StoreAdjacencyToFile(std::string &filename, std::string path = "");
+  bool CheckAdjacencyFileAgainstMolecule(std::string &path, atom **ListOfAtoms);
+  bool ParseOrderAtSiteFromFile(std::string &path);
+  bool StoreOrderAtSiteFile(std::string &path);
+  bool StoreForcesFile(MoleculeListClass *BondFragments, std::string &path, int *SortIndex);
+  bool CreateMappingLabelsToConfigSequence(int *&SortIndex);
+  bool CreateFatherLookupTable(atom **&LookupTable, int count = 0);
+  void BreadthFirstSearchAdd(molecule *Mol, atom **&AddedAtomList, bond **&AddedBondList, atom *Root, bond *Bond, int BondOrder, bool IsAngstroem);
+  /// -# BOSSANOVA
+  void FragmentBOSSANOVA(Graph *&FragmentList, KeyStack &RootStack, int *MinimumRingSize);
+  int PowerSetGenerator(int Order, struct UniqueFragments &FragmentSearch, KeySet RestrictedKeySet);
+  bool BuildInducedSubgraph(const molecule *Father);
+  molecule * StoreFragmentFromKeySet(KeySet &Leaflet, bool IsAngstroem);
+  void SPFragmentGenerator(struct UniqueFragments *FragmentSearch, int RootDistance, bond **BondsSet, int SetDimension, int SubOrder);
+  int LookForRemovalCandidate(KeySet *&Leaf, int *&ShortestPathList);
+  int GuesstimateFragmentCount(int order);
+
+  // 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 OutputTrajectories(ofstream * const output);
+  void OutputListOfBonds() const;
+  bool OutputXYZ(ofstream * const output) const;
+  bool OutputTrajectoriesXYZ(ofstream * const output);
+  bool Checkout(ofstream * const output) const;
+  bool OutputTemperatureFromTrajectories(ofstream * const output, int startstep, int endstep);
+
+  // Manipulation routines
+  void flipActiveFlag();
+
+  private:
+  int last_atom;      //!< number given to last atom
+  mutable internal_iterator InternalPointer;  //!< internal pointer for PointCloud
+};
+
+molecule *NewMolecule();
+void DeleteMolecule(molecule* mol);
+
+#include "molecule_template.hpp"
+
+/** A list of \a molecule classes.
+ */
+class MoleculeListClass : public Observable {
+  public:
+    MoleculeList ListOfMolecules; //!< List of the contained molecules
+    int MaxIndex;
+
+  MoleculeListClass(World *world);
+  ~MoleculeListClass();
+
+  bool AddHydrogenCorrection(std::string &path);
+  bool StoreForcesFile(std::string &path, int *SortIndex);
+  void insert(molecule *mol);
+  void erase(molecule *mol);
+  molecule * ReturnIndex(int index);
+  bool OutputConfigForListOfFragments(std::string &prefix, int *SortIndex);
+  int NumberOfActiveMolecules();
+  void Enumerate(ostream *out);
+  void Output(ofstream *out);
+  void DissectMoleculeIntoConnectedSubgraphs(const periodentafel * const periode, config * const configuration);
+  int CountAllAtoms() const;
+
+  // Methods moved here from the menus
+  // TODO: more refactoring needed on these methods
+  void flipChosen();
+  void createNewMolecule(periodentafel *periode);
+  void loadFromXYZ(periodentafel *periode);
+  void setMoleculeFilename();
+  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:
+  World *world; //!< The world this List belongs to. Needed to avoid deadlocks in the destructor
+};
+
+
+/** A leaf for a tree of \a molecule class
+ * Wraps molecules in a tree structure
+ */
+class MoleculeLeafClass {
+  public:
+    molecule *Leaf;                   //!< molecule of this leaf
+    //MoleculeLeafClass *UpLeaf;        //!< Leaf one level up
+    //MoleculeLeafClass *DownLeaf;      //!< First leaf one level down
+    MoleculeLeafClass *previous;  //!< Previous leaf on this level
+    MoleculeLeafClass *next;      //!< Next leaf on this level
+
+  //MoleculeLeafClass(MoleculeLeafClass *Up, MoleculeLeafClass *Previous);
+  MoleculeLeafClass(MoleculeLeafClass *PreviousLeaf);
+  ~MoleculeLeafClass();
+
+  bool AddLeaf(molecule *ptr, MoleculeLeafClass *Previous);
+  bool FillBondStructureFromReference(const molecule * const reference, atom **&ListOfLocalAtoms, bool FreeList = false);
+  bool FillRootStackForSubgraphs(KeyStack *&RootStack, bool *AtomMask, int &FragmentCounter);
+  bool AssignKeySetsToFragment(molecule *reference, Graph *KeySetList, atom ***&ListOfLocalAtoms, Graph **&FragmentList, int &FragmentCounter, bool FreeList = false);
+  bool FillListOfLocalAtoms(atom **&ListOfLocalAtoms, const int GlobalAtomCount, bool &FreeList);
+  void TranslateIndicesToGlobalIDs(Graph **FragmentList, int &FragmentCounter, int &TotalNumberOfKeySets, Graph &TotalGraph);
+  int Count() const;
+};
+
+
+#endif /*MOLECULES_HPP_*/
+
Index: src/molecule_dynamics.cpp
===================================================================
--- src/molecule_dynamics.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/molecule_dynamics.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,695 @@
+/*
+ * molecule_dynamics.cpp
+ *
+ *  Created on: Oct 5, 2009
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "World.hpp"
+#include "atom.hpp"
+#include "config.hpp"
+#include "element.hpp"
+#include "info.hpp"
+#include "log.hpp"
+#include "memoryallocator.hpp"
+#include "molecule.hpp"
+#include "parser.hpp"
+#include "Plane.hpp"
+#include "ThermoStatContainer.hpp"
+
+/************************************* Functions for class molecule *********************************/
+
+/** Penalizes long trajectories.
+ * \param *Walker atom to check against others
+ * \param *mol molecule with other atoms
+ * \param &Params constraint potential parameters
+ * \return penalty times each distance
+ */
+double SumDistanceOfTrajectories(atom *Walker, molecule *mol, struct EvaluatePotential &Params)
+{
+  gsl_matrix *A = gsl_matrix_alloc(NDIM,NDIM);
+  gsl_vector *x = gsl_vector_alloc(NDIM);
+  atom *Sprinter = NULL;
+  Vector trajectory1, trajectory2, normal, TestVector;
+  double Norm1, Norm2, tmp, result = 0.;
+
+  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
+    if ((*iter) == Walker) // hence, we only go up to the Walker, not beyond (similar to i=0; i<j; i++)
+      break;
+    // determine normalized trajectories direction vector (n1, n2)
+    Sprinter = Params.PermutationMap[Walker->nr];   // find first target point
+    trajectory1 = Sprinter->Trajectory.R.at(Params.endstep) - Walker->Trajectory.R.at(Params.startstep);
+    trajectory1.Normalize();
+    Norm1 = trajectory1.Norm();
+    Sprinter = Params.PermutationMap[(*iter)->nr];   // find second target point
+    trajectory2 = Sprinter->Trajectory.R.at(Params.endstep) - (*iter)->Trajectory.R.at(Params.startstep);
+    trajectory2.Normalize();
+    Norm2 = trajectory1.Norm();
+    // check whether either is zero()
+    if ((Norm1 < MYEPSILON) && (Norm2 < MYEPSILON)) {
+      tmp = Walker->Trajectory.R.at(Params.startstep).distance((*iter)->Trajectory.R.at(Params.startstep));
+    } else if (Norm1 < MYEPSILON) {
+      Sprinter = Params.PermutationMap[Walker->nr];   // find first target point
+      trajectory1 = Sprinter->Trajectory.R.at(Params.endstep) - (*iter)->Trajectory.R.at(Params.startstep);
+      trajectory2 *= trajectory1.ScalarProduct(trajectory2); // trajectory2 is scaled to unity, hence we don't need to divide by anything
+      trajectory1 -= trajectory2;   // project the part in norm direction away
+      tmp = trajectory1.Norm();  // remaining norm is distance
+    } else if (Norm2 < MYEPSILON) {
+      Sprinter = Params.PermutationMap[(*iter)->nr];   // find second target point
+      trajectory2 = Sprinter->Trajectory.R.at(Params.endstep) - Walker->Trajectory.R.at(Params.startstep);  // copy second offset
+      trajectory1 *= trajectory2.ScalarProduct(trajectory1); // trajectory1 is scaled to unity, hence we don't need to divide by anything
+      trajectory2 -= trajectory1;   // project the part in norm direction away
+      tmp = trajectory2.Norm();  // remaining norm is distance
+    } else if ((fabs(trajectory1.ScalarProduct(trajectory2)/Norm1/Norm2) - 1.) < MYEPSILON) { // check whether they're linear dependent
+  //        Log() << Verbose(3) << "Both trajectories of " << *Walker << " and " << *Runner << " are linear dependent: ";
+  //        Log() << Verbose(0) << trajectory1;
+  //        Log() << Verbose(0) << " and ";
+  //        Log() << Verbose(0) << trajectory2;
+      tmp = Walker->Trajectory.R.at(Params.startstep).distance((*iter)->Trajectory.R.at(Params.startstep));
+  //        Log() << Verbose(0) << " with distance " << tmp << "." << endl;
+    } else { // determine distance by finding minimum distance
+  //        Log() << Verbose(3) << "Both trajectories of " << *Walker << " and " << *(*iter) << " are linear independent ";
+  //        Log() << Verbose(0) << endl;
+  //        Log() << Verbose(0) << "First Trajectory: ";
+  //        Log() << Verbose(0) << trajectory1 << endl;
+  //        Log() << Verbose(0) << "Second Trajectory: ";
+  //        Log() << Verbose(0) << trajectory2 << endl;
+      // determine normal vector for both
+      normal = Plane(trajectory1, trajectory2,0).getNormal();
+      // print all vectors for debugging
+  //        Log() << Verbose(0) << "Normal vector in between: ";
+  //        Log() << Verbose(0) << normal << endl;
+      // setup matrix
+      for (int i=NDIM;i--;) {
+        gsl_matrix_set(A, 0, i, trajectory1[i]);
+        gsl_matrix_set(A, 1, i, trajectory2[i]);
+        gsl_matrix_set(A, 2, i, normal[i]);
+        gsl_vector_set(x,i, (Walker->Trajectory.R.at(Params.startstep)[i] - (*iter)->Trajectory.R.at(Params.startstep)[i]));
+      }
+      // solve the linear system by Householder transformations
+      gsl_linalg_HH_svx(A, x);
+      // distance from last component
+      tmp = gsl_vector_get(x,2);
+  //        Log() << Verbose(0) << " with distance " << tmp << "." << endl;
+      // test whether we really have the intersection (by checking on c_1 and c_2)
+      trajectory1.Scale(gsl_vector_get(x,0));
+      trajectory2.Scale(gsl_vector_get(x,1));
+      normal.Scale(gsl_vector_get(x,2));
+      TestVector = (*iter)->Trajectory.R.at(Params.startstep) + trajectory2 + normal
+                   - (Walker->Trajectory.R.at(Params.startstep) + trajectory1);
+      if (TestVector.Norm() < MYEPSILON) {
+  //          Log() << Verbose(2) << "Test: ok.\tDistance of " << tmp << " is correct." << endl;
+      } else {
+  //          Log() << Verbose(2) << "Test: failed.\tIntersection is off by ";
+  //          Log() << Verbose(0) << TestVector;
+  //          Log() << Verbose(0) << "." << endl;
+      }
+    }
+    // add up
+    tmp *= Params.IsAngstroem ? 1. : 1./AtomicLengthToAngstroem;
+    if (fabs(tmp) > MYEPSILON) {
+      result += Params.PenaltyConstants[1] * 1./tmp;
+      //Log() << Verbose(4) << "Adding " << 1./tmp*constants[1] << "." << endl;
+    }
+  }
+  return result;
+};
+
+/** Penalizes atoms heading to same target.
+ * \param *Walker atom to check against others
+ * \param *mol molecule with other atoms
+ * \param &Params constrained potential parameters
+ * \return \a penalty times the number of equal targets
+ */
+double PenalizeEqualTargets(atom *Walker, molecule *mol, struct EvaluatePotential &Params)
+{
+  double result = 0.;
+  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
+    if ((Params.PermutationMap[Walker->nr] == Params.PermutationMap[(*iter)->nr]) && (Walker->nr < (*iter)->nr)) {
+  //    atom *Sprinter = PermutationMap[Walker->nr];
+  //        Log() << Verbose(0) << *Walker << " and " << *(*iter) << " are heading to the same target at ";
+  //        Log() << Verbose(0) << Sprinter->Trajectory.R.at(endstep);
+  //        Log() << Verbose(0) << ", penalting." << endl;
+      result += Params.PenaltyConstants[2];
+      //Log() << Verbose(4) << "Adding " << constants[2] << "." << endl;
+    }
+  }
+  return result;
+};
+
+/** Evaluates the potential energy used for constrained molecular dynamics.
+ * \f$V_i^{con} = c^{bond} \cdot | r_{P(i)} - R_i | + sum_{i \neq j} C^{min} \cdot \frac{1}{C_{ij}} + C^{inj} \Bigl (1 - \theta \bigl (\prod_{i \neq j} (P(i) - P(j)) \bigr ) \Bigr )\f$
+ *     where the first term points to the target in minimum distance, the second is a penalty for trajectories lying too close to each other (\f$C_{ij}\f$ is minimum distance between
+ *     trajectories i and j) and the third term is a penalty for two atoms trying to each the same target point.
+ * Note that for the second term we have to solve the following linear system:
+ * \f$-c_1 \cdot n_1 + c_2 \cdot n_2 + C \cdot n_3 = - p_2 + p_1\f$, where \f$c_1\f$, \f$c_2\f$ and \f$C\f$ are constants,
+ * offset vector \f$p_1\f$ in direction \f$n_1\f$, offset vector \f$p_2\f$ in direction \f$n_2\f$,
+ * \f$n_3\f$ is the normal vector to both directions. \f$C\f$ would be the minimum distance between the two lines.
+ * \sa molecule::MinimiseConstrainedPotential(), molecule::VerletForceIntegration()
+ * \param *out output stream for debugging
+ * \param &Params constrained potential parameters
+ * \return potential energy
+ * \note This routine is scaling quadratically which is not optimal.
+ * \todo There's a bit double counting going on for the first time, bu nothing to worry really about.
+ */
+double molecule::ConstrainedPotential(struct EvaluatePotential &Params)
+{
+  double tmp = 0.;
+  double result = 0.;
+  // go through every atom
+  atom *Runner = NULL;
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    // first term: distance to target
+    Runner = Params.PermutationMap[(*iter)->nr];   // find target point
+    tmp = ((*iter)->Trajectory.R.at(Params.startstep).distance(Runner->Trajectory.R.at(Params.endstep)));
+    tmp *= Params.IsAngstroem ? 1. : 1./AtomicLengthToAngstroem;
+    result += Params.PenaltyConstants[0] * tmp;
+    //Log() << Verbose(4) << "Adding " << tmp*constants[0] << "." << endl;
+
+    // second term: sum of distances to other trajectories
+    result += SumDistanceOfTrajectories((*iter), this, Params);
+
+    // third term: penalty for equal targets
+    result += PenalizeEqualTargets((*iter), this, Params);
+  }
+
+  return result;
+};
+
+/** print the current permutation map.
+ * \param *out output stream for debugging
+ * \param &Params constrained potential parameters
+ * \param AtomCount number of atoms
+ */
+void PrintPermutationMap(int AtomCount, struct EvaluatePotential &Params)
+{
+  stringstream zeile1, zeile2;
+  int *DoubleList = new int[AtomCount];
+  for(int i=0;i<AtomCount;i++)
+    DoubleList[i] = 0;
+  int doubles = 0;
+  zeile1 << "PermutationMap: ";
+  zeile2 << "                ";
+  for (int i=0;i<AtomCount;i++) {
+    Params.DoubleList[Params.PermutationMap[i]->nr]++;
+    zeile1 << i << " ";
+    zeile2 << Params.PermutationMap[i]->nr << " ";
+  }
+  for (int i=0;i<AtomCount;i++)
+    if (Params.DoubleList[i] > 1)
+    doubles++;
+  if (doubles >0)
+    DoLog(2) && (Log() << Verbose(2) << "Found " << doubles << " Doubles." << endl);
+  delete[](DoubleList);
+//  Log() << Verbose(2) << zeile1.str() << endl << zeile2.str() << endl;
+};
+
+/** \f$O(N^2)\f$ operation of calculation distance between each atom pair and putting into DistanceList.
+ * \param *mol molecule to scan distances in
+ * \param &Params constrained potential parameters
+ */
+void FillDistanceList(molecule *mol, struct EvaluatePotential &Params)
+{
+  for (int i=mol->getAtomCount(); i--;) {
+    Params.DistanceList[i] = new DistanceMap;    // is the distance sorted target list per atom
+    Params.DistanceList[i]->clear();
+  }
+
+  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
+    for (molecule::const_iterator runner = mol->begin(); runner != mol->end(); ++runner) {
+      Params.DistanceList[(*iter)->nr]->insert( DistancePair((*iter)->Trajectory.R.at(Params.startstep).distance((*runner)->Trajectory.R.at(Params.endstep)), (*runner)) );
+    }
+  }
+};
+
+/** initialize lists.
+ * \param *out output stream for debugging
+ * \param *mol molecule to scan distances in
+ * \param &Params constrained potential parameters
+ */
+void CreateInitialLists(molecule *mol, struct EvaluatePotential &Params)
+{
+  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
+    Params.StepList[(*iter)->nr] = Params.DistanceList[(*iter)->nr]->begin();    // stores the step to the next iterator that could be a possible next target
+    Params.PermutationMap[(*iter)->nr] = Params.DistanceList[(*iter)->nr]->begin()->second;   // always pick target with the smallest distance
+    Params.DoubleList[Params.DistanceList[(*iter)->nr]->begin()->second->nr]++;            // increase this target's source count (>1? not injective)
+    Params.DistanceIterators[(*iter)->nr] = Params.DistanceList[(*iter)->nr]->begin();    // and remember which one we picked
+    DoLog(2) && (Log() << Verbose(2) << **iter << " starts with distance " << Params.DistanceList[(*iter)->nr]->begin()->first << "." << endl);
+  }
+};
+
+/** Try the next nearest neighbour in order to make the permutation map injective.
+ * \param *out output stream for debugging
+ * \param *mol molecule
+ * \param *Walker atom to change its target
+ * \param &OldPotential old value of constraint potential to see if we do better with new target
+ * \param &Params constrained potential parameters
+ */
+double TryNextNearestNeighbourForInjectivePermutation(molecule *mol, atom *Walker, double &OldPotential, struct EvaluatePotential &Params)
+{
+  double Potential = 0;
+  DistanceMap::iterator NewBase = Params.DistanceIterators[Walker->nr];  // store old base
+  do {
+    NewBase++;  // take next further distance in distance to targets list that's a target of no one
+  } while ((Params.DoubleList[NewBase->second->nr] != 0) && (NewBase != Params.DistanceList[Walker->nr]->end()));
+  if (NewBase != Params.DistanceList[Walker->nr]->end()) {
+    Params.PermutationMap[Walker->nr] = NewBase->second;
+    Potential = fabs(mol->ConstrainedPotential(Params));
+    if (Potential > OldPotential) { // undo
+      Params.PermutationMap[Walker->nr] = Params.DistanceIterators[Walker->nr]->second;
+    } else {  // do
+      Params.DoubleList[Params.DistanceIterators[Walker->nr]->second->nr]--;  // decrease the old entry in the doubles list
+      Params.DoubleList[NewBase->second->nr]++;    // increase the old entry in the doubles list
+      Params.DistanceIterators[Walker->nr] = NewBase;
+      OldPotential = Potential;
+      DoLog(3) && (Log() << Verbose(3) << "Found a new permutation, new potential is " << OldPotential << "." << endl);
+    }
+  }
+  return Potential;
+};
+
+/** Permutes \a **&PermutationMap until the penalty is below constants[2].
+ * \param *out output stream for debugging
+ * \param *mol molecule to scan distances in
+ * \param &Params constrained potential parameters
+ */
+void MakeInjectivePermutation(molecule *mol, struct EvaluatePotential &Params)
+{
+  molecule::const_iterator iter = mol->begin();
+  DistanceMap::iterator NewBase;
+  double Potential = fabs(mol->ConstrainedPotential(Params));
+
+  if (mol->empty()) {
+    eLog() << Verbose(1) << "Molecule is empty." << endl;
+    return;
+  }
+  while ((Potential) > Params.PenaltyConstants[2]) {
+    PrintPermutationMap(mol->getAtomCount(), Params);
+    iter++;
+    if (iter == mol->end()) // round-robin at the end
+      iter = mol->begin();
+    if (Params.DoubleList[Params.DistanceIterators[(*iter)->nr]->second->nr] <= 1)  // no need to make those injective that aren't
+      continue;
+    // now, try finding a new one
+    Potential = TryNextNearestNeighbourForInjectivePermutation(mol, (*iter), Potential, Params);
+  }
+  for (int i=mol->getAtomCount(); i--;) // now each single entry in the DoubleList should be <=1
+    if (Params.DoubleList[i] > 1) {
+      DoeLog(0) && (eLog()<< Verbose(0) << "Failed to create an injective PermutationMap!" << endl);
+      performCriticalExit();
+    }
+  DoLog(1) && (Log() << Verbose(1) << "done." << endl);
+};
+
+/** Minimises the extra potential for constrained molecular dynamics and gives forces and the constrained potential energy.
+ * We do the following:
+ *  -# Generate a distance list from all source to all target points
+ *  -# Sort this per source point
+ *  -# Take for each source point the target point with minimum distance, use this as initial permutation
+ *  -# check whether molecule::ConstrainedPotential() is greater than injective penalty
+ *     -# If so, we go through each source point, stepping down in the sorted target point distance list and re-checking potential.
+ *  -# Next, we only apply transformations that keep the injectivity of the permutations list.
+ *  -# Hence, for one source point we step down the ladder and seek the corresponding owner of this new target
+ *     point and try to change it for one with lesser distance, or for the next one with greater distance, but only
+ *     if this decreases the conditional potential.
+ *  -# finished.
+ *  -# Then, we calculate the forces by taking the spatial derivative, where we scale the potential to such a degree,
+ *     that the total force is always pointing in direction of the constraint force (ensuring that we move in the
+ *     right direction).
+ *  -# Finally, we calculate the potential energy and return.
+ * \param *out output stream for debugging
+ * \param **PermutationMap on return: mapping between the atom label of the initial and the final configuration
+ * \param startstep current MD step giving initial position between which and \a endstep we perform the constrained MD (as further steps are always concatenated)
+ * \param endstep step giving final position in constrained MD
+ * \param IsAngstroem whether coordinates are in angstroem (true) or bohrradius (false)
+ * \sa molecule::VerletForceIntegration()
+ * \return potential energy (and allocated **PermutationMap (array of molecule::AtomCount ^2)
+ * \todo The constrained potential's constants are set to fixed values right now, but they should scale based on checks of the system in order
+ *       to ensure they're properties (e.g. constants[2] always greater than the energy of the system).
+ * \bug this all is not O(N log N) but O(N^2)
+ */
+double molecule::MinimiseConstrainedPotential(atom **&PermutationMap, int startstep, int endstep, bool IsAngstroem)
+{
+  double Potential, OldPotential, OlderPotential;
+  struct EvaluatePotential Params;
+  Params.PermutationMap = new atom *[getAtomCount()];
+  Params.DistanceList = new DistanceMap *[getAtomCount()];
+  Params.DistanceIterators = new DistanceMap::iterator[getAtomCount()];
+  Params.DoubleList = new int[getAtomCount()];
+  Params.StepList = new DistanceMap::iterator[getAtomCount()];
+  int round;
+  atom *Sprinter = NULL;
+  DistanceMap::iterator Rider, Strider;
+
+  // set to zero
+  for (int i=0;i<getAtomCount();i++) {
+    Params.PermutationMap[i] = NULL;
+    Params.DoubleList[i] = 0;
+  }
+
+  /// Minimise the potential
+  // set Lagrange multiplier constants
+  Params.PenaltyConstants[0] = 10.;
+  Params.PenaltyConstants[1] = 1.;
+  Params.PenaltyConstants[2] = 1e+7;    // just a huge penalty
+  // generate the distance list
+  DoLog(1) && (Log() << Verbose(1) << "Allocating, initializting and filling the distance list ... " << endl);
+  FillDistanceList(this, Params);
+
+  // create the initial PermutationMap (source -> target)
+  CreateInitialLists(this, Params);
+
+  // make the PermutationMap injective by checking whether we have a non-zero constants[2] term in it
+  DoLog(1) && (Log() << Verbose(1) << "Making the PermutationMap injective ... " << endl);
+  MakeInjectivePermutation(this, Params);
+  delete[](Params.DoubleList);
+
+  // argument minimise the constrained potential in this injective PermutationMap
+  DoLog(1) && (Log() << Verbose(1) << "Argument minimising the PermutationMap." << endl);
+  OldPotential = 1e+10;
+  round = 0;
+  do {
+    DoLog(2) && (Log() << Verbose(2) << "Starting round " << ++round << ", at current potential " << OldPotential << " ... " << endl);
+    OlderPotential = OldPotential;
+    molecule::const_iterator iter;
+    do {
+      iter = begin();
+      for (; iter != end(); ++iter) {
+        PrintPermutationMap(getAtomCount(), Params);
+        Sprinter = Params.DistanceIterators[(*iter)->nr]->second;   // store initial partner
+        Strider = Params.DistanceIterators[(*iter)->nr];  //remember old iterator
+        Params.DistanceIterators[(*iter)->nr] = Params.StepList[(*iter)->nr];
+        if (Params.DistanceIterators[(*iter)->nr] == Params.DistanceList[(*iter)->nr]->end()) {// stop, before we run through the list and still on
+          Params.DistanceIterators[(*iter)->nr] == Params.DistanceList[(*iter)->nr]->begin();
+          break;
+        }
+        //Log() << Verbose(2) << "Current Walker: " << *(*iter) << " with old/next candidate " << *Sprinter << "/" << *DistanceIterators[(*iter)->nr]->second << "." << endl;
+        // find source of the new target
+        molecule::const_iterator runner = begin();
+        for (; runner != end(); ++runner) { // find the source whose toes we might be stepping on (Walker's new target should be in use by another already)
+          if (Params.PermutationMap[(*runner)->nr] == Params.DistanceIterators[(*iter)->nr]->second) {
+            //Log() << Verbose(2) << "Found the corresponding owner " << *(*runner) << " to " << *PermutationMap[(*runner)->nr] << "." << endl;
+            break;
+          }
+        }
+        if (runner != end()) { // we found the other source
+          // then look in its distance list for Sprinter
+          Rider = Params.DistanceList[(*runner)->nr]->begin();
+          for (; Rider != Params.DistanceList[(*runner)->nr]->end(); Rider++)
+            if (Rider->second == Sprinter)
+              break;
+          if (Rider != Params.DistanceList[(*runner)->nr]->end()) { // if we have found one
+            //Log() << Verbose(2) << "Current Other: " << *(*runner) << " with old/next candidate " << *PermutationMap[(*runner)->nr] << "/" << *Rider->second << "." << endl;
+            // exchange both
+            Params.PermutationMap[(*iter)->nr] = Params.DistanceIterators[(*iter)->nr]->second; // put next farther distance into PermutationMap
+            Params.PermutationMap[(*runner)->nr] = Sprinter;  // and hand the old target to its respective owner
+            PrintPermutationMap(getAtomCount(), Params);
+            // calculate the new potential
+            //Log() << Verbose(2) << "Checking new potential ..." << endl;
+            Potential = ConstrainedPotential(Params);
+            if (Potential > OldPotential) { // we made everything worse! Undo ...
+              //Log() << Verbose(3) << "Nay, made the potential worse: " << Potential << " vs. " << OldPotential << "!" << endl;
+              //Log() << Verbose(3) << "Setting " << *(*runner) << "'s source to " << *Params.DistanceIterators[(*runner)->nr]->second << "." << endl;
+              // Undo for Runner (note, we haven't moved the iteration yet, we may use this)
+              Params.PermutationMap[(*runner)->nr] = Params.DistanceIterators[(*runner)->nr]->second;
+              // Undo for Walker
+              Params.DistanceIterators[(*iter)->nr] = Strider;  // take next farther distance target
+              //Log() << Verbose(3) << "Setting " << *(*iter) << "'s source to " << *Params.DistanceIterators[(*iter)->nr]->second << "." << endl;
+              Params.PermutationMap[(*iter)->nr] = Params.DistanceIterators[(*iter)->nr]->second;
+            } else {
+              Params.DistanceIterators[(*runner)->nr] = Rider;  // if successful also move the pointer in the iterator list
+              DoLog(3) && (Log() << Verbose(3) << "Found a better permutation, new potential is " << Potential << " vs." << OldPotential << "." << endl);
+              OldPotential = Potential;
+            }
+            if (Potential > Params.PenaltyConstants[2]) {
+              DoeLog(1) && (eLog()<< Verbose(1) << "The two-step permutation procedure did not maintain injectivity!" << endl);
+              exit(255);
+            }
+            //Log() << Verbose(0) << endl;
+          } else {
+            DoeLog(1) && (eLog()<< Verbose(1) << **runner << " was not the owner of " << *Sprinter << "!" << endl);
+            exit(255);
+          }
+        } else {
+          Params.PermutationMap[(*iter)->nr] = Params.DistanceIterators[(*iter)->nr]->second; // new target has no source!
+        }
+        Params.StepList[(*iter)->nr]++; // take next farther distance target
+      }
+    } while (++iter != end());
+  } while ((OlderPotential - OldPotential) > 1e-3);
+  DoLog(1) && (Log() << Verbose(1) << "done." << endl);
+
+
+  /// free memory and return with evaluated potential
+  for (int i=getAtomCount(); i--;)
+    Params.DistanceList[i]->clear();
+  delete[](Params.DistanceList);
+  delete[](Params.DistanceIterators);
+  return ConstrainedPotential(Params);
+};
+
+
+/** Evaluates the (distance-related part) of the constrained potential for the constrained forces.
+ * \param *out output stream for debugging
+ * \param startstep current MD step giving initial position between which and \a endstep we perform the constrained MD (as further steps are always concatenated)
+ * \param endstep step giving final position in constrained MD
+ * \param **PermutationMap mapping between the atom label of the initial and the final configuration
+ * \param *Force ForceMatrix containing force vectors from the external energy functional minimisation.
+ * \todo the constant for the constrained potential distance part is hard-coded independently of the hard-coded value in MinimiseConstrainedPotential()
+ */
+void molecule::EvaluateConstrainedForces(int startstep, int endstep, atom **PermutationMap, ForceMatrix *Force)
+{
+  /// evaluate forces (only the distance to target dependent part) with the final PermutationMap
+  DoLog(1) && (Log() << Verbose(1) << "Calculating forces and adding onto ForceMatrix ... " << endl);
+  ActOnAllAtoms( &atom::EvaluateConstrainedForce, startstep, endstep, PermutationMap, Force );
+  DoLog(1) && (Log() << Verbose(1) << "done." << endl);
+};
+
+/** Performs a linear interpolation between two desired atomic configurations with a given number of steps.
+ * Note, step number is config::MaxOuterStep
+ * \param *out output stream for debugging
+ * \param startstep stating initial configuration in molecule::Trajectories
+ * \param endstep stating final configuration in molecule::Trajectories
+ * \param &prefix path and prefix
+ * \param &config configuration structure
+ * \param MapByIdentity if true we just use the identity to map atoms in start config to end config, if not we find mapping by \sa MinimiseConstrainedPotential()
+ * \return true - success in writing step files, false - error writing files or only one step in molecule::Trajectories
+ */
+bool molecule::LinearInterpolationBetweenConfiguration(int startstep, int endstep, std::string &prefix, config &configuration, bool MapByIdentity)
+{
+  molecule *mol = NULL;
+  bool status = true;
+  int MaxSteps = configuration.MaxOuterStep;
+  MoleculeListClass *MoleculePerStep = new MoleculeListClass(World::getPointer());
+  // Get the Permutation Map by MinimiseConstrainedPotential
+  atom **PermutationMap = NULL;
+  atom *Sprinter = NULL;
+  if (!MapByIdentity)
+    MinimiseConstrainedPotential(PermutationMap, startstep, endstep, configuration.GetIsAngstroem());
+  else {
+    PermutationMap = new atom *[getAtomCount()];
+    SetIndexedArrayForEachAtomTo( PermutationMap, &atom::nr );
+  }
+
+  // check whether we have sufficient space in Trajectories for each atom
+  ActOnAllAtoms( &atom::ResizeTrajectory, MaxSteps );
+  // push endstep to last one
+  ActOnAllAtoms( &atom::CopyStepOnStep, MaxSteps, endstep );
+  endstep = MaxSteps;
+
+  // go through all steps and add the molecular configuration to the list and to the Trajectories of \a this molecule
+  DoLog(1) && (Log() << Verbose(1) << "Filling intermediate " << MaxSteps << " steps with MDSteps of " << MDSteps << "." << endl);
+  for (int step = 0; step <= MaxSteps; step++) {
+    mol = World::getInstance().createMolecule();
+    MoleculePerStep->insert(mol);
+    for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+      // add to molecule list
+      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);
+        // add to Trajectories
+        //Log() << Verbose(3) << step << ">=" << MDSteps-1 << endl;
+        if (step < MaxSteps) {
+          (*iter)->Trajectory.R.at(step)[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);
+          (*iter)->Trajectory.U.at(step)[n] = 0.;
+          (*iter)->Trajectory.F.at(step)[n] = 0.;
+        }
+      }
+    }
+  }
+  MDSteps = MaxSteps+1;   // otherwise new Trajectories' points aren't stored on save&exit
+
+  // store the list to single step files
+  int *SortIndex = new int[getAtomCount()];
+  for (int i=getAtomCount(); i--; )
+    SortIndex[i] = i;
+
+  status = MoleculePerStep->OutputConfigForListOfFragments(prefix, SortIndex);
+  delete[](SortIndex);
+
+  // free and return
+  delete[](PermutationMap);
+  delete(MoleculePerStep);
+  return status;
+};
+
+/** Parses nuclear forces from file and performs Verlet integration.
+ * Note that we assume the parsed forces to be in atomic units (hence, if coordinates are in angstroem, we
+ * have to transform them).
+ * This adds a new MD step to the config file.
+ * \param *file filename
+ * \param config structure with config::Deltat, config::IsAngstroem, config::DoConstrained
+ * \param offset offset in matrix file to the first force component
+ * \return true - file found and parsed, false - file not found or imparsable
+ * \todo This is not yet checked if it is correctly working with DoConstrained set to true.
+ */
+bool molecule::VerletForceIntegration(char *file, config &configuration, const size_t offset)
+{
+  Info FunctionInfo(__func__);
+  ifstream input(file);
+  string token;
+  stringstream item;
+  double IonMass, ConstrainedPotentialEnergy, ActualTemp;
+  Vector Velocity;
+  ForceMatrix Force;
+
+  CountElements();  // make sure ElementsInMolecule is up to date
+
+  const int AtomCount = getAtomCount();
+  // check file
+  if (input == NULL) {
+    return false;
+  } else {
+    // parse file into ForceMatrix
+    if (!Force.ParseMatrix(file, 0,0,0)) {
+      DoeLog(0) && (eLog()<< Verbose(0) << "Could not parse Force Matrix file " << file << "." << endl);
+      performCriticalExit();
+      return false;
+    }
+    if (Force.RowCounter[0] != AtomCount) {
+      DoeLog(0) && (eLog()<< Verbose(0) << "Mismatch between number of atoms in file " << Force.RowCounter[0] << " and in molecule " << getAtomCount() << "." << endl);
+      performCriticalExit();
+      return false;
+    }
+    // correct Forces
+    Velocity.Zero();
+    for(int i=0;i<AtomCount;i++)
+      for(int d=0;d<NDIM;d++) {
+        Velocity[d] += Force.Matrix[0][i][d+offset];
+      }
+    for(int i=0;i<AtomCount;i++)
+      for(int d=0;d<NDIM;d++) {
+        Force.Matrix[0][i][d+offset] -= Velocity[d]/static_cast<double>(AtomCount);
+      }
+    // solve a constrained potential if we are meant to
+    if (configuration.DoConstrainedMD) {
+      // calculate forces and potential
+      atom **PermutationMap = NULL;
+      ConstrainedPotentialEnergy = MinimiseConstrainedPotential(PermutationMap,configuration.DoConstrainedMD, 0, configuration.GetIsAngstroem());
+      EvaluateConstrainedForces(configuration.DoConstrainedMD, 0, PermutationMap, &Force);
+      delete[](PermutationMap);
+    }
+
+    // and perform Verlet integration for each atom with position, velocity and force vector
+    // check size of vectors
+    //ActOnAllAtoms( &atom::ResizeTrajectory, MDSteps+10 );
+
+    ActOnAllAtoms( &atom::VelocityVerletUpdate, MDSteps+1, &configuration, &Force, (const size_t) 0);
+  }
+  // correct velocities (rather momenta) so that center of mass remains motionless
+  Velocity.Zero();
+  IonMass = 0.;
+  ActOnAllAtoms ( &atom::SumUpKineticEnergy, MDSteps+1, &IonMass, &Velocity );
+
+  // correct velocities (rather momenta) so that center of mass remains motionless
+  Velocity.Scale(1./IonMass);
+  ActualTemp = 0.;
+  ActOnAllAtoms ( &atom::CorrectVelocity, &ActualTemp, MDSteps+1, &Velocity );
+  Thermostats(configuration, ActualTemp, Berendsen);
+  MDSteps++;
+
+  // exit
+  return true;
+};
+
+/** Implementation of various thermostats.
+ * All these thermostats apply an additional force which has the following forms:
+ * -# Woodcock
+ *  \f$p_i \rightarrow \sqrt{\frac{T_0}{T}} \cdot p_i\f$
+ * -# Gaussian
+ *  \f$ \frac{ \sum_i \frac{p_i}{m_i} \frac{\partial V}{\partial q_i}} {\sum_i \frac{p^2_i}{m_i}} \cdot p_i\f$
+ * -# Langevin
+ *  \f$p_{i,n} \rightarrow \sqrt{1-\alpha^2} p_{i,0} + \alpha p_r\f$
+ * -# Berendsen
+ *  \f$p_i \rightarrow \left [ 1+ \frac{\delta t}{\tau_T} \left ( \frac{T_0}{T} \right ) \right ]^{\frac{1}{2}} \cdot p_i\f$
+ * -# Nose-Hoover
+ *  \f$\zeta p_i \f$ with \f$\frac{\partial \zeta}{\partial t} = \frac{1}{M_s} \left ( \sum^N_{i=1} \frac{p_i^2}{m_i} - g k_B T \right )\f$
+ * These Thermostats either simply rescale the velocities, thus this function should be called after ion velocities have been updated, and/or
+ * have a constraint force acting additionally on the ions. In the latter case, the ion speeds have to be modified
+ * belatedly and the constraint force set.
+ * \param *P Problem at hand
+ * \param i which of the thermostats to take: 0 - none, 1 - Woodcock, 2 - Gaussian, 3 - Langevin, 4 - Berendsen, 5 - Nose-Hoover
+ * \sa InitThermostat()
+ */
+void molecule::Thermostats(config &configuration, double ActualTemp, int Thermostat)
+{
+  double ekin = 0.;
+  double E = 0., G = 0.;
+  double delta_alpha = 0.;
+  double ScaleTempFactor;
+  gsl_rng * r;
+  const gsl_rng_type * T;
+
+  // calculate scale configuration
+  ScaleTempFactor = configuration.Thermostats->TargetTemp/ActualTemp;
+
+  // differentating between the various thermostats
+  switch(Thermostat) {
+     case None:
+      DoLog(2) && (Log() << Verbose(2) <<  "Applying no thermostat..." << endl);
+      break;
+     case Woodcock:
+      if ((configuration.Thermostats->ScaleTempStep > 0) && ((MDSteps-1) % configuration.Thermostats->ScaleTempStep == 0)) {
+        DoLog(2) && (Log() << Verbose(2) <<  "Applying Woodcock thermostat..." << endl);
+        ActOnAllAtoms( &atom::Thermostat_Woodcock, sqrt(ScaleTempFactor), MDSteps, &ekin );
+      }
+      break;
+     case Gaussian:
+      DoLog(2) && (Log() << Verbose(2) <<  "Applying Gaussian thermostat..." << endl);
+      ActOnAllAtoms( &atom::Thermostat_Gaussian_init, MDSteps, &G, &E );
+
+      DoLog(1) && (Log() << Verbose(1) << "Gaussian Least Constraint constant is " << G/E << "." << endl);
+      ActOnAllAtoms( &atom::Thermostat_Gaussian_least_constraint, MDSteps, G/E, &ekin, &configuration);
+
+      break;
+     case Langevin:
+      DoLog(2) && (Log() << Verbose(2) <<  "Applying Langevin thermostat..." << endl);
+      // init random number generator
+      gsl_rng_env_setup();
+      T = gsl_rng_default;
+      r = gsl_rng_alloc (T);
+      // Go through each ion
+      ActOnAllAtoms( &atom::Thermostat_Langevin, MDSteps, r, &ekin, &configuration );
+      break;
+
+     case Berendsen:
+      DoLog(2) && (Log() << Verbose(2) <<  "Applying Berendsen-VanGunsteren thermostat..." << endl);
+      ActOnAllAtoms( &atom::Thermostat_Berendsen, MDSteps, ScaleTempFactor, &ekin, &configuration );
+      break;
+
+     case NoseHoover:
+      DoLog(2) && (Log() << Verbose(2) <<  "Applying Nose-Hoover thermostat..." << endl);
+      // dynamically evolve alpha (the additional degree of freedom)
+      delta_alpha = 0.;
+      ActOnAllAtoms( &atom::Thermostat_NoseHoover_init, MDSteps, &delta_alpha );
+      delta_alpha = (delta_alpha - (3.*getAtomCount()+1.) * configuration.Thermostats->TargetTemp)/(configuration.Thermostats->HooverMass*Units2Electronmass);
+      configuration.Thermostats->alpha += delta_alpha*configuration.Deltat;
+      DoLog(3) && (Log() << Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration.Thermostats->alpha << "." << endl);
+      // apply updated alpha as additional force
+      ActOnAllAtoms( &atom::Thermostat_NoseHoover_scale, MDSteps, &ekin, &configuration );
+      break;
+  }
+  DoLog(1) && (Log() << Verbose(1) << "Kinetic energy is " << ekin << "." << endl);
+};
Index: src/molecule_fragmentation.cpp
===================================================================
--- src/molecule_fragmentation.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/molecule_fragmentation.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,1792 @@
+/*
+ * molecule_fragmentation.cpp
+ *
+ *  Created on: Oct 5, 2009
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include <cstring>
+
+#include "World.hpp"
+#include "atom.hpp"
+#include "bond.hpp"
+#include "config.hpp"
+#include "element.hpp"
+#include "helpers.hpp"
+#include "lists.hpp"
+#include "log.hpp"
+#include "memoryallocator.hpp"
+#include "molecule.hpp"
+#include "periodentafel.hpp"
+#include "World.hpp"
+
+/************************************* Functions for class molecule *********************************/
+
+
+/** Estimates by educated guessing (using upper limit) the expected number of fragments.
+ * The upper limit is
+ * \f[
+ *  n = N \cdot C^k
+ * \f]
+ * where \f$C=2^c\f$ and c is the maximum bond degree over N number of atoms.
+ * \param *out output stream for debugging
+ * \param order bond order k
+ * \return number n of fragments
+ */
+int molecule::GuesstimateFragmentCount(int order)
+{
+  size_t c = 0;
+  int FragmentCount;
+  // get maximum bond degree
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    c = ((*iter)->ListOfBonds.size() > c) ? (*iter)->ListOfBonds.size() : c;
+  }
+  FragmentCount = NoNonHydrogen*(1 << (c*order));
+  DoLog(1) && (Log() << Verbose(1) << "Upper limit for this subgraph is " << FragmentCount << " for " << NoNonHydrogen << " non-H atoms with maximum bond degree of " << c << "." << endl);
+  return FragmentCount;
+};
+
+/** Scans a single line for number and puts them into \a KeySet.
+ * \param *out output stream for debugging
+ * \param *buffer buffer to scan
+ * \param &CurrentSet filled KeySet on return
+ * \return true - at least one valid atom id parsed, false - CurrentSet is empty
+ */
+bool ScanBufferIntoKeySet(char *buffer, KeySet &CurrentSet)
+{
+  stringstream line;
+  int AtomNr;
+  int status = 0;
+
+  line.str(buffer);
+  while (!line.eof()) {
+    line >> AtomNr;
+    if (AtomNr >= 0) {
+      CurrentSet.insert(AtomNr);  // insert at end, hence in same order as in file!
+      status++;
+    } // else it's "-1" or else and thus must not be added
+  }
+  DoLog(1) && (Log() << Verbose(1) << "The scanned KeySet is ");
+  for(KeySet::iterator runner = CurrentSet.begin(); runner != CurrentSet.end(); runner++) {
+    DoLog(0) && (Log() << Verbose(0) << (*runner) << "\t");
+  }
+  DoLog(0) && (Log() << Verbose(0) << endl);
+  return (status != 0);
+};
+
+/** Parses the KeySet file and fills \a *FragmentList from the known molecule structure.
+ * Does two-pass scanning:
+ * -# Scans the keyset file and initialises a temporary graph
+ * -# Scans TEFactors file and sets the TEFactor of each key set in the temporary graph accordingly
+ * Finally, the temporary graph is inserted into the given \a FragmentList for return.
+ * \param &path path to file
+ * \param *FragmentList empty, filled on return
+ * \return true - parsing successfully, false - failure on parsing (FragmentList will be NULL)
+ */
+bool ParseKeySetFile(std::string &path, Graph *&FragmentList)
+{
+  bool status = true;
+  ifstream InputFile;
+  stringstream line;
+  GraphTestPair testGraphInsert;
+  int NumberOfFragments = 0;
+  string filename;
+
+  if (FragmentList == NULL) { // check list pointer
+    FragmentList = new Graph;
+  }
+
+  // 1st pass: open file and read
+  DoLog(1) && (Log() << Verbose(1) << "Parsing the KeySet file ... " << endl);
+  filename = path + KEYSETFILE;
+  InputFile.open(filename.c_str());
+  if (InputFile.good()) {
+    // each line represents a new fragment
+    char buffer[MAXSTRINGSIZE];
+    // 1. parse keysets and insert into temp. graph
+    while (!InputFile.eof()) {
+      InputFile.getline(buffer, MAXSTRINGSIZE);
+      KeySet CurrentSet;
+      if ((strlen(buffer) > 0) && (ScanBufferIntoKeySet(buffer, CurrentSet))) {  // if at least one valid atom was added, write config
+        testGraphInsert = FragmentList->insert(GraphPair (CurrentSet,pair<int,double>(NumberOfFragments++,1)));  // store fragment number and current factor
+        if (!testGraphInsert.second) {
+          DoeLog(0) && (eLog()<< Verbose(0) << "KeySet file must be corrupt as there are two equal key sets therein!" << endl);
+          performCriticalExit();
+        }
+      }
+    }
+    // 2. Free and done
+    InputFile.close();
+    InputFile.clear();
+    DoLog(1) && (Log() << Verbose(1) << "\t ... done." << endl);
+  } else {
+    DoLog(1) && (Log() << Verbose(1) << "\t ... File " << filename << " not found." << endl);
+    status = false;
+  }
+
+  return status;
+};
+
+/** Parses the TE factors file and fills \a *FragmentList from the known molecule structure.
+ * -# Scans TEFactors file and sets the TEFactor of each key set in the temporary graph accordingly
+ * \param *out output stream for debugging
+ * \param *path path to file
+ * \param *FragmentList graph whose nodes's TE factors are set on return
+ * \return true - parsing successfully, false - failure on parsing
+ */
+bool ParseTEFactorsFile(char *path, Graph *FragmentList)
+{
+  bool status = true;
+  ifstream InputFile;
+  stringstream line;
+  GraphTestPair testGraphInsert;
+  int NumberOfFragments = 0;
+  double TEFactor;
+  char filename[MAXSTRINGSIZE];
+
+  if (FragmentList == NULL) { // check list pointer
+    FragmentList = new Graph;
+  }
+
+  // 2nd pass: open TEFactors file and read
+  DoLog(1) && (Log() << Verbose(1) << "Parsing the TEFactors file ... " << endl);
+  sprintf(filename, "%s/%s%s", path, FRAGMENTPREFIX, TEFACTORSFILE);
+  InputFile.open(filename);
+  if (InputFile != NULL) {
+    // 3. add found TEFactors to each keyset
+    NumberOfFragments = 0;
+    for(Graph::iterator runner = FragmentList->begin();runner != FragmentList->end(); runner++) {
+      if (!InputFile.eof()) {
+        InputFile >> TEFactor;
+        (*runner).second.second = TEFactor;
+        DoLog(2) && (Log() << Verbose(2) << "Setting " << ++NumberOfFragments << " fragment's TEFactor to " << (*runner).second.second << "." << endl);
+      } else {
+        status = false;
+        break;
+      }
+    }
+    // 4. Free and done
+    InputFile.close();
+    DoLog(1) && (Log() << Verbose(1) << "done." << endl);
+  } else {
+    DoLog(1) && (Log() << Verbose(1) << "File " << filename << " not found." << endl);
+    status = false;
+  }
+
+  return status;
+};
+
+/** Stores key sets to file.
+ * \param KeySetList Graph with Keysets
+ * \param &path path to file
+ * \return true - file written successfully, false - writing failed
+ */
+bool StoreKeySetFile(Graph &KeySetList, std::string &path)
+{
+  bool status =  true;
+  string line = path + KEYSETFILE;
+  ofstream output(line.c_str());
+
+  // open KeySet file
+  DoLog(1) && (Log() << Verbose(1) << "Saving key sets of the total graph ... ");
+  if(output.good()) {
+    for(Graph::iterator runner = KeySetList.begin(); runner != KeySetList.end(); runner++) {
+      for (KeySet::iterator sprinter = (*runner).first.begin();sprinter != (*runner).first.end(); sprinter++) {
+        if (sprinter != (*runner).first.begin())
+          output << "\t";
+        output << *sprinter;
+      }
+      output << endl;
+    }
+    DoLog(0) && (Log() << Verbose(0) << "done." << endl);
+  } else {
+    DoeLog(0) && (eLog()<< Verbose(0) << "Unable to open " << line << " for writing keysets!" << endl);
+    performCriticalExit();
+    status = false;
+  }
+  output.close();
+  output.clear();
+
+  return status;
+};
+
+
+/** Stores TEFactors to file.
+ * \param *out output stream for debugging
+ * \param KeySetList Graph with factors
+ * \param *path path to file
+ * \return true - file written successfully, false - writing failed
+ */
+bool StoreTEFactorsFile(Graph &KeySetList, char *path)
+{
+  ofstream output;
+  bool status =  true;
+  string line;
+
+  // open TEFactors file
+  line = path;
+  line.append("/");
+  line += FRAGMENTPREFIX;
+  line += TEFACTORSFILE;
+  output.open(line.c_str(), ios::out);
+  DoLog(1) && (Log() << Verbose(1) << "Saving TEFactors of the total graph ... ");
+  if(output != NULL) {
+    for(Graph::iterator runner = KeySetList.begin(); runner != KeySetList.end(); runner++)
+      output << (*runner).second.second << endl;
+    DoLog(1) && (Log() << Verbose(1) << "done." << endl);
+  } else {
+    DoLog(1) && (Log() << Verbose(1) << "failed to open " << line << "." << endl);
+    status = false;
+  }
+  output.close();
+
+  return status;
+};
+
+/** For a given graph, sorts KeySets into a (index, keyset) map.
+ * \param *GlobalKeySetList list of keysets with global ids (valid in "this" molecule) needed for adaptive increase
+ * \return map from index to keyset
+ */
+map<int,KeySet> * GraphToIndexedKeySet(Graph *GlobalKeySetList)
+{
+  map<int,KeySet> *IndexKeySetList = new map<int,KeySet>;
+  for(Graph::iterator runner = GlobalKeySetList->begin(); runner != GlobalKeySetList->end(); runner++) {
+    IndexKeySetList->insert( pair<int,KeySet>(runner->second.first,runner->first) );
+  }
+  return IndexKeySetList;
+};
+
+/** Inserts a (\a No, \a value) pair into the list, overwriting present one.
+ * Note if values are equal, No will decided on which is first
+ * \param *out output stream for debugging
+ * \param &AdaptiveCriteriaList list to insert into
+ * \param &IndexedKeySetList list to find key set for a given index \a No
+ * \param FragOrder current bond order of fragment
+ * \param No index of keyset
+ * \param value energy value
+ */
+void InsertIntoAdaptiveCriteriaList(map<int, pair<double,int> > *AdaptiveCriteriaList, map<int,KeySet> &IndexKeySetList, int FragOrder, int No, double Value)
+{
+  map<int,KeySet>::iterator marker = IndexKeySetList.find(No);    // find keyset to Frag No.
+  if (marker != IndexKeySetList.end()) {  // if found
+    Value *= 1 + MYEPSILON*(*((*marker).second.begin()));     // in case of equal energies this makes them not equal without changing anything actually
+    // as the smallest number in each set has always been the root (we use global id to keep the doubles away), seek smallest and insert into AtomMask
+    pair <map<int, pair<double,int> >::iterator, bool> InsertedElement = AdaptiveCriteriaList->insert( make_pair(*((*marker).second.begin()), pair<double,int>( fabs(Value), FragOrder) ));
+    map<int, pair<double,int> >::iterator PresentItem = InsertedElement.first;
+    if (!InsertedElement.second) { // this root is already present
+      if ((*PresentItem).second.second < FragOrder)  // if order there is lower, update entry with higher-order term
+        //if ((*PresentItem).second.first < (*runner).first)    // as higher-order terms are not always better, we skip this part (which would always include this site into adaptive increase)
+        {  // if value is smaller, update value and order
+        (*PresentItem).second.first = fabs(Value);
+        (*PresentItem).second.second = FragOrder;
+        DoLog(2) && (Log() << Verbose(2) << "Updated element (" <<  (*PresentItem).first << ",[" << (*PresentItem).second.first << "," << (*PresentItem).second.second << "])." << endl);
+      } else {
+        DoLog(2) && (Log() << Verbose(2) << "Did not update element " <<  (*PresentItem).first << " as " << FragOrder << " is less than or equal to " << (*PresentItem).second.second << "." << endl);
+      }
+    } else {
+      DoLog(2) && (Log() << Verbose(2) << "Inserted element (" <<  (*PresentItem).first << ",[" << (*PresentItem).second.first << "," << (*PresentItem).second.second << "])." << endl);
+    }
+  } else {
+    DoLog(1) && (Log() << Verbose(1) << "No Fragment under No. " << No << "found." << endl);
+  }
+};
+
+/** Scans the adaptive order file and insert (index, value) into map.
+ * \param &path path to ENERGYPERFRAGMENT file (may be NULL if Order is non-negative)
+ * \param &IndexedKeySetList list to find key set for a given index \a No
+ * \return adaptive criteria list from file
+ */
+map<int, pair<double,int> > * ScanAdaptiveFileIntoMap(std::string &path, map<int,KeySet> &IndexKeySetList)
+{
+  map<int, pair<double,int> > *AdaptiveCriteriaList = new map<int, pair<double,int> >;
+  int No = 0, FragOrder = 0;
+  double Value = 0.;
+  char buffer[MAXSTRINGSIZE];
+  string filename = path + ENERGYPERFRAGMENT;
+  ifstream InputFile(filename.c_str());
+
+  if (InputFile.fail()) {
+    DoeLog(1) && (eLog() << Verbose(1) << "Cannot find file " << filename << "." << endl);
+    return AdaptiveCriteriaList;
+  }
+
+  if (CountLinesinFile(InputFile) > 0) {
+    // each line represents a fragment root (Atom::nr) id and its energy contribution
+    InputFile.getline(buffer, MAXSTRINGSIZE); // skip comment lines
+    InputFile.getline(buffer, MAXSTRINGSIZE);
+    while(!InputFile.eof()) {
+      InputFile.getline(buffer, MAXSTRINGSIZE);
+      if (strlen(buffer) > 2) {
+        //Log() << Verbose(2) << "Scanning: " << buffer << endl;
+        stringstream line(buffer);
+        line >> FragOrder;
+        line >> ws >> No;
+        line >> ws >> Value; // skip time entry
+        line >> ws >> Value;
+        No -= 1;  // indices start at 1 in file, not 0
+        //Log() << Verbose(2) << " - yields (" << No << "," << Value << ", " << FragOrder << ")" << endl;
+
+        // clean the list of those entries that have been superceded by higher order terms already
+        InsertIntoAdaptiveCriteriaList(AdaptiveCriteriaList, IndexKeySetList, FragOrder, No, Value);
+      }
+    }
+    // close and done
+    InputFile.close();
+    InputFile.clear();
+  }
+
+  return AdaptiveCriteriaList;
+};
+
+/** Maps adaptive criteria list back onto (Value, (Root Nr., Order))
+ * (i.e. sorted by value to pick the highest ones)
+ * \param *out output stream for debugging
+ * \param &AdaptiveCriteriaList list to insert into
+ * \param *mol molecule with atoms
+ * \return remapped list
+ */
+map<double, pair<int,int> >  * ReMapAdaptiveCriteriaListToValue(map<int, pair<double,int> > *AdaptiveCriteriaList, molecule *mol)
+{
+  atom *Walker = NULL;
+  map<double, pair<int,int> > *FinalRootCandidates = new map<double, pair<int,int> > ;
+  DoLog(1) && (Log() << Verbose(1) << "Root candidate list is: " << endl);
+  for(map<int, pair<double,int> >::iterator runner = AdaptiveCriteriaList->begin(); runner != AdaptiveCriteriaList->end(); runner++) {
+    Walker = mol->FindAtom((*runner).first);
+    if (Walker != NULL) {
+      //if ((*runner).second.second >= Walker->AdaptiveOrder) { // only insert if this is an "active" root site for the current order
+      if (!Walker->MaxOrder) {
+        DoLog(2) && (Log() << Verbose(2) << "(" << (*runner).first << ",[" << (*runner).second.first << "," << (*runner).second.second << "])" << endl);
+        FinalRootCandidates->insert( make_pair( (*runner).second.first, pair<int,int>((*runner).first, (*runner).second.second) ) );
+      } else {
+        DoLog(2) && (Log() << Verbose(2) << "Excluding (" << *Walker << ", " << (*runner).first << ",[" << (*runner).second.first << "," << (*runner).second.second << "]), as it has reached its maximum order." << endl);
+      }
+    } else {
+      DoeLog(0) && (eLog()<< Verbose(0) << "Atom No. " << (*runner).second.first << " was not found in this molecule." << endl);
+      performCriticalExit();
+    }
+  }
+  return FinalRootCandidates;
+};
+
+/** Marks all candidate sites for update if below adaptive threshold.
+ * Picks a given number of highest values and set *AtomMask to true.
+ * \param *out output stream for debugging
+ * \param *AtomMask defines true/false per global Atom::nr to mask in/out each nuclear site, used to activate given number of site to increment order adaptively
+ * \param FinalRootCandidates list candidates to check
+ * \param Order desired order
+ * \param *mol molecule with atoms
+ * \return true - if update is necessary, false - not
+ */
+bool MarkUpdateCandidates(bool *AtomMask, map<double, pair<int,int> > &FinalRootCandidates, int Order, molecule *mol)
+{
+  atom *Walker = NULL;
+  int No = -1;
+  bool status = false;
+  for(map<double, pair<int,int> >::iterator runner = FinalRootCandidates.upper_bound(pow(10.,Order)); runner != FinalRootCandidates.end(); runner++) {
+    No = (*runner).second.first;
+    Walker = mol->FindAtom(No);
+    //if (Walker->AdaptiveOrder < MinimumRingSize[Walker->nr]) {
+      DoLog(2) && (Log() << Verbose(2) << "Root " << No << " is still above threshold (10^{" << Order <<"}: " << runner->first << ", setting entry " << No << " of Atom mask to true." << endl);
+      AtomMask[No] = true;
+      status = true;
+    //} else
+      //Log() << Verbose(2) << "Root " << No << " is still above threshold (10^{" << Order <<"}: " << runner->first << ", however MinimumRingSize of " << MinimumRingSize[Walker->nr] << " does not allow further adaptive increase." << endl;
+  }
+  return status;
+};
+
+/** print atom mask for debugging.
+ * \param *out output stream for debugging
+ * \param *AtomMask defines true/false per global Atom::nr to mask in/out each nuclear site, used to activate given number of site to increment order adaptively
+ * \param AtomCount number of entries in \a *AtomMask
+ */
+void PrintAtomMask(bool *AtomMask, int AtomCount)
+{
+  DoLog(2) && (Log() << Verbose(2) << "              ");
+  for(int i=0;i<AtomCount;i++)
+    DoLog(0) && (Log() << Verbose(0) << (i % 10));
+  DoLog(0) && (Log() << Verbose(0) << endl);
+  DoLog(2) && (Log() << Verbose(2) << "Atom mask is: ");
+  for(int i=0;i<AtomCount;i++)
+    DoLog(0) && (Log() << Verbose(0) << (AtomMask[i] ? "t" : "f"));
+  DoLog(0) && (Log() << Verbose(0) << endl);
+};
+
+/** Checks whether the OrderAtSite is still below \a Order at some site.
+ * \param *AtomMask defines true/false per global Atom::nr to mask in/out each nuclear site, used to activate given number of site to increment order adaptively
+ * \param *GlobalKeySetList list of keysets with global ids (valid in "this" molecule) needed for adaptive increase
+ * \param Order desired Order if positive, desired exponent in threshold criteria if negative (0 is single-step)
+ * \param *MinimumRingSize array of max. possible order to avoid loops
+ * \param path path to ENERGYPERFRAGMENT file (may be NULL if Order is non-negative)
+ * \return true - needs further fragmentation, false - does not need fragmentation
+ */
+bool molecule::CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, std::string path)
+{
+  bool status = false;
+
+  // initialize mask list
+  for(int i=getAtomCount();i--;)
+    AtomMask[i] = false;
+
+  if (Order < 0) { // adaptive increase of BondOrder per site
+    if (AtomMask[getAtomCount()] == true)  // break after one step
+      return false;
+
+    // transmorph graph keyset list into indexed KeySetList
+    if (GlobalKeySetList == NULL) {
+      DoeLog(1) && (eLog()<< Verbose(1) << "Given global key set list (graph) is NULL!" << endl);
+      return false;
+    }
+    map<int,KeySet> *IndexKeySetList = GraphToIndexedKeySet(GlobalKeySetList);
+
+    // parse the EnergyPerFragment file
+    map<int, pair<double,int> > *AdaptiveCriteriaList = ScanAdaptiveFileIntoMap(path, *IndexKeySetList); // (Root No., (Value, Order)) !
+    if (AdaptiveCriteriaList->empty()) {
+      DoeLog(2) && (eLog()<< Verbose(2) << "Unable to parse file, incrementing all." << endl);
+      for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    #ifdef ADDHYDROGEN
+        if ((*iter)->type->Z != 1) // skip hydrogen
+    #endif
+        {
+          AtomMask[(*iter)->nr] = true;  // include all (non-hydrogen) atoms
+          status = true;
+        }
+      }
+    }
+    // then map back onto (Value, (Root Nr., Order)) (i.e. sorted by value to pick the highest ones)
+    map<double, pair<int,int> > *FinalRootCandidates = ReMapAdaptiveCriteriaListToValue(AdaptiveCriteriaList, this);
+
+    // pick the ones still below threshold and mark as to be adaptively updated
+    MarkUpdateCandidates(AtomMask, *FinalRootCandidates, Order, this);
+
+    delete[](IndexKeySetList);
+    delete[](AdaptiveCriteriaList);
+    delete[](FinalRootCandidates);
+  } else { // global increase of Bond Order
+    for(molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+  #ifdef ADDHYDROGEN
+      if ((*iter)->type->Z != 1) // skip hydrogen
+  #endif
+      {
+        AtomMask[(*iter)->nr] = true;  // include all (non-hydrogen) atoms
+        if ((Order != 0) && ((*iter)->AdaptiveOrder < Order)) // && ((*iter)->AdaptiveOrder < MinimumRingSize[(*iter)->nr]))
+          status = true;
+      }
+    }
+    if ((!Order) && (!AtomMask[getAtomCount()]))  // single stepping, just check
+      status = true;
+
+    if (!status) {
+      if (Order == 0)
+        DoLog(1) && (Log() << Verbose(1) << "Single stepping done." << endl);
+      else
+        DoLog(1) && (Log() << Verbose(1) << "Order at every site is already equal or above desired order " << Order << "." << endl);
+    }
+  }
+
+  PrintAtomMask(AtomMask, getAtomCount()); // for debugging
+
+  return status;
+};
+
+/** Create a SortIndex to map from atomic labels to the sequence in which the atoms are given in the config file.
+ * \param *out output stream for debugging
+ * \param *&SortIndex Mapping array of size molecule::AtomCount
+ * \return true - success, false - failure of SortIndex alloc
+ */
+bool molecule::CreateMappingLabelsToConfigSequence(int *&SortIndex)
+{
+  if (SortIndex != NULL) {
+    DoLog(1) && (Log() << Verbose(1) << "SortIndex is " << SortIndex << " and not NULL as expected." << endl);
+    return false;
+  }
+  SortIndex = new int[getAtomCount()];
+  for(int i=getAtomCount();i--;)
+    SortIndex[i] = -1;
+
+  int AtomNo = 0;
+  SetIndexedArrayForEachAtomTo( SortIndex, &atom::nr, &IncrementalAbsoluteValue, AtomNo );
+
+  return true;
+};
+
+
+
+/** Creates a lookup table for true father's Atom::Nr -> atom ptr.
+ * \param *start begin of list (STL iterator, i.e. first item)
+ * \paran *end end of list (STL iterator, i.e. one past last item)
+ * \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
+ */
+bool molecule::CreateFatherLookupTable(atom **&LookupTable, int count)
+{
+  bool status = true;
+  int AtomNo;
+
+  if (LookupTable != NULL) {
+    Log() << Verbose(0) << "Pointer for Lookup table is not NULL! Aborting ..." <<endl;
+    return false;
+  }
+
+  // count them
+  if (count == 0) {
+    for (molecule::iterator iter = begin(); iter != end(); ++iter) { // create a lookup table (Atom::nr -> atom) used as a marker table lateron
+      count = (count < (*iter)->GetTrueFather()->nr) ? (*iter)->GetTrueFather()->nr : count;
+    }
+  }
+  if (count <= 0) {
+    Log() << Verbose(0) << "Count of lookup list is 0 or less." << endl;
+    return false;
+  }
+
+  // allocate and fill
+  LookupTable = new atom *[count];
+  if (LookupTable == NULL) {
+    eLog() << Verbose(0) << "LookupTable memory allocation failed!" << endl;
+    performCriticalExit();
+    status = false;
+  } else {
+    for (int i=0;i<count;i++)
+      LookupTable[i] = NULL;
+    for (molecule::iterator iter = begin(); iter != end(); ++iter) {
+      AtomNo = (*iter)->GetTrueFather()->nr;
+      if ((AtomNo >= 0) && (AtomNo < count)) {
+        //*out << "Setting LookupTable[" << AtomNo << "] to " << *(*iter) << endl;
+        LookupTable[AtomNo] = (*iter);
+      } else {
+        Log() << Verbose(0) << "Walker " << *(*iter) << " exceeded range of nuclear ids [0, " << count << ")." << endl;
+        status = false;
+        break;
+      }
+    }
+  }
+
+  return status;
+};
+
+/** Performs a many-body bond order analysis for a given bond order.
+ * -# parses adjacency, keysets and orderatsite files
+ * -# performs DFS to find connected subgraphs (to leave this in was a design decision: might be useful later)
+ * -# RootStack is created for every subgraph (here, later we implement the "update 10 sites with highest energ
+y contribution", and that's why this consciously not done in the following loop)
+ * -# in a loop over all subgraphs
+ *  -# calls FragmentBOSSANOVA with this RootStack and within the subgraph molecule structure
+ *  -# creates molecule (fragment)s from the returned keysets (StoreFragmentFromKeySet)
+ * -# combines the generated molecule lists from all subgraphs
+ * -# saves to disk: fragment configs, adjacency, orderatsite, keyset files
+ * Note that as we split "this" molecule up into a list of subgraphs, i.e. a MoleculeListClass, we have two sets
+ * of vertex indices: Global always means the index in "this" molecule, whereas local refers to the molecule or
+ * subgraph in the MoleculeListClass.
+ * \param Order up to how many neighbouring bonds a fragment contains in BondOrderScheme::BottumUp scheme
+ * \param &prefix path and prefix of the bond order configs to be written
+ * \return 1 - continue, 2 - stop (no fragmentation occured)
+ */
+int molecule::FragmentMolecule(int Order, std::string &prefix)
+{
+  MoleculeListClass *BondFragments = NULL;
+  int *MinimumRingSize = new int[getAtomCount()];
+  int FragmentCounter;
+  MoleculeLeafClass *MolecularWalker = NULL;
+  MoleculeLeafClass *Subgraphs = NULL;      // list of subgraphs from DFS analysis
+  fstream File;
+  bool FragmentationToDo = true;
+  class StackClass<bond *> *BackEdgeStack = NULL, *LocalBackEdgeStack = NULL;
+  bool CheckOrder = false;
+  Graph **FragmentList = NULL;
+  Graph *ParsedFragmentList = NULL;
+  Graph TotalGraph;     // graph with all keysets however local numbers
+  int TotalNumberOfKeySets = 0;
+  atom **ListOfAtoms = NULL;
+  atom ***ListOfLocalAtoms = NULL;
+  bool *AtomMask = NULL;
+
+  DoLog(0) && (Log() << Verbose(0) << endl);
+#ifdef ADDHYDROGEN
+  DoLog(0) && (Log() << Verbose(0) << "I will treat hydrogen special and saturate dangling bonds with it." << endl);
+#else
+  DoLog(0) && (Log() << Verbose(0) << "Hydrogen is treated just like the rest of the lot." << endl);
+#endif
+
+  // ++++++++++++++++++++++++++++ INITIAL STUFF: Bond structure analysis, file parsing, ... ++++++++++++++++++++++++++++++++++++++++++
+
+  // ===== 1. Check whether bond structure is same as stored in files ====
+
+  // create lookup table for Atom::nr
+  FragmentationToDo = FragmentationToDo && CreateFatherLookupTable(ListOfAtoms, getAtomCount());
+
+  // === compare it with adjacency file ===
+  FragmentationToDo = FragmentationToDo && CheckAdjacencyFileAgainstMolecule(prefix, ListOfAtoms);
+  delete[](ListOfAtoms);
+
+  // ===== 2. perform a DFS analysis to gather info on cyclic structure and a list of disconnected subgraphs =====
+  Subgraphs = DepthFirstSearchAnalysis(BackEdgeStack);
+
+  // analysis of the cycles (print rings, get minimum cycle length) for each subgraph
+  for(int i=getAtomCount();i--;)
+    MinimumRingSize[i] = getAtomCount();
+  MolecularWalker = Subgraphs;
+  const int LeafCount = Subgraphs->next->Count();
+  FragmentCounter = 0;
+  while (MolecularWalker->next != NULL) {
+    MolecularWalker = MolecularWalker->next;
+    // fill the bond structure of the individually stored subgraphs
+    ListOfAtoms = NULL;
+    MolecularWalker->FillBondStructureFromReference(this, ListOfAtoms, false);  // we want to keep the created ListOfLocalAtoms
+    DoLog(0) && (Log() << Verbose(0) << "Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl);
+    LocalBackEdgeStack = new StackClass<bond *> (MolecularWalker->Leaf->BondCount);
+//    // check the list of local atoms for debugging
+//    Log() << Verbose(0) << "ListOfLocalAtoms for this subgraph is:" << endl;
+//    for (int i=0;i<getAtomCount();i++)
+//      if (ListOfLocalAtoms[FragmentCounter][i] == NULL)
+//        Log() << Verbose(0) << "\tNULL";
+//      else
+//        Log() << Verbose(0) << "\t" << ListOfLocalAtoms[FragmentCounter][i]->Name;
+    DoLog(0) && (Log() << Verbose(0) << "Gathering local back edges for subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl);
+    MolecularWalker->Leaf->PickLocalBackEdges(ListOfAtoms, BackEdgeStack, LocalBackEdgeStack);
+    DoLog(0) && (Log() << Verbose(0) << "Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl);
+    MolecularWalker->Leaf->CyclicStructureAnalysis(LocalBackEdgeStack, MinimumRingSize);
+    DoLog(0) && (Log() << Verbose(0) << "Done with Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl);
+    delete(LocalBackEdgeStack);
+    delete(ListOfAtoms);
+    FragmentCounter++;
+  }
+  delete(BackEdgeStack);
+
+  // ===== 3. if structure still valid, parse key set file and others =====
+  FragmentationToDo = FragmentationToDo && ParseKeySetFile(prefix, ParsedFragmentList);
+
+  // ===== 4. check globally whether there's something to do actually (first adaptivity check)
+  FragmentationToDo = FragmentationToDo && ParseOrderAtSiteFromFile(prefix);
+
+  // =================================== Begin of FRAGMENTATION ===============================
+  // ===== 6a. assign each keyset to its respective subgraph =====
+  ListOfLocalAtoms = new atom **[LeafCount];
+  for (int i=0;i<LeafCount;i++)
+    ListOfLocalAtoms[i] = NULL;
+  FragmentCounter = 0;
+  Subgraphs->next->AssignKeySetsToFragment(this, ParsedFragmentList, ListOfLocalAtoms, FragmentList, FragmentCounter, true);
+  delete[](ListOfLocalAtoms);
+
+  // ===== 6b. prepare and go into the adaptive (Order<0), single-step (Order==0) or incremental (Order>0) cycle
+  KeyStack *RootStack = new KeyStack[Subgraphs->next->Count()];
+  AtomMask = new bool[getAtomCount()+1];
+  AtomMask[getAtomCount()] = false;
+  FragmentationToDo = false;  // if CheckOrderAtSite just ones recommends fragmentation, we will save fragments afterwards
+  while ((CheckOrder = CheckOrderAtSite(AtomMask, ParsedFragmentList, Order, MinimumRingSize, prefix))) {
+    FragmentationToDo = FragmentationToDo || CheckOrder;
+    AtomMask[getAtomCount()] = true;   // last plus one entry is used as marker that we have been through this loop once already in CheckOrderAtSite()
+    // ===== 6b. fill RootStack for each subgraph (second adaptivity check) =====
+    Subgraphs->next->FillRootStackForSubgraphs(RootStack, AtomMask, (FragmentCounter = 0));
+
+    // ===== 7. fill the bond fragment list =====
+    FragmentCounter = 0;
+    MolecularWalker = Subgraphs;
+    while (MolecularWalker->next != NULL) {
+      MolecularWalker = MolecularWalker->next;
+      DoLog(1) && (Log() << Verbose(1) << "Fragmenting subgraph " << MolecularWalker << "." << endl);
+      //MolecularWalker->Leaf->OutputListOfBonds(out);  // output atom::ListOfBonds for debugging
+      if (MolecularWalker->Leaf->hasBondStructure()) {
+        // call BOSSANOVA method
+        DoLog(0) && (Log() << Verbose(0) << endl << " ========== BOND ENERGY of subgraph " << FragmentCounter << " ========================= " << endl);
+        MolecularWalker->Leaf->FragmentBOSSANOVA(FragmentList[FragmentCounter], RootStack[FragmentCounter], MinimumRingSize);
+      } else {
+        DoeLog(1) && (eLog()<< Verbose(1) << "Subgraph " << MolecularWalker << " has no atoms!" << endl);
+      }
+      FragmentCounter++;  // next fragment list
+    }
+  }
+  DoLog(2) && (Log() << Verbose(2) << "CheckOrder is " << CheckOrder << "." << endl);
+  delete[](RootStack);
+  delete[](AtomMask);
+  delete(ParsedFragmentList);
+  delete[](MinimumRingSize);
+
+  // ==================================== End of FRAGMENTATION ============================================
+
+  // ===== 8a. translate list into global numbers (i.e. ones that are valid in "this" molecule, not in MolecularWalker->Leaf)
+  Subgraphs->next->TranslateIndicesToGlobalIDs(FragmentList, (FragmentCounter = 0), TotalNumberOfKeySets, TotalGraph);
+
+  // free subgraph memory again
+  FragmentCounter = 0;
+  if (Subgraphs != NULL) {
+    while (Subgraphs->next != NULL) {
+      Subgraphs = Subgraphs->next;
+      delete(FragmentList[FragmentCounter++]);
+      delete(Subgraphs->previous);
+    }
+    delete(Subgraphs);
+  }
+  delete[](FragmentList);
+
+  // ===== 8b. gather keyset lists (graphs) from all subgraphs and transform into MoleculeListClass =====
+  //if (FragmentationToDo) {    // we should always store the fragments again as coordination might have changed slightly without changing bond structure
+  // allocate memory for the pointer array and transmorph graphs into full molecular fragments
+  BondFragments = new MoleculeListClass(World::getPointer());
+  int k=0;
+  for(Graph::iterator runner = TotalGraph.begin(); runner != TotalGraph.end(); runner++) {
+    KeySet test = (*runner).first;
+    DoLog(0) && (Log() << Verbose(0) << "Fragment No." << (*runner).second.first << " with TEFactor " << (*runner).second.second << "." << endl);
+    BondFragments->insert(StoreFragmentFromKeySet(test, World::getInstance().getConfig()));
+    k++;
+  }
+  DoLog(0) && (Log() << Verbose(0) << k << "/" << BondFragments->ListOfMolecules.size() << " fragments generated from the keysets." << endl);
+
+  // ===== 9. Save fragments' configuration and keyset files et al to disk ===
+  if (BondFragments->ListOfMolecules.size() != 0) {
+    // create the SortIndex from BFS labels to order in the config file
+    int *SortIndex = NULL;
+    CreateMappingLabelsToConfigSequence(SortIndex);
+
+    DoLog(1) && (Log() << Verbose(1) << "Writing " << BondFragments->ListOfMolecules.size() << " possible bond fragmentation configs" << endl);
+    if (BondFragments->OutputConfigForListOfFragments(prefix, SortIndex))
+      DoLog(1) && (Log() << Verbose(1) << "All configs written." << endl);
+    else
+      DoLog(1) && (Log() << Verbose(1) << "Some config writing failed." << endl);
+
+    // store force index reference file
+    BondFragments->StoreForcesFile(prefix, SortIndex);
+
+    // store keysets file
+    StoreKeySetFile(TotalGraph, prefix);
+
+    {
+      // store Adjacency file
+      std::string filename = prefix + ADJACENCYFILE;
+      StoreAdjacencyToFile(filename);
+    }
+
+    // store Hydrogen saturation correction file
+    BondFragments->AddHydrogenCorrection(prefix);
+
+    // store adaptive orders into file
+    StoreOrderAtSiteFile(prefix);
+
+    // restore orbital and Stop values
+    //CalculateOrbitals(*configuration);
+
+    // free memory for bond part
+    DoLog(1) && (Log() << Verbose(1) << "Freeing bond memory" << endl);
+    delete[](SortIndex);
+  } else {
+    DoLog(1) && (Log() << Verbose(1) << "FragmentList is zero on return, splitting failed." << endl);
+  }
+  delete(BondFragments);
+  DoLog(0) && (Log() << Verbose(0) << "End of bond fragmentation." << endl);
+
+  return ((int)(!FragmentationToDo)+1);    // 1 - continue, 2 - stop (no fragmentation occured)
+};
+
+
+/** Stores pairs (Atom::nr, Atom::AdaptiveOrder) into file.
+ * Atoms not present in the file get "-1".
+ * \param &path path to file ORDERATSITEFILE
+ * \return true - file writable, false - not writable
+ */
+bool molecule::StoreOrderAtSiteFile(std::string &path)
+{
+  string line;
+  ofstream file;
+
+  line = path + ORDERATSITEFILE;
+  file.open(line.c_str());
+  DoLog(1) && (Log() << Verbose(1) << "Writing OrderAtSite " << ORDERATSITEFILE << " ... " << endl);
+  if (file.good()) {
+    ActOnAllAtoms( &atom::OutputOrder, &file );
+    file.close();
+    DoLog(1) && (Log() << Verbose(1) << "done." << endl);
+    return true;
+  } else {
+    DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line << "." << endl);
+    return false;
+  }
+};
+
+/** Parses pairs(Atom::nr, Atom::AdaptiveOrder) from file and stores in molecule's Atom's.
+ * Atoms not present in the file get "0".
+ * \param &path path to file ORDERATSITEFILEe
+ * \return true - file found and scanned, false - file not found
+ * \sa ParseKeySetFile() and CheckAdjacencyFileAgainstMolecule() as this is meant to be used in conjunction with the two
+ */
+bool molecule::ParseOrderAtSiteFromFile(std::string &path)
+{
+  unsigned char *OrderArray = new unsigned char[getAtomCount()];
+  bool *MaxArray = new bool[getAtomCount()];
+  bool status;
+  int AtomNr, value;
+  string line;
+  ifstream file;
+
+  for(int i=0;i<getAtomCount();i++) {
+    OrderArray[i] = 0;
+    MaxArray[i] = false;
+  }
+
+  DoLog(1) && (Log() << Verbose(1) << "Begin of ParseOrderAtSiteFromFile" << endl);
+  line = path + ORDERATSITEFILE;
+  file.open(line.c_str());
+  if (file.good()) {
+    while (!file.eof()) { // parse from file
+      AtomNr = -1;
+      file >> AtomNr;
+      if (AtomNr != -1) {   // test whether we really parsed something (this is necessary, otherwise last atom is set twice and to 0 on second time)
+        file >> value;
+        OrderArray[AtomNr] = value;
+        file >> value;
+        MaxArray[AtomNr] = value;
+        //Log() << Verbose(2) << "AtomNr " << AtomNr << " with order " << (int)OrderArray[AtomNr] << " and max order set to " << (int)MaxArray[AtomNr] << "." << endl;
+      }
+    }
+    file.close();
+
+    // set atom values
+    SetAtomValueToIndexedArray( OrderArray, &atom::nr, &atom::AdaptiveOrder );
+    SetAtomValueToIndexedArray( MaxArray, &atom::nr, &atom::MaxOrder );
+
+    DoLog(1) && (Log() << Verbose(1) << "\t ... done." << endl);
+    status = true;
+  } else {
+    DoLog(1) && (Log() << Verbose(1) << "\t ... failed to open file " << line << "." << endl);
+    status = false;
+  }
+  delete[](OrderArray);
+  delete[](MaxArray);
+
+  DoLog(1) && (Log() << Verbose(1) << "End of ParseOrderAtSiteFromFile" << endl);
+  return status;
+};
+
+
+
+/** Looks through a StackClass<atom *> and returns the likeliest removal candiate.
+ * \param *out output stream for debugging messages
+ * \param *&Leaf KeySet to look through
+ * \param *&ShortestPathList list of the shortest path to decide which atom to suggest as removal candidate in the end
+ * \param index of the atom suggested for removal
+ */
+int molecule::LookForRemovalCandidate(KeySet *&Leaf, int *&ShortestPathList)
+{
+  atom *Runner = NULL;
+  int SP, Removal;
+
+  DoLog(2) && (Log() << Verbose(2) << "Looking for removal candidate." << endl);
+  SP = -1; //0;  // not -1, so that Root is never removed
+  Removal = -1;
+  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 (ShortestPathList[(*runner)] > SP) {  // remove the oldest one with longest shortest path
+        SP = ShortestPathList[(*runner)];
+        Removal = (*runner);
+      }
+    }
+  }
+  return Removal;
+};
+
+/** Initializes some value for putting fragment of \a *mol into \a *Leaf.
+ * \param *mol total molecule
+ * \param *Leaf fragment molecule
+ * \param &Leaflet pointer to KeySet structure
+ * \param **SonList calloc'd list which atom of \a *Leaf is a son of which atom in \a *mol
+ * \return number of atoms in fragment
+ */
+int StoreFragmentFromKeySet_Init(molecule *mol, molecule *Leaf, KeySet &Leaflet, atom **SonList)
+{
+  atom *FatherOfRunner = NULL;
+
+  Leaf->BondDistance = mol->BondDistance;
+
+  // first create the minimal set of atoms from the KeySet
+  int size = 0;
+  for(KeySet::iterator runner = Leaflet.begin(); runner != Leaflet.end(); runner++) {
+    FatherOfRunner = mol->FindAtom((*runner));  // find the id
+    SonList[FatherOfRunner->nr] = Leaf->AddCopyAtom(FatherOfRunner);
+    size++;
+  }
+  return size;
+};
+
+/** Creates an induced subgraph out of a fragmental key set, adding bonds and hydrogens (if treated specially).
+ * \param *out output stream for debugging messages
+ * \param *mol total molecule
+ * \param *Leaf fragment molecule
+ * \param IsAngstroem whether we have Ansgtroem or bohrradius
+ * \param **SonList list which atom of \a *Leaf is a son of which atom in \a *mol
+ */
+void CreateInducedSubgraphOfFragment(molecule *mol, molecule *Leaf, atom **SonList, bool IsAngstroem)
+{
+  bool LonelyFlag = false;
+  atom *OtherFather = NULL;
+  atom *FatherOfRunner = NULL;
+
+#ifdef ADDHYDROGEN
+  molecule::const_iterator runner;
+#endif
+  // we increment the iter just before skipping the hydrogen
+  for (molecule::const_iterator iter = Leaf->begin(); iter != Leaf->end();) {
+    LonelyFlag = true;
+    FatherOfRunner = (*iter)->father;
+    ASSERT(FatherOfRunner,"Atom without father found");
+    if (SonList[FatherOfRunner->nr] != NULL)  {  // check if this, our father, is present in list
+      // create all bonds
+      for (BondList::const_iterator BondRunner = FatherOfRunner->ListOfBonds.begin(); BondRunner != FatherOfRunner->ListOfBonds.end(); (++BondRunner)) {
+        OtherFather = (*BondRunner)->GetOtherAtom(FatherOfRunner);
+//        Log() << Verbose(2) << "Father " << *FatherOfRunner << " of son " << *SonList[FatherOfRunner->nr] << " is bound to " << *OtherFather;
+        if (SonList[OtherFather->nr] != NULL) {
+//          Log() << Verbose(0) << ", whose son is " << *SonList[OtherFather->nr] << "." << endl;
+          if (OtherFather->nr > FatherOfRunner->nr) { // add bond (nr check is for adding only one of both variants: ab, ba)
+//            Log() << Verbose(3) << "Adding Bond: ";
+//            Log() << Verbose(0) <<
+            Leaf->AddBond((*iter), SonList[OtherFather->nr], (*BondRunner)->BondDegree);
+//            Log() << Verbose(0) << "." << endl;
+            //NumBonds[(*iter)->nr]++;
+          } else {
+//            Log() << Verbose(3) << "Not adding bond, labels in wrong order." << endl;
+          }
+          LonelyFlag = false;
+        } else {
+//          Log() << Verbose(0) << ", who has no son in this fragment molecule." << endl;
+#ifdef ADDHYDROGEN
+          //Log() << Verbose(3) << "Adding Hydrogen to " << (*iter)->Name << " and a bond in between." << endl;
+          if(!Leaf->AddHydrogenReplacementAtom((*BondRunner), (*iter), FatherOfRunner, OtherFather, IsAngstroem))
+            exit(1);
+#endif
+          //NumBonds[(*iter)->nr] += Binder->BondDegree;
+        }
+      }
+    } else {
+    DoeLog(1) && (eLog()<< Verbose(1) << "Son " << (*iter)->getName() << " has father " << FatherOfRunner->getName() << " but its entry in SonList is " << SonList[FatherOfRunner->nr] << "!" << endl);
+    }
+    if ((LonelyFlag) && (Leaf->getAtomCount() > 1)) {
+      DoLog(0) && (Log() << Verbose(0) << **iter << "has got bonds only to hydrogens!" << endl);
+    }
+    ++iter;
+#ifdef ADDHYDROGEN
+    while ((iter != Leaf->end()) && ((*iter)->type->Z == 1)){ // skip added hydrogen
+      iter++;
+    }
+#endif
+  }
+};
+
+/** Stores a fragment from \a KeySet into \a molecule.
+ * First creates the minimal set of atoms from the KeySet, then creates the bond structure from the complete
+ * molecule and adds missing hydrogen where bonds were cut.
+ * \param *out output stream for debugging messages
+ * \param &Leaflet pointer to KeySet structure
+ * \param IsAngstroem whether we have Ansgtroem or bohrradius
+ * \return pointer to constructed molecule
+ */
+molecule * molecule::StoreFragmentFromKeySet(KeySet &Leaflet, bool IsAngstroem)
+{
+  atom **SonList = new atom*[getAtomCount()];
+  molecule *Leaf = World::getInstance().createMolecule();
+
+  for(int i=0;i<getAtomCount();i++)
+    SonList[i] = NULL;
+
+//  Log() << Verbose(1) << "Begin of StoreFragmentFromKeyset." << endl;
+  StoreFragmentFromKeySet_Init(this, Leaf, Leaflet, SonList);
+  // create the bonds between all: Make it an induced subgraph and add hydrogen
+//  Log() << Verbose(2) << "Creating bonds from father graph (i.e. induced subgraph creation)." << endl;
+  CreateInducedSubgraphOfFragment(this, Leaf, SonList, IsAngstroem);
+
+  //Leaflet->Leaf->ScanForPeriodicCorrection(out);
+  delete[](SonList);
+//  Log() << Verbose(1) << "End of StoreFragmentFromKeyset." << endl;
+  return Leaf;
+};
+
+
+/** Clears the touched list
+ * \param *out output stream for debugging
+ * \param verbosity verbosity level
+ * \param *&TouchedList touched list
+ * \param SubOrder current suborder
+ * \param TouchedIndex currently touched
+ */
+void SPFragmentGenerator_ClearingTouched(int verbosity, int *&TouchedList, int SubOrder, int &TouchedIndex)
+{
+  Log() << Verbose(1+verbosity) << "Clearing touched list." << endl;
+  for (TouchedIndex=SubOrder+1;TouchedIndex--;)  // empty touched list
+    TouchedList[TouchedIndex] = -1;
+  TouchedIndex = 0;
+
+}
+
+/** Adds the current combination of the power set to the snake stack.
+ * \param *out output stream for debugging
+ * \param verbosity verbosity level
+ * \param CurrentCombination
+ * \param SetDimension maximum number of bits in power set
+ * \param *FragmentSet snake stack to remove from
+ * \param *&TouchedList touched list
+ * \param TouchedIndex currently touched
+ * \return number of set bits
+ */
+int AddPowersetToSnakeStack(int verbosity, int CurrentCombination, int SetDimension, KeySet *FragmentSet, bond **BondsSet, int *&TouchedList, int &TouchedIndex)
+{
+  atom *OtherWalker = NULL;
+  bool bit = false;
+  KeySetTestPair TestKeySetInsert;
+
+  int Added = 0;
+  for (int j=0;j<SetDimension;j++) {  // pull out every bit by shifting
+    bit = ((CurrentCombination & (1 << j)) != 0);  // mask the bit for the j-th bond
+    if (bit) {  // if bit is set, we add this bond partner
+      OtherWalker = BondsSet[j]->rightatom;  // rightatom is always the one more distant, i.e. the one to add
+      //Log() << Verbose(1+verbosity) << "Current Bond is " << BondsSet[j] << ", checking on " << *OtherWalker << "." << endl;
+      Log() << Verbose(2+verbosity) << "Adding " << *OtherWalker << " with nr " << OtherWalker->nr << "." << endl;
+      TestKeySetInsert = FragmentSet->insert(OtherWalker->nr);
+      if (TestKeySetInsert.second) {
+        TouchedList[TouchedIndex++] = OtherWalker->nr;  // note as added
+        Added++;
+      } else {
+        Log() << Verbose(2+verbosity) << "This was item was already present in the keyset." << endl;
+      }
+    } else {
+      Log() << Verbose(2+verbosity) << "Not adding." << endl;
+    }
+  }
+  return Added;
+};
+
+/** Counts the number of elements in a power set.
+ * \param *SetFirst
+ * \param *SetLast
+ * \param *&TouchedList touched list
+ * \param TouchedIndex currently touched
+ * \return number of elements
+ */
+int CountSetMembers(bond *SetFirst, bond *SetLast, int *&TouchedList, int TouchedIndex)
+{
+  int SetDimension = 0;
+  bond *Binder = SetFirst;    // start node for this level
+  while (Binder->next != SetLast) {    // compare to end node of this level
+    Binder = Binder->next;
+    for (int k=TouchedIndex;k--;) {
+      if (Binder->Contains(TouchedList[k]))   // if we added this very endpiece
+        SetDimension++;
+    }
+  }
+  return SetDimension;
+};
+
+/** Counts the number of elements in a power set.
+ * \param *BondsList bonds list to fill
+ * \param *SetFirst
+ * \param *SetLast
+ * \param *&TouchedList touched list
+ * \param TouchedIndex currently touched
+ * \return number of elements
+ */
+int FillBondsList(bond **BondsList, bond *SetFirst, bond *SetLast, int *&TouchedList, int TouchedIndex)
+{
+  int SetDimension = 0;
+  bond *Binder = SetFirst;    // start node for this level
+  while (Binder->next != SetLast) {    // compare to end node of this level
+    Binder = Binder->next;
+    for (int k=0;k<TouchedIndex;k++) {
+      if (Binder->leftatom->nr == TouchedList[k])   // leftatom is always the close one
+        BondsList[SetDimension++] = Binder;
+    }
+  }
+  return SetDimension;
+};
+
+/** Remove all items that were added on this SP level.
+ * \param *out output stream for debugging
+ * \param verbosity verbosity level
+ * \param *FragmentSet snake stack to remove from
+ * \param *&TouchedList touched list
+ * \param TouchedIndex currently touched
+ */
+void RemoveAllTouchedFromSnakeStack(int verbosity, KeySet *FragmentSet, int *&TouchedList, int &TouchedIndex)
+{
+  int Removal = 0;
+  for(int j=0;j<TouchedIndex;j++) {
+    Removal = TouchedList[j];
+    Log() << Verbose(2+verbosity) << "Removing item nr. " << Removal << " from snake stack." << endl;
+    FragmentSet->erase(Removal);
+    TouchedList[j] = -1;
+  }
+  DoLog(2) && (Log() << Verbose(2) << "Remaining local nr.s on snake stack are: ");
+  for(KeySet::iterator runner = FragmentSet->begin(); runner != FragmentSet->end(); runner++)
+    DoLog(0) && (Log() << Verbose(0) << (*runner) << " ");
+  DoLog(0) && (Log() << Verbose(0) << endl);
+  TouchedIndex = 0; // set Index to 0 for list of atoms added on this level
+};
+
+/** From a given set of Bond sorted by Shortest Path distance, create all possible fragments of size \a SetDimension.
+ * -# loops over every possible combination (2^dimension of edge set)
+ *  -# inserts current set, if there's still space left
+ *    -# yes: calls SPFragmentGenerator with structure, created new edge list and size respective to root dist
+ance+1
+ *    -# no: stores fragment into keyset list by calling InsertFragmentIntoGraph
+ *  -# removes all items added into the snake stack (in UniqueFragments structure) added during level (root
+distance) and current set
+ * \param *out output stream for debugging
+ * \param FragmentSearch UniqueFragments structure with all values needed
+ * \param RootDistance current shortest path level, whose set of edges is represented by **BondsSet
+ * \param SetDimension Number of possible bonds on this level (i.e. size of the array BondsSet[])
+ * \param SubOrder remaining number of allowed vertices to add
+ */
+void molecule::SPFragmentGenerator(struct UniqueFragments *FragmentSearch, int RootDistance, bond **BondsSet, int SetDimension, int SubOrder)
+{
+  int verbosity = 0; //FragmentSearch->ANOVAOrder-SubOrder;
+  int NumCombinations;
+  int bits, TouchedIndex, SubSetDimension, SP, Added;
+  int SpaceLeft;
+  int *TouchedList = new int[SubOrder + 1];
+  KeySetTestPair TestKeySetInsert;
+
+  NumCombinations = 1 << SetDimension;
+
+  // here for all bonds of Walker all combinations of end pieces (from the bonds)
+  // have to be added and for the remaining ANOVA order GraphCrawler be called
+  // recursively for the next level
+
+  Log() << Verbose(1+verbosity) << "Begin of SPFragmentGenerator." << endl;
+  Log() << Verbose(1+verbosity) << "We are " << RootDistance << " away from Root, which is " << *FragmentSearch->Root << ", SubOrder is " << SubOrder << ", SetDimension is " << SetDimension << " and this means " <<  NumCombinations-1 << " combination(s)." << endl;
+
+  // initialised touched list (stores added atoms on this level)
+  SPFragmentGenerator_ClearingTouched(verbosity, TouchedList, SubOrder, TouchedIndex);
+
+  // create every possible combination of the endpieces
+  Log() << Verbose(1+verbosity) << "Going through all combinations of the power set." << endl;
+  for (int i=1;i<NumCombinations;i++) {  // sweep through all power set combinations (skip empty set!)
+    // count the set bit of i
+    bits = 0;
+    for (int j=SetDimension;j--;)
+      bits += (i & (1 << j)) >> j;
+
+    Log() << Verbose(1+verbosity) << "Current set is " << Binary(i | (1 << SetDimension)) << ", number of bits is " << bits << "." << endl;
+    if (bits <= SubOrder) { // if not greater than additional atoms allowed on stack, continue
+      // --1-- add this set of the power set of bond partners to the snake stack
+      Added = AddPowersetToSnakeStack(verbosity, i, SetDimension, FragmentSearch->FragmentSet, BondsSet, TouchedList, TouchedIndex);
+
+      SpaceLeft = SubOrder - Added ;// SubOrder - bits; // due to item's maybe being already present, this does not work anymore
+      if (SpaceLeft > 0) {
+        Log() << Verbose(1+verbosity) << "There's still some space left on stack: " << SpaceLeft << "." << endl;
+        if (SubOrder > 1) {    // Due to Added above we have to check extra whether we're not already reaching beyond the desired Order
+          // --2-- look at all added end pieces of this combination, construct bond subsets and sweep through a power set of these by recursion
+          SP = RootDistance+1;  // this is the next level
+
+          // first count the members in the subset
+          SubSetDimension = CountSetMembers(FragmentSearch->BondsPerSPList[2*SP], FragmentSearch->BondsPerSPList[2*SP+1], TouchedList, TouchedIndex);
+
+          // then allocate and fill the list
+          bond *BondsList[SubSetDimension];
+          SubSetDimension = FillBondsList(BondsList, FragmentSearch->BondsPerSPList[2*SP], FragmentSearch->BondsPerSPList[2*SP+1], TouchedList, TouchedIndex);
+
+          // then iterate
+          Log() << Verbose(2+verbosity) << "Calling subset generator " << SP << " away from root " << *FragmentSearch->Root << " with sub set dimension " << SubSetDimension << "." << endl;
+          SPFragmentGenerator(FragmentSearch, SP, BondsList, SubSetDimension, SubOrder-bits);
+        }
+      } else {
+        // --2-- otherwise store the complete fragment
+        Log() << Verbose(1+verbosity) << "Enough items on stack for a fragment!" << endl;
+        // store fragment as a KeySet
+        DoLog(2) && (Log() << Verbose(2) << "Found a new fragment[" << FragmentSearch->FragmentCounter << "], local nr.s are: ");
+        for(KeySet::iterator runner = FragmentSearch->FragmentSet->begin(); runner != FragmentSearch->FragmentSet->end(); runner++)
+          DoLog(0) && (Log() << Verbose(0) << (*runner) << " ");
+        DoLog(0) && (Log() << Verbose(0) << endl);
+        //if (!CheckForConnectedSubgraph(FragmentSearch->FragmentSet))
+          //DoeLog(1) && (eLog()<< Verbose(1) << "The found fragment is not a connected subgraph!" << endl);
+        InsertFragmentIntoGraph(FragmentSearch);
+      }
+
+      // --3-- remove all added items in this level from snake stack
+      Log() << Verbose(1+verbosity) << "Removing all items that were added on this SP level " << RootDistance << "." << endl;
+      RemoveAllTouchedFromSnakeStack(verbosity, FragmentSearch->FragmentSet, TouchedList, TouchedIndex);
+    } else {
+      Log() << Verbose(2+verbosity) << "More atoms to add for this set (" << bits << ") than space left on stack " << SubOrder << ", skipping this set." << endl;
+    }
+  }
+  delete[](TouchedList);
+  Log() << Verbose(1+verbosity) << "End of SPFragmentGenerator, " << RootDistance << " away from Root " << *FragmentSearch->Root << " and SubOrder is " << SubOrder << "." << endl;
+};
+
+/** Allocates memory for UniqueFragments::BondsPerSPList.
+ * \param *out output stream
+ * \param Order bond order (limits BFS exploration and "number of digits" in power set generation
+ * \param FragmentSearch UniqueFragments
+ * \sa FreeSPList()
+ */
+void InitialiseSPList(int Order, struct UniqueFragments &FragmentSearch)
+{
+  FragmentSearch.BondsPerSPList = new bond* [Order * 2];
+  FragmentSearch.BondsPerSPCount = new int[Order];
+  for (int i=Order;i--;) {
+    FragmentSearch.BondsPerSPList[2*i] = new bond();    // start node
+    FragmentSearch.BondsPerSPList[2*i+1] = new bond();  // end node
+    FragmentSearch.BondsPerSPList[2*i]->next = FragmentSearch.BondsPerSPList[2*i+1];     // intertwine these two
+    FragmentSearch.BondsPerSPList[2*i+1]->previous = FragmentSearch.BondsPerSPList[2*i];
+    FragmentSearch.BondsPerSPCount[i] = 0;
+  }
+};
+
+/** Free's memory for for UniqueFragments::BondsPerSPList.
+ * \param *out output stream
+ * \param Order bond order (limits BFS exploration and "number of digits" in power set generation
+ * \param FragmentSearch UniqueFragments\
+ * \sa InitialiseSPList()
+ */
+void FreeSPList(int Order, struct UniqueFragments &FragmentSearch)
+{
+  delete[](FragmentSearch.BondsPerSPCount);
+  for (int i=Order;i--;) {
+    delete(FragmentSearch.BondsPerSPList[2*i]);
+    delete(FragmentSearch.BondsPerSPList[2*i+1]);
+  }
+  delete[](FragmentSearch.BondsPerSPList);
+};
+
+/** Sets FragmenSearch to initial value.
+ * Sets UniqueFragments::ShortestPathList entries to zero, UniqueFragments::BondsPerSPCount to zero (except zero level to 1) and
+ * adds initial bond UniqueFragments::Root to UniqueFragments::Root to UniqueFragments::BondsPerSPList
+ * \param *out output stream
+ * \param Order bond order (limits BFS exploration and "number of digits" in power set generation
+ * \param FragmentSearch UniqueFragments
+ * \sa FreeSPList()
+ */
+void SetSPList(int Order, struct UniqueFragments &FragmentSearch)
+{
+  // prepare Label and SP arrays of the BFS search
+  FragmentSearch.ShortestPathList[FragmentSearch.Root->nr] = 0;
+
+  // prepare root level (SP = 0) and a loop bond denoting Root
+  for (int i=Order;i--;)
+    FragmentSearch.BondsPerSPCount[i] = 0;
+  FragmentSearch.BondsPerSPCount[0] = 1;
+  bond *Binder = new bond(FragmentSearch.Root, FragmentSearch.Root);
+  add(Binder, FragmentSearch.BondsPerSPList[1]);
+};
+
+/** Resets UniqueFragments::ShortestPathList and cleans bonds from UniqueFragments::BondsPerSPList.
+ * \param *out output stream
+ * \param Order bond order (limits BFS exploration and "number of digits" in power set generation
+ * \param FragmentSearch UniqueFragments
+ * \sa InitialiseSPList()
+ */
+void ResetSPList(int Order, struct UniqueFragments &FragmentSearch)
+{
+  bond *Binder = NULL;
+  DoLog(0) && (Log() << Verbose(0) << "Free'ing all found lists. and resetting index lists" << endl);
+  for(int i=Order;i--;) {
+    DoLog(1) && (Log() << Verbose(1) << "Current SP level is " << i << ": ");
+    Binder = FragmentSearch.BondsPerSPList[2*i];
+    while (Binder->next != FragmentSearch.BondsPerSPList[2*i+1]) {
+      Binder = Binder->next;
+      // Log() << Verbose(0) << "Removing atom " << Binder->leftatom->nr << " and " << Binder->rightatom->nr << "." << endl; // make sure numbers are local
+      FragmentSearch.ShortestPathList[Binder->leftatom->nr] = -1;
+      FragmentSearch.ShortestPathList[Binder->rightatom->nr] = -1;
+    }
+    // delete added bonds
+    cleanup(FragmentSearch.BondsPerSPList[2*i], FragmentSearch.BondsPerSPList[2*i+1]);
+    // also start and end node
+    DoLog(0) && (Log() << Verbose(0) << "cleaned." << endl);
+  }
+};
+
+
+/** Fills the Bonds per Shortest Path List and set the vertex labels.
+ * \param *out output stream
+ * \param Order bond order (limits BFS exploration and "number of digits" in power set generation
+ * \param FragmentSearch UniqueFragments
+ * \param *mol molecule with atoms and bonds
+ * \param RestrictedKeySet Restricted vertex set to use in context of molecule
+ */
+void FillSPListandLabelVertices(int Order, struct UniqueFragments &FragmentSearch, molecule *mol, KeySet RestrictedKeySet)
+{
+  // Actually, we should construct a spanning tree vom the root atom and select all edges therefrom and put them into
+  // according shortest path lists. However, we don't. Rather we fill these lists right away, as they do form a spanning
+  // tree already sorted into various SP levels. That's why we just do loops over the depth (CurrentSP) and breadth
+  // (EdgeinSPLevel) of this tree ...
+  // In another picture, the bonds always contain a direction by rightatom being the one more distant from root and hence
+  // naturally leftatom forming its predecessor, preventing the BFS"seeker" from continuing in the wrong direction.
+  int AtomKeyNr = -1;
+  atom *Walker = NULL;
+  atom *OtherWalker = NULL;
+  atom *Predecessor = NULL;
+  bond *CurrentEdge = NULL;
+  bond *Binder = NULL;
+  int RootKeyNr = FragmentSearch.Root->GetTrueFather()->nr;
+  int RemainingWalkers = -1;
+  int SP = -1;
+
+  DoLog(0) && (Log() << Verbose(0) << "Starting BFS analysis ..." << endl);
+  for (SP = 0; SP < (Order-1); SP++) {
+    DoLog(1) && (Log() << Verbose(1) << "New SP level reached: " << SP << ", creating new SP list with " << FragmentSearch.BondsPerSPCount[SP] << " item(s)");
+    if (SP > 0) {
+      DoLog(0) && (Log() << Verbose(0) << ", old level closed with " << FragmentSearch.BondsPerSPCount[SP-1] << " item(s)." << endl);
+      FragmentSearch.BondsPerSPCount[SP] = 0;
+    } else
+      DoLog(0) && (Log() << Verbose(0) << "." << endl);
+
+    RemainingWalkers = FragmentSearch.BondsPerSPCount[SP];
+    CurrentEdge = FragmentSearch.BondsPerSPList[2*SP];    /// start of this SP level's list
+    while (CurrentEdge->next != FragmentSearch.BondsPerSPList[2*SP+1]) {    /// end of this SP level's list
+      CurrentEdge = CurrentEdge->next;
+      RemainingWalkers--;
+      Walker = CurrentEdge->rightatom;    // rightatom is always the one more distant
+      Predecessor = CurrentEdge->leftatom;    // ... and leftatom is predecessor
+      AtomKeyNr = Walker->nr;
+      DoLog(0) && (Log() << Verbose(0) << "Current Walker is: " << *Walker << " with nr " << Walker->nr << " and SP of " << SP << ", with " << RemainingWalkers << " remaining walkers on this level." << endl);
+      // check for new sp level
+      // go through all its bonds
+      DoLog(1) && (Log() << Verbose(1) << "Going through all bonds of Walker." << endl);
+      for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
+        OtherWalker = (*Runner)->GetOtherAtom(Walker);
+        if ((RestrictedKeySet.find(OtherWalker->nr) != RestrictedKeySet.end())
+  #ifdef ADDHYDROGEN
+         && (OtherWalker->type->Z != 1)
+  #endif
+                                                              ) {  // skip hydrogens and restrict to fragment
+          DoLog(2) && (Log() << Verbose(2) << "Current partner is " << *OtherWalker << " with nr " << OtherWalker->nr << " in bond " << *(*Runner) << "." << endl);
+          // set the label if not set (and push on root stack as well)
+          if ((OtherWalker != Predecessor) && (OtherWalker->GetTrueFather()->nr > RootKeyNr)) { // only pass through those with label bigger than Root's
+            FragmentSearch.ShortestPathList[OtherWalker->nr] = SP+1;
+            DoLog(3) && (Log() << Verbose(3) << "Set Shortest Path to " << FragmentSearch.ShortestPathList[OtherWalker->nr] << "." << endl);
+            // add the bond in between to the SP list
+            Binder = new bond(Walker, OtherWalker); // create a new bond in such a manner, that bond::rightatom is always the one more distant
+            add(Binder, FragmentSearch.BondsPerSPList[2*(SP+1)+1]);
+            FragmentSearch.BondsPerSPCount[SP+1]++;
+            DoLog(3) && (Log() << Verbose(3) << "Added its bond to SP list, having now " << FragmentSearch.BondsPerSPCount[SP+1] << " item(s)." << endl);
+          } else {
+            if (OtherWalker != Predecessor)
+              DoLog(3) && (Log() << Verbose(3) << "Not passing on, as index of " << *OtherWalker << " " << OtherWalker->GetTrueFather()->nr << " is smaller than that of Root " << RootKeyNr << "." << endl);
+            else
+              DoLog(3) && (Log() << Verbose(3) << "This is my predecessor " << *Predecessor << "." << endl);
+          }
+        } else Log() << Verbose(2) << "Is not in the restricted keyset or skipping hydrogen " << *OtherWalker << "." << endl;
+      }
+    }
+  }
+};
+
+/** prints the Bonds per Shortest Path list in UniqueFragments.
+ * \param *out output stream
+ * \param Order bond order (limits BFS exploration and "number of digits" in power set generation
+ * \param FragmentSearch UniqueFragments
+ */
+void OutputSPList(int Order, struct UniqueFragments &FragmentSearch)
+{
+  bond *Binder = NULL;
+  DoLog(0) && (Log() << Verbose(0) << "Printing all found lists." << endl);
+  for(int i=1;i<Order;i++) {    // skip the root edge in the printing
+    Binder = FragmentSearch.BondsPerSPList[2*i];
+    DoLog(1) && (Log() << Verbose(1) << "Current SP level is " << i << "." << endl);
+    while (Binder->next != FragmentSearch.BondsPerSPList[2*i+1]) {
+      Binder = Binder->next;
+      DoLog(2) && (Log() << Verbose(2) << *Binder << endl);
+    }
+  }
+};
+
+/** Simply counts all bonds in all UniqueFragments::BondsPerSPList lists.
+ * \param *out output stream
+ * \param Order bond order (limits BFS exploration and "number of digits" in power set generation
+ * \param FragmentSearch UniqueFragments
+ */
+int CountNumbersInBondsList(int Order, struct UniqueFragments &FragmentSearch)
+{
+  bond *Binder = NULL;
+  int SP = -1;  // the Root <-> Root edge must be subtracted!
+  for(int i=Order;i--;) { // sum up all found edges
+    Binder = FragmentSearch.BondsPerSPList[2*i];
+    while (Binder->next != FragmentSearch.BondsPerSPList[2*i+1]) {
+      Binder = Binder->next;
+      SP++;
+    }
+  }
+  return SP;
+};
+
+/** Creates a list of all unique fragments of certain vertex size from a given graph \a Fragment for a given root vertex in the context of \a this molecule.
+ * -# initialises UniqueFragments structure
+ * -# fills edge list via BFS
+ * -# creates the fragment by calling recursive function SPFragmentGenerator with UniqueFragments structure, 0 as
+ root distance, the edge set, its dimension and the current suborder
+ * -# Free'ing structure
+ * Note that we may use the fact that the atoms are SP-ordered on the atomstack. I.e. when popping always the last, we first get all
+ * with SP of 2, then those with SP of 3, then those with SP of 4 and so on.
+ * \param *out output stream for debugging
+ * \param Order bond order (limits BFS exploration and "number of digits" in power set generation
+ * \param FragmentSearch UniqueFragments structure containing TEFactor, root atom and so on
+ * \param RestrictedKeySet Restricted vertex set to use in context of molecule
+ * \return number of inserted fragments
+ * \note ShortestPathList in FragmentSearch structure is probably due to NumberOfAtomsSPLevel and SP not needed anymore
+ */
+int molecule::PowerSetGenerator(int Order, struct UniqueFragments &FragmentSearch, KeySet RestrictedKeySet)
+{
+  int Counter = FragmentSearch.FragmentCounter; // mark current value of counter
+
+  DoLog(0) && (Log() << Verbose(0) << endl);
+  DoLog(0) && (Log() << Verbose(0) << "Begin of PowerSetGenerator with order " << Order << " at Root " << *FragmentSearch.Root << "." << endl);
+
+  SetSPList(Order, FragmentSearch);
+
+  // do a BFS search to fill the SP lists and label the found vertices
+  FillSPListandLabelVertices(Order, FragmentSearch, this, RestrictedKeySet);
+
+  // outputting all list for debugging
+  OutputSPList(Order, FragmentSearch);
+
+  // creating fragments with the found edge sets  (may be done in reverse order, faster)
+  int SP = CountNumbersInBondsList(Order, FragmentSearch);
+  DoLog(0) && (Log() << Verbose(0) << "Total number of edges is " << SP << "." << endl);
+  if (SP >= (Order-1)) {
+    // start with root (push on fragment stack)
+    DoLog(0) && (Log() << Verbose(0) << "Starting fragment generation with " << *FragmentSearch.Root << ", local nr is " << FragmentSearch.Root->nr << "." << endl);
+    FragmentSearch.FragmentSet->clear();
+    DoLog(0) && (Log() << Verbose(0) << "Preparing subset for this root and calling generator." << endl);
+
+    // prepare the subset and call the generator
+    bond* BondsList[FragmentSearch.BondsPerSPCount[0]];
+    for(int i=0;i<FragmentSearch.BondsPerSPCount[0];i++)
+      BondsList[i] = NULL;
+    BondsList[0] = FragmentSearch.BondsPerSPList[0]->next;  // on SP level 0 there's only the root bond
+
+    SPFragmentGenerator(&FragmentSearch, 0, BondsList, FragmentSearch.BondsPerSPCount[0], Order);
+  } else {
+    DoLog(0) && (Log() << Verbose(0) << "Not enough total number of edges to build " << Order << "-body fragments." << endl);
+  }
+
+  // as FragmentSearch structure is used only once, we don't have to clean it anymore
+  // remove root from stack
+  DoLog(0) && (Log() << Verbose(0) << "Removing root again from stack." << endl);
+  FragmentSearch.FragmentSet->erase(FragmentSearch.Root->nr);
+
+  // free'ing the bonds lists
+  ResetSPList(Order, FragmentSearch);
+
+  // return list
+  DoLog(0) && (Log() << Verbose(0) << "End of PowerSetGenerator." << endl);
+  return (FragmentSearch.FragmentCounter - Counter);
+};
+
+bool KeyCompare::operator() (const KeySet SubgraphA, const KeySet SubgraphB) const
+{
+  //Log() << Verbose(0) << "my check is used." << endl;
+  if (SubgraphA.size() < SubgraphB.size()) {
+    return true;
+  } else {
+    if (SubgraphA.size() > SubgraphB.size()) {
+      return false;
+    } else {
+      KeySet::iterator IteratorA = SubgraphA.begin();
+      KeySet::iterator IteratorB = SubgraphB.begin();
+      while ((IteratorA != SubgraphA.end()) && (IteratorB != SubgraphB.end())) {
+        if ((*IteratorA) <  (*IteratorB))
+          return true;
+        else if ((*IteratorA) > (*IteratorB)) {
+            return false;
+          } // else, go on to next index
+        IteratorA++;
+        IteratorB++;
+      } // end of while loop
+    }// end of check in case of equal sizes
+  }
+  return false; // if we reach this point, they are equal
+};
+
+
+/** Combines all KeySets from all orders into single ones (with just unique entries).
+ * \param *out output stream for debugging
+ * \param *&FragmentList list to fill
+ * \param ***FragmentLowerOrdersList
+ * \param &RootStack stack with all root candidates (unequal to each atom in complete molecule if adaptive scheme is applied)
+ * \param *mol molecule with atoms and bonds
+ */
+int CombineAllOrderListIntoOne(Graph *&FragmentList, Graph ***FragmentLowerOrdersList, KeyStack &RootStack, molecule *mol)
+{
+  int RootNr = 0;
+  int RootKeyNr = 0;
+  int StartNr = 0;
+  int counter = 0;
+  int NumLevels = 0;
+  atom *Walker = NULL;
+
+  DoLog(0) && (Log() << Verbose(0) << "Combining the lists of all orders per order and finally into a single one." << endl);
+  if (FragmentList == NULL) {
+    FragmentList = new Graph;
+    counter = 0;
+  } else {
+    counter = FragmentList->size();
+  }
+
+  StartNr = RootStack.back();
+  do {
+    RootKeyNr = RootStack.front();
+    RootStack.pop_front();
+    Walker = mol->FindAtom(RootKeyNr);
+    NumLevels = 1 << (Walker->AdaptiveOrder - 1);
+    for(int i=0;i<NumLevels;i++) {
+      if (FragmentLowerOrdersList[RootNr][i] != NULL) {
+        InsertGraphIntoGraph(*FragmentList, (*FragmentLowerOrdersList[RootNr][i]), &counter);
+      }
+    }
+    RootStack.push_back(Walker->nr);
+    RootNr++;
+  } while (RootKeyNr != StartNr);
+  return counter;
+};
+
+/** Free's memory allocated for all KeySets from all orders.
+ * \param *out output stream for debugging
+ * \param ***FragmentLowerOrdersList
+ * \param &RootStack stack with all root candidates (unequal to each atom in complete molecule if adaptive scheme is applied)
+ * \param *mol molecule with atoms and bonds
+ */
+void FreeAllOrdersList(Graph ***FragmentLowerOrdersList, KeyStack &RootStack, molecule *mol)
+{
+  DoLog(1) && (Log() << Verbose(1) << "Free'ing the lists of all orders per order." << endl);
+  int RootNr = 0;
+  int RootKeyNr = 0;
+  int NumLevels = 0;
+  atom *Walker = NULL;
+  while (!RootStack.empty()) {
+    RootKeyNr = RootStack.front();
+    RootStack.pop_front();
+    Walker = mol->FindAtom(RootKeyNr);
+    NumLevels = 1 << (Walker->AdaptiveOrder - 1);
+    for(int i=0;i<NumLevels;i++) {
+      if (FragmentLowerOrdersList[RootNr][i] != NULL) {
+        delete(FragmentLowerOrdersList[RootNr][i]);
+      }
+    }
+    delete[](FragmentLowerOrdersList[RootNr]);
+    RootNr++;
+  }
+  delete[](FragmentLowerOrdersList);
+};
+
+
+/** Performs BOSSANOVA decomposition at selected sites, increasing the cutoff by one at these sites.
+ * -# constructs a complete keyset of the molecule
+ * -# In a loop over all possible roots from the given rootstack
+ *  -# increases order of root site
+ *  -# calls PowerSetGenerator with this order, the complete keyset and the rootkeynr
+ *  -# for all consecutive lower levels PowerSetGenerator is called with the suborder, the higher order keyset
+as the restricted one and each site in the set as the root)
+ *  -# these are merged into a fragment list of keysets
+ * -# All fragment lists (for all orders, i.e. from all destination fields) are merged into one list for return
+ * Important only is that we create all fragments, it is not important if we create them more than once
+ * as these copies are filtered out via use of the hash table (KeySet).
+ * \param *out output stream for debugging
+ * \param Fragment&*List list of already present keystacks (adaptive scheme) or empty list
+ * \param &RootStack stack with all root candidates (unequal to each atom in complete molecule if adaptive scheme is applied)
+ * \param *MinimumRingSize minimum ring size for each atom (molecule::Atomcount)
+ * \return pointer to Graph list
+ */
+void molecule::FragmentBOSSANOVA(Graph *&FragmentList, KeyStack &RootStack, int *MinimumRingSize)
+{
+  Graph ***FragmentLowerOrdersList = NULL;
+  int NumLevels = 0;
+  int NumMolecules = 0;
+  int TotalNumMolecules = 0;
+  int *NumMoleculesOfOrder = NULL;
+  int Order = 0;
+  int UpgradeCount = RootStack.size();
+  KeyStack FragmentRootStack;
+  int RootKeyNr = 0;
+  int RootNr = 0;
+  struct UniqueFragments FragmentSearch;
+
+  DoLog(0) && (Log() << Verbose(0) << "Begin of FragmentBOSSANOVA." << endl);
+
+  // FragmentLowerOrdersList is a 2D-array of pointer to MoleculeListClass objects, one dimension represents the ANOVA expansion of a single order (i.e. 5)
+  // with all needed lower orders that are subtracted, the other dimension is the BondOrder (i.e. from 1 to 5)
+  NumMoleculesOfOrder = new int[UpgradeCount];
+  FragmentLowerOrdersList = new Graph**[UpgradeCount];
+
+  for(int i=0;i<UpgradeCount;i++) {
+    NumMoleculesOfOrder[i] = 0;
+    FragmentLowerOrdersList[i] = NULL;
+  }
+
+  // initialise the fragments structure
+  FragmentSearch.FragmentCounter = 0;
+  FragmentSearch.FragmentSet = new KeySet;
+  FragmentSearch.Root = FindAtom(RootKeyNr);
+  FragmentSearch.ShortestPathList = new int[getAtomCount()];
+  for (int i=getAtomCount();i--;) {
+    FragmentSearch.ShortestPathList[i] = -1;
+  }
+
+  // Construct the complete KeySet which we need for topmost level only (but for all Roots)
+  KeySet CompleteMolecule;
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    CompleteMolecule.insert((*iter)->GetTrueFather()->nr);
+  }
+
+  // this can easily be seen: if Order is 5, then the number of levels for each lower order is the total sum of the number of levels above, as
+  // each has to be split up. E.g. for the second level we have one from 5th, one from 4th, two from 3th (which in turn is one from 5th, one from 4th),
+  // hence we have overall four 2th order levels for splitting. This also allows for putting all into a single array (FragmentLowerOrdersList[])
+  // with the order along the cells as this: 5433222211111111 for BondOrder 5 needing 16=pow(2,5-1) cells (only we use bit-shifting which is faster)
+  RootNr = 0;   // counts through the roots in RootStack
+  while ((RootNr < UpgradeCount) && (!RootStack.empty())) {
+    RootKeyNr = RootStack.front();
+    RootStack.pop_front();
+    atom *Walker = FindAtom(RootKeyNr);
+    // check cyclic lengths
+    //if ((MinimumRingSize[Walker->GetTrueFather()->nr] != -1) && (Walker->GetTrueFather()->AdaptiveOrder+1 > MinimumRingSize[Walker->GetTrueFather()->nr])) {
+    //  Log() << Verbose(0) << "Bond order " << Walker->GetTrueFather()->AdaptiveOrder << " of Root " << *Walker << " greater than or equal to Minimum Ring size of " << MinimumRingSize << " found is not allowed." << endl;
+    //} else
+    {
+      // increase adaptive order by one
+      Walker->GetTrueFather()->AdaptiveOrder++;
+      Order = Walker->AdaptiveOrder = Walker->GetTrueFather()->AdaptiveOrder;
+
+      // initialise Order-dependent entries of UniqueFragments structure
+      InitialiseSPList(Order, FragmentSearch);
+
+      // allocate memory for all lower level orders in this 1D-array of ptrs
+      NumLevels = 1 << (Order-1); // (int)pow(2,Order);
+      FragmentLowerOrdersList[RootNr] = new Graph*[NumLevels];
+      for (int i=0;i<NumLevels;i++)
+        FragmentLowerOrdersList[RootNr][i] = NULL;
+
+      // create top order where nothing is reduced
+      DoLog(0) && (Log() << Verbose(0) << "==============================================================================================================" << endl);
+      DoLog(0) && (Log() << Verbose(0) << "Creating KeySets of Bond Order " << Order << " for " << *Walker << ", " << (RootStack.size()-RootNr) << " Roots remaining." << endl); // , NumLevels is " << NumLevels << "
+
+      // Create list of Graphs of current Bond Order (i.e. F_{ij})
+      FragmentLowerOrdersList[RootNr][0] =  new Graph;
+      FragmentSearch.TEFactor = 1.;
+      FragmentSearch.Leaflet = FragmentLowerOrdersList[RootNr][0];      // set to insertion graph
+      FragmentSearch.Root = Walker;
+      NumMoleculesOfOrder[RootNr] = PowerSetGenerator(Walker->AdaptiveOrder, FragmentSearch, CompleteMolecule);
+
+      // output resulting number
+      DoLog(1) && (Log() << Verbose(1) << "Number of resulting KeySets is: " << NumMoleculesOfOrder[RootNr] << "." << endl);
+      if (NumMoleculesOfOrder[RootNr] != 0) {
+        NumMolecules = 0;
+      } else {
+        Walker->GetTrueFather()->MaxOrder = true;
+      }
+      // now, we have completely filled each cell of FragmentLowerOrdersList[] for the current Walker->AdaptiveOrder
+      //NumMoleculesOfOrder[Walker->AdaptiveOrder-1] = NumMolecules;
+      TotalNumMolecules += NumMoleculesOfOrder[RootNr];
+//      Log() << Verbose(1) << "Number of resulting molecules for Order " << (int)Walker->GetTrueFather()->AdaptiveOrder << " is: " << NumMoleculesOfOrder[RootNr] << "." << endl;
+      RootStack.push_back(RootKeyNr); // put back on stack
+      RootNr++;
+
+      // free Order-dependent entries of UniqueFragments structure for next loop cycle
+      FreeSPList(Order, FragmentSearch);
+    }
+  }
+  DoLog(0) && (Log() << Verbose(0) << "==============================================================================================================" << endl);
+  DoLog(1) && (Log() << Verbose(1) << "Total number of resulting molecules is: " << TotalNumMolecules << "." << endl);
+  DoLog(0) && (Log() << Verbose(0) << "==============================================================================================================" << endl);
+
+  // cleanup FragmentSearch structure
+  delete[](FragmentSearch.ShortestPathList);
+  delete(FragmentSearch.FragmentSet);
+
+  // now, FragmentLowerOrdersList is complete, it looks - for BondOrder 5 - as this (number is the ANOVA Order of the terms therein)
+  // 5433222211111111
+  // 43221111
+  // 3211
+  // 21
+  // 1
+
+  // Subsequently, we combine all into a single list (FragmentList)
+  CombineAllOrderListIntoOne(FragmentList, FragmentLowerOrdersList, RootStack, this);
+  FreeAllOrdersList(FragmentLowerOrdersList, RootStack, this);
+  delete[](NumMoleculesOfOrder);
+
+  DoLog(0) && (Log() << Verbose(0) << "End of FragmentBOSSANOVA." << endl);
+};
+
+/** Corrects the nuclei position if the fragment was created over the cell borders.
+ * Scans all bonds, checks the distance, if greater than typical, we have a candidate for the correction.
+ * We remove the bond whereafter the graph probably separates. Then, we translate the one component periodically
+ * and re-add the bond. Looping on the distance check.
+ * \param *out ofstream for debugging messages
+ */
+void molecule::ScanForPeriodicCorrection()
+{
+  bond *Binder = NULL;
+  bond *OtherBinder = NULL;
+  atom *Walker = NULL;
+  atom *OtherWalker = NULL;
+  double * const cell_size = World::getInstance().getDomain();
+  double *matrix = ReturnFullMatrixforSymmetric(cell_size);
+  enum Shading *ColorList = NULL;
+  double tmp;
+  Vector Translationvector;
+  //class StackClass<atom *> *CompStack = NULL;
+  class StackClass<atom *> *AtomStack = new StackClass<atom *>(getAtomCount());
+  bool flag = true;
+
+  DoLog(2) && (Log() << Verbose(2) << "Begin of ScanForPeriodicCorrection." << endl);
+
+  ColorList = new enum Shading[getAtomCount()];
+  for (int i=0;i<getAtomCount();i++)
+    ColorList[i] = (enum Shading)0;
+  while (flag) {
+    // remove bonds that are beyond bonddistance
+    Translationvector.Zero();
+    // scan all bonds
+    flag = false;
+    for(molecule::iterator AtomRunner = begin(); (!flag) && (AtomRunner != end()); ++AtomRunner)
+      for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); (!flag) && (BondRunner != (*AtomRunner)->ListOfBonds.end()); ++BondRunner) {
+        Binder = (*BondRunner);
+        for (int i=NDIM;i--;) {
+          tmp = fabs(Binder->leftatom->x[i] - Binder->rightatom->x[i]);
+          //Log() << Verbose(3) << "Checking " << i << "th distance of " << *Binder->leftatom << " to " << *Binder->rightatom << ": " << tmp << "." << endl;
+          if (tmp > BondDistance) {
+            OtherBinder = Binder->next; // note down binding partner for later re-insertion
+            unlink(Binder);   // unlink bond
+            DoLog(2) && (Log() << Verbose(2) << "Correcting at bond " << *Binder << "." << endl);
+            flag = true;
+            break;
+          }
+        }
+      }
+    if (flag) {
+      // create translation vector from their periodically modified distance
+      for (int i=NDIM;i--;) {
+        tmp = Binder->leftatom->x[i] - Binder->rightatom->x[i];
+        if (fabs(tmp) > BondDistance)
+          Translationvector[i] = (tmp < 0) ? +1. : -1.;
+      }
+      Translationvector.MatrixMultiplication(matrix);
+      //Log() << Verbose(3) << "Translation vector is ";
+      Log() << Verbose(0) << Translationvector <<  endl;
+      // apply to all atoms of first component via BFS
+      for (int i=getAtomCount();i--;)
+        ColorList[i] = white;
+      AtomStack->Push(Binder->leftatom);
+      while (!AtomStack->IsEmpty()) {
+        Walker = AtomStack->PopFirst();
+        //Log() << Verbose (3) << "Current Walker is: " << *Walker << "." << endl;
+        ColorList[Walker->nr] = black;    // mark as explored
+        Walker->x += Translationvector; // translate
+        for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
+          if ((*Runner) != Binder) {
+            OtherWalker = (*Runner)->GetOtherAtom(Walker);
+            if (ColorList[OtherWalker->nr] == white) {
+              AtomStack->Push(OtherWalker); // push if yet unexplored
+            }
+          }
+        }
+      }
+      // re-add bond
+      link(Binder, OtherBinder);
+    } else {
+      DoLog(3) && (Log() << Verbose(3) << "No corrections for this fragment." << endl);
+    }
+    //delete(CompStack);
+  }
+  // free allocated space from ReturnFullMatrixforSymmetric()
+  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 ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/molecule_geometry.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,586 @@
+/*
+ * molecule_geometry.cpp
+ *
+ *  Created on: Oct 5, 2009
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "atom.hpp"
+#include "bond.hpp"
+#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 <boost/foreach.hpp>
+
+
+/************************************* Functions for class molecule *********************************/
+
+
+/** Centers the molecule in the box whose lengths are defined by vector \a *BoxLengths.
+ * \param *out output stream for debugging
+ */
+bool molecule::CenterInBox()
+{
+  bool status = true;
+  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);
+  delete(Center);
+  delete(CenterBox);
+  return status;
+};
+
+
+/** Bounds the molecule in the box whose lengths are defined by vector \a *BoxLengths.
+ * \param *out output stream for debugging
+ */
+bool molecule::BoundInBox()
+{
+  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);
+  return status;
+};
+
+/** Centers the edge of the atoms at (0,0,0).
+ * \param *out output stream for debugging
+ * \param *max coordinates of other edge, specifying box dimensions.
+ */
+void molecule::CenterEdge(Vector *max)
+{
+  Vector *min = new Vector;
+
+//  Log() << Verbose(3) << "Begin of CenterEdge." << endl;
+  molecule::const_iterator iter = begin();  // start at first in list
+  if (iter != end()) { //list not empty?
+    for (int i=NDIM;i--;) {
+      max->at(i) = (*iter)->x[i];
+      min->at(i) = (*iter)->x[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);
+      }
+    }
+//    Log() << Verbose(4) << "Maximum is ";
+//    max->Output(out);
+//    Log() << Verbose(0) << ", Minimum is ";
+//    min->Output(out);
+//    Log() << Verbose(0) << endl;
+    min->Scale(-1.);
+    (*max) += (*min);
+    Translate(min);
+    Center.Zero();
+  }
+  delete(min);
+//  Log() << Verbose(3) << "End of CenterEdge." << endl;
+};
+
+/** Centers the center of the atoms at (0,0,0).
+ * \param *out output stream for debugging
+ * \param *center return vector for translation vector
+ */
+void molecule::CenterOrigin()
+{
+  int Num = 0;
+  molecule::const_iterator iter = begin();  // start at first in list
+
+  Center.Zero();
+
+  if (iter != end()) {   //list not empty?
+    for (; iter != end(); ++iter) {  // continue with second if present
+      Num++;
+      Center += (*iter)->x;
+    }
+    Center.Scale(-1./(double)Num); // divide through total number (and sign for direction)
+    Translate(&Center);
+    Center.Zero();
+  }
+};
+
+/** Returns vector pointing to center of all atoms.
+ * \return pointer to center of all vector
+ */
+Vector * molecule::DetermineCenterOfAll() const
+{
+  molecule::const_iterator iter = begin();  // start at first in list
+  Vector *a = new Vector();
+  double Num = 0;
+
+  a->Zero();
+
+  if (iter != end()) {   //list not empty?
+    for (; iter != end(); ++iter) {  // continue with second if present
+      Num++;
+      (*a) += (*iter)->x;
+    }
+    a->Scale(1./(double)Num); // divide through total mass (and sign for direction)
+  }
+  return a;
+};
+
+/** Returns vector pointing to center of the domain.
+ * \return pointer to center of the domain
+ */
+Vector * molecule::DetermineCenterOfBox() const
+{
+  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);
+
+  return a;
+};
+
+/** Returns vector pointing to center of gravity.
+ * \param *out output stream for debugging
+ * \return pointer to center of gravity vector
+ */
+Vector * molecule::DetermineCenterOfGravity()
+{
+  molecule::const_iterator iter = begin();  // start at first in list
+  Vector *a = new Vector();
+  Vector tmp;
+  double Num = 0;
+
+  a->Zero();
+
+  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;
+      (*a) += tmp;
+    }
+    a->Scale(1./Num); // divide through total mass
+  }
+//  Log() << Verbose(1) << "Resulting center of gravity: ";
+//  a->Output(out);
+//  Log() << Verbose(0) << endl;
+  return a;
+};
+
+/** Centers the center of gravity of the atoms at (0,0,0).
+ * \param *out output stream for debugging
+ * \param *center return vector for translation vector
+ */
+void molecule::CenterPeriodic()
+{
+  DeterminePeriodicCenter(Center);
+};
+
+
+/** Centers the center of gravity of the atoms at (0,0,0).
+ * \param *out output stream for debugging
+ * \param *center return vector for translation vector
+ */
+void molecule::CenterAtVector(Vector *newcenter)
+{
+  Center = *newcenter;
+};
+
+
+/** Scales all atoms by \a *factor.
+ * \param *factor pointer to scaling factor
+ *
+ * TODO: Is this realy what is meant, i.e.
+ * x=(x[0]*factor[0],x[1]*factor[1],x[2]*factor[2]) (current impl)
+ * or rather
+ * x=(**factor) * x (as suggested by comment)
+ */
+void molecule::Scale(const double ** const factor)
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    for (int j=0;j<MDSteps;j++)
+      (*iter)->Trajectory.R.at(j).ScaleAll(*factor);
+    (*iter)->x.ScaleAll(*factor);
+  }
+};
+
+/** Translate all atoms by given vector.
+ * \param trans[] translation vector.
+ */
+void molecule::Translate(const Vector *trans)
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    for (int j=0;j<MDSteps;j++)
+      (*iter)->Trajectory.R.at(j) += (*trans);
+    (*iter)->x += (*trans);
+  }
+};
+
+/** Translate the molecule periodically in the box.
+ * \param trans[] translation vector.
+ * TODO treatment of trajetories missing
+ */
+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);
+};
+
+
+/** Mirrors all atoms against a given plane.
+ * \param n[] normal vector of mirror plane.
+ */
+void molecule::Mirror(const Vector *n)
+{
+  OBSERVE;
+  Plane p(*n,0);
+  BOOST_FOREACH( atom* iter, atoms ){
+    (*iter->node) = p.mirrorVector(*iter->node);
+  }
+};
+
+/** Determines center of molecule (yet not considering atom masses).
+ * \param center reference to return vector
+ */
+void molecule::DeterminePeriodicCenter(Vector &center)
+{
+  double * const cell_size = World::getInstance().getDomain();
+  double *matrix = ReturnFullMatrixforSymmetric(cell_size);
+  double *inversematrix = InverseMatrix(matrix);
+  double tmp;
+  bool flag;
+  Vector Testvector, Translationvector;
+
+  do {
+    Center.Zero();
+    flag = true;
+    for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+#ifdef ADDHYDROGEN
+      if ((*iter)->type->Z != 1) {
+#endif
+        Testvector = (*iter)->x;
+        Testvector.MatrixMultiplication(inversematrix);
+        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];
+              if ((fabs(tmp)) > BondDistance) {
+                flag = false;
+                DoLog(0) && (Log() << Verbose(0) << "Hit: atom " << (*iter)->getName() << " in bond " << *(*Runner) << " has to be shifted due to " << tmp << "." << endl);
+                if (tmp > 0)
+                  Translationvector[j] -= 1.;
+                else
+                  Translationvector[j] += 1.;
+              }
+            }
+        }
+        Testvector += Translationvector;
+        Testvector.MatrixMultiplication(matrix);
+        Center += Testvector;
+        Log() << Verbose(1) << "vector is: " << Testvector << endl;
+#ifdef ADDHYDROGEN
+        // 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);
+            Testvector += Translationvector;
+            Testvector.MatrixMultiplication(matrix);
+            Center += Testvector;
+            Log() << Verbose(1) << "Hydrogen vector is: " << Testvector << endl;
+          }
+        }
+      }
+#endif
+    }
+  } 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);
+};
+
+
+/** Align all atoms in such a manner that given vector \a *n is along z axis.
+ * \param n[] alignment vector.
+ */
+void molecule::Align(Vector *n)
+{
+  double alpha, tmp;
+  Vector z_axis;
+  z_axis[0] = 0.;
+  z_axis[1] = 0.;
+  z_axis[2] = 1.;
+
+  // rotate on z-x plane
+  DoLog(0) && (Log() << Verbose(0) << "Begin of Aligning all atoms." << endl);
+  alpha = atan(-n->at(0)/n->at(2));
+  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];
+    for (int j=0;j<MDSteps;j++) {
+      tmp = (*iter)->Trajectory.R.at(j)[0];
+      (*iter)->Trajectory.R.at(j)[0] =  cos(alpha) * tmp + sin(alpha) * (*iter)->Trajectory.R.at(j)[2];
+      (*iter)->Trajectory.R.at(j)[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->Trajectory.R.at(j)[2];
+    }
+  }
+  // rotate n vector
+  tmp = n->at(0);
+  n->at(0) =  cos(alpha) * tmp +  sin(alpha) * n->at(2);
+  n->at(2) = -sin(alpha) * tmp +  cos(alpha) * n->at(2);
+  DoLog(1) && (Log() << Verbose(1) << "alignment vector after first rotation: " << n << endl);
+
+  // rotate on z-y plane
+  alpha = atan(-n->at(1)/n->at(2));
+  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];
+    for (int j=0;j<MDSteps;j++) {
+      tmp = (*iter)->Trajectory.R.at(j)[1];
+      (*iter)->Trajectory.R.at(j)[1] =  cos(alpha) * tmp + sin(alpha) * (*iter)->Trajectory.R.at(j)[2];
+      (*iter)->Trajectory.R.at(j)[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->Trajectory.R.at(j)[2];
+    }
+  }
+  // rotate n vector (for consistency check)
+  tmp = n->at(1);
+  n->at(1) =  cos(alpha) * tmp +  sin(alpha) * n->at(2);
+  n->at(2) = -sin(alpha) * tmp +  cos(alpha) * n->at(2);
+
+
+  DoLog(1) && (Log() << Verbose(1) << "alignment vector after second rotation: " << n << endl);
+  DoLog(0) && (Log() << Verbose(0) << "End of Aligning all atoms." << endl);
+};
+
+
+/** Calculates sum over least square distance to line hidden in \a *x.
+ * \param *x offset and direction vector
+ * \param *params pointer to lsq_params structure
+ * \return \f$ sum_i^N | y_i - (a + t_i b)|^2\f$
+ */
+double LeastSquareDistance (const gsl_vector * x, void * params)
+{
+  double res = 0, t;
+  Vector a,b,c,d;
+  struct lsq_params *par = (struct lsq_params *)params;
+
+  // initialize vectors
+  a[0] = gsl_vector_get(x,0);
+  a[1] = gsl_vector_get(x,1);
+  a[2] = gsl_vector_get(x,2);
+  b[0] = gsl_vector_get(x,3);
+  b[1] = gsl_vector_get(x,4);
+  b[2] = gsl_vector_get(x,5);
+  // 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;
+      t = c.ScalarProduct(b);           // get direction parameter
+      d = t*b;       // and create vector
+      c -= d;   // ... yielding distance vector
+      res += d.ScalarProduct(d);        // add squared distance
+    }
+  }
+  return res;
+};
+
+/** By minimizing the least square distance gains alignment vector.
+ * \bug this is not yet working properly it seems
+ */
+void molecule::GetAlignvector(struct lsq_params * par) const
+{
+    int np = 6;
+
+   const gsl_multimin_fminimizer_type *T =
+     gsl_multimin_fminimizer_nmsimplex;
+   gsl_multimin_fminimizer *s = NULL;
+   gsl_vector *ss;
+   gsl_multimin_function minex_func;
+
+   size_t iter = 0, i;
+   int status;
+   double size;
+
+   /* Initial vertex size vector */
+   ss = gsl_vector_alloc (np);
+
+   /* Set all step sizes to 1 */
+   gsl_vector_set_all (ss, 1.0);
+
+   /* Starting point */
+   par->x = gsl_vector_alloc (np);
+   par->mol = this;
+
+   gsl_vector_set (par->x, 0, 0.0);  // offset
+   gsl_vector_set (par->x, 1, 0.0);
+   gsl_vector_set (par->x, 2, 0.0);
+   gsl_vector_set (par->x, 3, 0.0);  // direction
+   gsl_vector_set (par->x, 4, 0.0);
+   gsl_vector_set (par->x, 5, 1.0);
+
+   /* Initialize method and iterate */
+   minex_func.f = &LeastSquareDistance;
+   minex_func.n = np;
+   minex_func.params = (void *)par;
+
+   s = gsl_multimin_fminimizer_alloc (T, np);
+   gsl_multimin_fminimizer_set (s, &minex_func, par->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)
+         {
+           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=0;i<(size_t)np;i++)
+    gsl_vector_set(par->x, i, gsl_vector_get(s->x, i));
+   //gsl_vector_free(par->x);
+   gsl_vector_free(ss);
+   gsl_multimin_fminimizer_free (s);
+};
Index: src/molecule_graph.cpp
===================================================================
--- src/molecule_graph.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/molecule_graph.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,1526 @@
+/*
+ * molecule_graph.cpp
+ *
+ *  Created on: Oct 5, 2009
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "atom.hpp"
+#include "bond.hpp"
+#include "bondgraph.hpp"
+#include "config.hpp"
+#include "defs.hpp"
+#include "element.hpp"
+#include "helpers.hpp"
+#include "info.hpp"
+#include "linkedcell.hpp"
+#include "lists.hpp"
+#include "log.hpp"
+#include "memoryallocator.hpp"
+#include "molecule.hpp"
+#include "World.hpp"
+#include "Helpers/fast_functions.hpp"
+#include "Helpers/Assert.hpp"
+
+
+struct BFSAccounting
+{
+  atom **PredecessorList;
+  int *ShortestPathList;
+  enum Shading *ColorList;
+  class StackClass<atom *> *BFSStack;
+  class StackClass<atom *> *TouchedStack;
+  int AtomCount;
+  int BondOrder;
+  atom *Root;
+  bool BackStepping;
+  int CurrentGraphNr;
+  int ComponentNr;
+};
+
+/** Accounting data for Depth First Search.
+ */
+struct DFSAccounting
+{
+  class StackClass<atom *> *AtomStack;
+  class StackClass<bond *> *BackEdgeStack;
+  int CurrentGraphNr;
+  int ComponentNumber;
+  atom *Root;
+  bool BackStepping;
+};
+
+/************************************* Functions for class molecule *********************************/
+
+/** Creates an adjacency list of the molecule.
+ * We obtain an outside file with the indices of atoms which are bondmembers.
+ */
+void molecule::CreateAdjacencyListFromDbondFile(ifstream *input)
+{
+  Info FunctionInfo(__func__);
+  // 1 We will parse bonds out of the dbond file created by tremolo.
+  int atom1, atom2;
+  atom *Walker, *OtherWalker;
+  char line[MAXSTRINGSIZE];
+
+  if (input->fail()) {
+    DoeLog(0) && (eLog() << Verbose(0) << "Opening of bond file failed \n");
+    performCriticalExit();
+  };
+  doCountAtoms();
+
+  // skip header
+  input->getline(line,MAXSTRINGSIZE);
+  DoLog(1) && (Log() << Verbose(1) << "Scanning file ... \n");
+  while (!input->eof()) // Check whether we read everything already
+  {
+    input->getline(line,MAXSTRINGSIZE);
+    stringstream zeile(line);
+    zeile >> atom1;
+    zeile >> atom2;
+
+    DoLog(2) && (Log() << Verbose(2) << "Looking for atoms " << atom1 << " and " << atom2 << "." << endl);
+    if (atom2 < atom1) //Sort indices of atoms in order
+      flip(atom1, atom2);
+    Walker = FindAtom(atom1);
+    ASSERT(Walker,"Could not find an atom with the ID given in dbond file");
+    OtherWalker = FindAtom(atom2);
+    ASSERT(OtherWalker,"Could not find an atom with the ID given in dbond file");
+    AddBond(Walker, OtherWalker); //Add the bond between the two atoms with respective indices.
+  }
+}
+;
+
+/** Creates an adjacency list of the molecule.
+ * Generally, we use the CSD approach to bond recognition, that is the the distance
+ * between two atoms A and B must be within [Rcov(A)+Rcov(B)-t,Rcov(A)+Rcov(B)+t] with
+ * a threshold t = 0.4 Angstroem.
+ * To make it O(N log N) the function uses the linked-cell technique as follows:
+ * The procedure is step-wise:
+ *  -# Remove every bond in list
+ *  -# Count the atoms in the molecule with CountAtoms()
+ *  -# partition cell into smaller linked cells of size \a bonddistance
+ *  -# put each atom into its corresponding cell
+ *  -# go through every cell, check the atoms therein against all possible bond partners in the 27 adjacent cells, add bond if true
+ *  -# correct the bond degree iteratively (single->double->triple bond)
+ *  -# finally print the bond list to \a *out if desired
+ * \param *out out stream for printing the matrix, NULL if no output
+ * \param bonddistance length of linked cells (i.e. maximum minimal length checked)
+ * \param IsAngstroem whether coordinate system is gauged to Angstroem or Bohr radii
+ * \param *minmaxdistance function to give upper and lower bound on whether particle is bonded to some other
+ * \param *BG BondGraph with the member function above or NULL, if just standard covalent should be used.
+ */
+void molecule::CreateAdjacencyList(double bonddistance, bool IsAngstroem, void (BondGraph::*minmaxdistance)(BondedParticle * const , BondedParticle * const , double &, double &, bool), BondGraph *BG)
+{
+  atom *Walker = NULL;
+  atom *OtherWalker = NULL;
+  int n[NDIM];
+  double MinDistance, MaxDistance;
+  LinkedCell *LC = NULL;
+  bool free_BG = false;
+  double * const cell_size = World::getInstance().getDomain();
+
+  if (BG == NULL) {
+    BG = new BondGraph(IsAngstroem);
+    free_BG = true;
+  }
+
+  BondDistance = bonddistance; // * ((IsAngstroem) ? 1. : 1./AtomicLengthToAngstroem);
+  DoLog(0) && (Log() << Verbose(0) << "Begin of CreateAdjacencyList." << endl);
+  // remove every bond from the list
+  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)
+        delete((*BondRunner));
+  BondCount = 0;
+
+  // count atoms in molecule = dimension of matrix (also give each unique name and continuous numbering)
+  DoLog(1) && (Log() << Verbose(1) << "AtomCount " << getAtomCount() << " and bonddistance is " << bonddistance << "." << endl);
+
+  if ((getAtomCount() > 1) && (bonddistance > 1.)) {
+    DoLog(2) && (Log() << Verbose(2) << "Creating Linked Cell structure ... " << endl);
+    LC = new LinkedCell(this, bonddistance);
+
+    // create a list to map Tesselpoint::nr to atom *
+    DoLog(2) && (Log() << Verbose(2) << "Creating TesselPoint to atom map ... " << endl);
+
+    // set numbers for atoms that can later be used
+    int i=0;
+    for(internal_iterator iter = atoms.begin();iter!= atoms.end(); ++iter){
+      (*iter)->nr = i++;
+    }
+
+    // 3a. go through every cell
+    DoLog(2) && (Log() << Verbose(2) << "Celling ... " << endl);
+    for (LC->n[0] = 0; LC->n[0] < LC->N[0]; LC->n[0]++)
+      for (LC->n[1] = 0; LC->n[1] < LC->N[1]; LC->n[1]++)
+        for (LC->n[2] = 0; LC->n[2] < LC->N[2]; LC->n[2]++) {
+          const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
+//          Log() << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;
+          if (List != NULL) {
+            for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
+              Walker = dynamic_cast<atom*>(*Runner);
+              ASSERT(Walker,"Tesselpoint that was not an atom retrieved from LinkedNode");
+              //Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl;
+              // 3c. check for possible bond between each atom in this and every one in the 27 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]++) {
+                    const LinkedCell::LinkedNodes *OtherList = LC->GetRelativeToCurrentCell(n);
+//                    Log() << Verbose(2) << "Current relative cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;
+                    if (OtherList != NULL) {
+                      for (LinkedCell::LinkedNodes::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) {
+                        if ((*OtherRunner)->nr > Walker->nr) {
+                          OtherWalker = dynamic_cast<atom*>(*OtherRunner);
+                          ASSERT(OtherWalker,"TesselPoint that was not an atom retrieved from LinkedNode");
+                          //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 bool status = (distance <= MaxDistance * MaxDistance) && (distance >= MinDistance * MinDistance);
+//                          Log() << Verbose(1) << "MinDistance is " << MinDistance << " and MaxDistance is " << MaxDistance << "." << endl;
+                          if (OtherWalker->father->nr > Walker->father->nr) {
+                            if (status) { // create bond if distance is smaller
+//                              Log() << Verbose(1) << "Adding Bond between " << *Walker << " and " << *OtherWalker << " in distance " << sqrt(distance) << "." << endl;
+                              AddBond(Walker->father, OtherWalker->father, 1); // also increases molecule::BondCount
+                            } else {
+//                              Log() << Verbose(1) << "Not Adding: distance too great." << endl;
+                            }
+                          } else {
+//                            Log() << Verbose(1) << "Not Adding: Wrong order of labels." << endl;
+                          }
+                        }
+                      }
+                    }
+                  }
+            }
+          }
+        }
+    delete (LC);
+    DoLog(1) && (Log() << Verbose(1) << "I detected " << BondCount << " bonds in the molecule with distance " << BondDistance << "." << endl);
+
+    // correct bond degree by comparing valence and bond degree
+    DoLog(2) && (Log() << Verbose(2) << "Correcting bond degree ... " << endl);
+    CorrectBondDegree();
+
+    // output bonds for debugging (if bond chain list was correctly installed)
+    ActOnAllAtoms( &atom::OutputBondOfAtom );
+  } else
+    DoLog(1) && (Log() << Verbose(1) << "AtomCount is " << getAtomCount() << ", thus no bonds, no connections!." << endl);
+  DoLog(0) && (Log() << Verbose(0) << "End of CreateAdjacencyList." << endl);
+  if (free_BG)
+    delete(BG);
+}
+;
+
+/** Checks for presence of bonds within atom list.
+ * TODO: more sophisticated check for bond structure (e.g. connected subgraph, ...)
+ * \return true - bonds present, false - no bonds
+ */
+bool molecule::hasBondStructure()
+{
+  for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
+    if (!(*AtomRunner)->ListOfBonds.empty())
+      return true;
+  return false;
+}
+
+/** Counts the number of present bonds.
+ * \return number of bonds
+ */
+unsigned int molecule::CountBonds() const
+{
+  unsigned int counter = 0;
+  for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
+    for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
+      if ((*BondRunner)->leftatom == *AtomRunner)
+        counter++;
+  return counter;
+}
+
+/** Prints a list of all bonds to \a *out.
+ * \param output stream
+ */
+void molecule::OutputBondsList() const
+{
+  DoLog(1) && (Log() << Verbose(1) << endl << "From contents of bond chain list:");
+  for(molecule::const_iterator AtomRunner = molecule::begin(); AtomRunner != molecule::end(); ++AtomRunner)
+    for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
+      if ((*BondRunner)->leftatom == *AtomRunner) {
+        DoLog(0) && (Log() << Verbose(0) << *(*BondRunner) << "\t" << endl);
+      }
+  DoLog(0) && (Log() << Verbose(0) << endl);
+}
+;
+
+/** correct bond degree by comparing valence and bond degree.
+ * correct Bond degree of each bond by checking both bond partners for a mismatch between valence and current sum of bond degrees,
+ * iteratively increase the one first where the other bond partner has the fewest number of bonds (i.e. in general bonds oxygene
+ * preferred over carbon bonds). Beforehand, we had picked the first mismatching partner, which lead to oxygenes with single instead of
+ * double bonds as was expected.
+ * \param *out output stream for debugging
+ * \return number of bonds that could not be corrected
+ */
+int molecule::CorrectBondDegree() const
+{
+  int No = 0, OldNo = -1;
+
+  if (BondCount != 0) {
+    DoLog(1) && (Log() << Verbose(1) << "Correcting Bond degree of each bond ... " << endl);
+    do {
+      OldNo = No;
+      No = SumPerAtom( &atom::CorrectBondDegree );
+    } while (OldNo != No);
+    DoLog(0) && (Log() << Verbose(0) << " done." << endl);
+  } else {
+    DoLog(1) && (Log() << Verbose(1) << "BondCount is " << BondCount << ", no bonds between any of the " << getAtomCount() << " atoms." << endl);
+  }
+  DoLog(0) && (Log() << Verbose(0) << No << " bonds could not be corrected." << endl);
+
+  return (No);
+}
+;
+
+/** Counts all cyclic bonds and returns their number.
+ * \note Hydrogen bonds can never by cyclic, thus no check for that
+ * \param *out output stream for debugging
+ * \return number opf cyclic bonds
+ */
+int molecule::CountCyclicBonds()
+{
+  NoCyclicBonds = 0;
+  int *MinimumRingSize = NULL;
+  MoleculeLeafClass *Subgraphs = NULL;
+  class StackClass<bond *> *BackEdgeStack = NULL;
+  for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
+    if ((!(*AtomRunner)->ListOfBonds.empty()) && ((*(*AtomRunner)->ListOfBonds.begin())->Type == Undetermined)) {
+      DoLog(0) && (Log() << Verbose(0) << "No Depth-First-Search analysis performed so far, calling ..." << endl);
+      Subgraphs = DepthFirstSearchAnalysis(BackEdgeStack);
+      while (Subgraphs->next != NULL) {
+        Subgraphs = Subgraphs->next;
+        delete (Subgraphs->previous);
+      }
+      delete (Subgraphs);
+      delete[] (MinimumRingSize);
+      break;
+    }
+  for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
+    for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
+      if ((*BondRunner)->leftatom == *AtomRunner)
+        if ((*BondRunner)->Cyclic)
+          NoCyclicBonds++;
+  delete (BackEdgeStack);
+  return NoCyclicBonds;
+}
+;
+
+/** Returns Shading as a char string.
+ * \param color the Shading
+ * \return string of the flag
+ */
+string molecule::GetColor(enum Shading color) const
+{
+  switch (color) {
+    case white:
+      return "white";
+      break;
+    case lightgray:
+      return "lightgray";
+      break;
+    case darkgray:
+      return "darkgray";
+      break;
+    case black:
+      return "black";
+      break;
+    default:
+      return "uncolored";
+      break;
+  };
+}
+;
+
+/** Sets atom::GraphNr and atom::LowpointNr to BFSAccounting::CurrentGraphNr.
+ * \param *out output stream for debugging
+ * \param *Walker current node
+ * \param &BFS structure with accounting data for BFS
+ */
+void DepthFirstSearchAnalysis_SetWalkersGraphNr(atom *&Walker, struct DFSAccounting &DFS)
+{
+  if (!DFS.BackStepping) { // if we don't just return from (8)
+    Walker->GraphNr = DFS.CurrentGraphNr;
+    Walker->LowpointNr = DFS.CurrentGraphNr;
+    DoLog(1) && (Log() << Verbose(1) << "Setting Walker[" << Walker->getName() << "]'s number to " << Walker->GraphNr << " with Lowpoint " << Walker->LowpointNr << "." << endl);
+    DFS.AtomStack->Push(Walker);
+    DFS.CurrentGraphNr++;
+  }
+}
+;
+
+/** During DFS goes along unvisited bond and touches other atom.
+ * Sets bond::type, if
+ *  -# BackEdge: set atom::LowpointNr and push on \a BackEdgeStack
+ *  -# TreeEgde: set atom::Ancestor and continue with Walker along this edge
+ * Continue until molecule::FindNextUnused() finds no more unused bonds.
+ * \param *out output stream for debugging
+ * \param *mol molecule with atoms and finding unused bonds
+ * \param *&Binder current edge
+ * \param &DFS DFS accounting data
+ */
+void DepthFirstSearchAnalysis_ProbeAlongUnusedBond(const molecule * const mol, atom *&Walker, bond *&Binder, struct DFSAccounting &DFS)
+{
+  atom *OtherAtom = NULL;
+
+  do { // (3) if Walker has no unused egdes, go to (5)
+    DFS.BackStepping = false; // reset backstepping flag for (8)
+    if (Binder == NULL) // if we don't just return from (11), Binder is already set to next unused
+      Binder = mol->FindNextUnused(Walker);
+    if (Binder == NULL)
+      break;
+    DoLog(2) && (Log() << Verbose(2) << "Current Unused Bond is " << *Binder << "." << endl);
+    // (4) Mark Binder used, ...
+    Binder->MarkUsed(black);
+    OtherAtom = Binder->GetOtherAtom(Walker);
+    DoLog(2) && (Log() << Verbose(2) << "(4) OtherAtom is " << OtherAtom->getName() << "." << endl);
+    if (OtherAtom->GraphNr != -1) {
+      // (4a) ... if "other" atom has been visited (GraphNr != 0), set lowpoint to minimum of both, go to (3)
+      Binder->Type = BackEdge;
+      DFS.BackEdgeStack->Push(Binder);
+      Walker->LowpointNr = (Walker->LowpointNr < OtherAtom->GraphNr) ? Walker->LowpointNr : OtherAtom->GraphNr;
+      DoLog(3) && (Log() << Verbose(3) << "(4a) Visited: Setting Lowpoint of Walker[" << Walker->getName() << "] to " << Walker->LowpointNr << "." << endl);
+    } else {
+      // (4b) ... otherwise set OtherAtom as Ancestor of Walker and Walker as OtherAtom, go to (2)
+      Binder->Type = TreeEdge;
+      OtherAtom->Ancestor = Walker;
+      Walker = OtherAtom;
+      DoLog(3) && (Log() << Verbose(3) << "(4b) Not Visited: OtherAtom[" << OtherAtom->getName() << "]'s Ancestor is now " << OtherAtom->Ancestor->getName() << ", Walker is OtherAtom " << OtherAtom->getName() << "." << endl);
+      break;
+    }
+    Binder = NULL;
+  } while (1); // (3)
+}
+;
+
+/** Checks whether we have a new component.
+ * if atom::LowpointNr of \a *&Walker is greater than atom::GraphNr of its atom::Ancestor, we have a new component.
+ * Meaning that if we touch upon a node who suddenly has a smaller atom::LowpointNr than its ancestor, then we
+ * have a found a new branch in the graph tree.
+ * \param *out output stream for debugging
+ * \param *mol molecule with atoms and finding unused bonds
+ * \param *&Walker current node
+ * \param &DFS DFS accounting data
+ */
+void DepthFirstSearchAnalysis_CheckForaNewComponent(const molecule * const mol, atom *&Walker, struct DFSAccounting &DFS, MoleculeLeafClass *&LeafWalker)
+{
+  atom *OtherAtom = NULL;
+
+  // (5) if Ancestor of Walker is ...
+  DoLog(1) && (Log() << Verbose(1) << "(5) Number of Walker[" << Walker->getName() << "]'s Ancestor[" << Walker->Ancestor->getName() << "] is " << Walker->Ancestor->GraphNr << "." << endl);
+
+  if (Walker->Ancestor->GraphNr != DFS.Root->GraphNr) {
+    // (6)  (Ancestor of Walker is not Root)
+    if (Walker->LowpointNr < Walker->Ancestor->GraphNr) {
+      // (6a) set Ancestor's Lowpoint number to minimum of of its Ancestor and itself, go to Step(8)
+      Walker->Ancestor->LowpointNr = (Walker->Ancestor->LowpointNr < Walker->LowpointNr) ? Walker->Ancestor->LowpointNr : Walker->LowpointNr;
+      DoLog(2) && (Log() << Verbose(2) << "(6) Setting Walker[" << Walker->getName() << "]'s Ancestor[" << Walker->Ancestor->getName() << "]'s Lowpoint to " << Walker->Ancestor->LowpointNr << "." << endl);
+    } else {
+      // (7) (Ancestor of Walker is a separating vertex, remove all from stack till Walker (including), these and Ancestor form a component
+      Walker->Ancestor->SeparationVertex = true;
+      DoLog(2) && (Log() << Verbose(2) << "(7) Walker[" << Walker->getName() << "]'s Ancestor[" << Walker->Ancestor->getName() << "]'s is a separating vertex, creating component." << endl);
+      mol->SetNextComponentNumber(Walker->Ancestor, DFS.ComponentNumber);
+      DoLog(3) && (Log() << Verbose(3) << "(7) Walker[" << Walker->getName() << "]'s Ancestor's Compont is " << DFS.ComponentNumber << "." << endl);
+      mol->SetNextComponentNumber(Walker, DFS.ComponentNumber);
+      DoLog(3) && (Log() << Verbose(3) << "(7) Walker[" << Walker->getName() << "]'s Compont is " << DFS.ComponentNumber << "." << endl);
+      do {
+        OtherAtom = DFS.AtomStack->PopLast();
+        LeafWalker->Leaf->AddCopyAtom(OtherAtom);
+        mol->SetNextComponentNumber(OtherAtom, DFS.ComponentNumber);
+        DoLog(3) && (Log() << Verbose(3) << "(7) Other[" << OtherAtom->getName() << "]'s Compont is " << DFS.ComponentNumber << "." << endl);
+      } while (OtherAtom != Walker);
+      DFS.ComponentNumber++;
+    }
+    // (8) Walker becomes its Ancestor, go to (3)
+    DoLog(2) && (Log() << Verbose(2) << "(8) Walker[" << Walker->getName() << "] is now its Ancestor " << Walker->Ancestor->getName() << ", backstepping. " << endl);
+    Walker = Walker->Ancestor;
+    DFS.BackStepping = true;
+  }
+}
+;
+
+/** Cleans the root stack when we have found a component.
+ * If we are not DFSAccounting::BackStepping, then we clear the root stack by putting everything into a
+ * component down till we meet DFSAccounting::Root.
+ * \param *out output stream for debugging
+ * \param *mol molecule with atoms and finding unused bonds
+ * \param *&Walker current node
+ * \param *&Binder current edge
+ * \param &DFS DFS accounting data
+ */
+void DepthFirstSearchAnalysis_CleanRootStackDownTillWalker(const molecule * const mol, atom *&Walker, bond *&Binder, struct DFSAccounting &DFS, MoleculeLeafClass *&LeafWalker)
+{
+  atom *OtherAtom = NULL;
+
+  if (!DFS.BackStepping) { // coming from (8) want to go to (3)
+    // (9) remove all from stack till Walker (including), these and Root form a component
+    //DFS.AtomStack->Output(out);
+    mol->SetNextComponentNumber(DFS.Root, DFS.ComponentNumber);
+    DoLog(3) && (Log() << Verbose(3) << "(9) Root[" << DFS.Root->getName() << "]'s Component is " << DFS.ComponentNumber << "." << endl);
+    mol->SetNextComponentNumber(Walker, DFS.ComponentNumber);
+    DoLog(3) && (Log() << Verbose(3) << "(9) Walker[" << Walker->getName() << "]'s Component is " << DFS.ComponentNumber << "." << endl);
+    do {
+      OtherAtom = DFS.AtomStack->PopLast();
+      LeafWalker->Leaf->AddCopyAtom(OtherAtom);
+      mol->SetNextComponentNumber(OtherAtom, DFS.ComponentNumber);
+      DoLog(3) && (Log() << Verbose(3) << "(7) Other[" << OtherAtom->getName() << "]'s Compont is " << DFS.ComponentNumber << "." << endl);
+    } while (OtherAtom != Walker);
+    DFS.ComponentNumber++;
+
+    // (11) Root is separation vertex,  set Walker to Root and go to (4)
+    Walker = DFS.Root;
+    Binder = mol->FindNextUnused(Walker);
+    DoLog(1) && (Log() << Verbose(1) << "(10) Walker is Root[" << DFS.Root->getName() << "], next Unused Bond is " << Binder << "." << endl);
+    if (Binder != NULL) { // Root is separation vertex
+      DoLog(1) && (Log() << Verbose(1) << "(11) Root is a separation vertex." << endl);
+      Walker->SeparationVertex = true;
+    }
+  }
+}
+;
+
+/** Initializes DFSAccounting structure.
+ * \param *out output stream for debugging
+ * \param &DFS accounting structure to allocate
+ * \param *mol molecule with AtomCount, BondCount and all atoms
+ */
+void DepthFirstSearchAnalysis_Init(struct DFSAccounting &DFS, const molecule * const mol)
+{
+  DFS.AtomStack = new StackClass<atom *> (mol->getAtomCount());
+  DFS.CurrentGraphNr = 0;
+  DFS.ComponentNumber = 0;
+  DFS.BackStepping = false;
+  mol->ResetAllBondsToUnused();
+  mol->SetAtomValueToValue(-1, &atom::GraphNr);
+  mol->ActOnAllAtoms(&atom::InitComponentNr);
+  DFS.BackEdgeStack->ClearStack();
+}
+;
+
+/** Free's DFSAccounting structure.
+ * \param *out output stream for debugging
+ * \param &DFS accounting structure to free
+ */
+void DepthFirstSearchAnalysis_Finalize(struct DFSAccounting &DFS)
+{
+  delete (DFS.AtomStack);
+  // delete (DFS.BackEdgeStack); // DON'T free, see DepthFirstSearchAnalysis(), is returned as allocated
+}
+;
+
+/** Performs a Depth-First search on this molecule.
+ * Marks bonds in molecule as cyclic, bridge, ... and atoms as
+ * articulations points, ...
+ * We use the algorithm from [Even, Graph Algorithms, p.62].
+ * \param *out output stream for debugging
+ * \param *&BackEdgeStack NULL pointer to StackClass with all the found back edges, allocated and filled on return
+ * \return list of each disconnected subgraph as an individual molecule class structure
+ */
+MoleculeLeafClass * molecule::DepthFirstSearchAnalysis(class StackClass<bond *> *&BackEdgeStack) const
+{
+  struct DFSAccounting DFS;
+  BackEdgeStack = new StackClass<bond *> (BondCount);
+  DFS.BackEdgeStack = BackEdgeStack;
+  MoleculeLeafClass *SubGraphs = new MoleculeLeafClass(NULL);
+  MoleculeLeafClass *LeafWalker = SubGraphs;
+  int OldGraphNr = 0;
+  atom *Walker = NULL;
+  bond *Binder = NULL;
+
+  if (getAtomCount() == 0)
+    return SubGraphs;
+  DoLog(0) && (Log() << Verbose(0) << "Begin of DepthFirstSearchAnalysis" << endl);
+  DepthFirstSearchAnalysis_Init(DFS, this);
+
+  for (molecule::const_iterator iter = begin(); iter != end();) {
+    DFS.Root = *iter;
+    // (1) mark all edges unused, empty stack, set atom->GraphNr = -1 for all
+    DFS.AtomStack->ClearStack();
+
+    // put into new subgraph molecule and add this to list of subgraphs
+    LeafWalker = new MoleculeLeafClass(LeafWalker);
+    LeafWalker->Leaf = World::getInstance().createMolecule();
+    LeafWalker->Leaf->AddCopyAtom(DFS.Root);
+
+    OldGraphNr = DFS.CurrentGraphNr;
+    Walker = DFS.Root;
+    do { // (10)
+      do { // (2) set number and Lowpoint of Atom to i, increase i, push current atom
+        DepthFirstSearchAnalysis_SetWalkersGraphNr(Walker, DFS);
+
+        DepthFirstSearchAnalysis_ProbeAlongUnusedBond(this, Walker, Binder, DFS);
+
+        if (Binder == NULL) {
+          DoLog(2) && (Log() << Verbose(2) << "No more Unused Bonds." << endl);
+          break;
+        } else
+          Binder = NULL;
+      } while (1); // (2)
+
+      // if we came from backstepping, yet there were no more unused bonds, we end up here with no Ancestor, because Walker is Root! Then we are finished!
+      if ((Walker == DFS.Root) && (Binder == NULL))
+        break;
+
+      DepthFirstSearchAnalysis_CheckForaNewComponent(this, Walker, DFS, LeafWalker);
+
+      DepthFirstSearchAnalysis_CleanRootStackDownTillWalker(this, Walker, Binder, DFS, LeafWalker);
+
+    } while ((DFS.BackStepping) || (Binder != NULL)); // (10) halt only if Root has no unused edges
+
+    // 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);
+    DoLog(0) && (Log() << Verbose(0) << endl);
+
+    // step on to next root
+    while ((iter != end()) && ((*iter)->GraphNr != -1)) {
+      //Log() << Verbose(1) << "Current next subgraph root candidate is " << (*iter)->Name << "." << endl;
+      if ((*iter)->GraphNr != -1) // if already discovered, step on
+        iter++;
+    }
+  }
+  // set cyclic bond criterium on "same LP" basis
+  CyclicBondAnalysis();
+
+  OutputGraphInfoPerAtom();
+
+  OutputGraphInfoPerBond();
+
+  // free all and exit
+  DepthFirstSearchAnalysis_Finalize(DFS);
+  DoLog(0) && (Log() << Verbose(0) << "End of DepthFirstSearchAnalysis" << endl);
+  return SubGraphs;
+}
+;
+
+/** Scans through all bonds and set bond::Cyclic to true where atom::LowpointNr of both ends is equal: LP criterion.
+ */
+void molecule::CyclicBondAnalysis() const
+{
+  NoCyclicBonds = 0;
+  for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
+    for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
+      if ((*BondRunner)->leftatom == *AtomRunner)
+        if ((*BondRunner)->rightatom->LowpointNr == (*BondRunner)->leftatom->LowpointNr) { // cyclic ??
+          (*BondRunner)->Cyclic = true;
+          NoCyclicBonds++;
+        }
+}
+;
+
+/** Output graph information per atom.
+ * \param *out output stream
+ */
+void molecule::OutputGraphInfoPerAtom() const
+{
+  DoLog(1) && (Log() << Verbose(1) << "Final graph info for each atom is:" << endl);
+  ActOnAllAtoms( &atom::OutputGraphInfo );
+}
+;
+
+/** Output graph information per bond.
+ * \param *out output stream
+ */
+void molecule::OutputGraphInfoPerBond() const
+{
+  bond *Binder = NULL;
+  DoLog(1) && (Log() << Verbose(1) << "Final graph info for each bond is:" << endl);
+  for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
+    for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
+      if ((*BondRunner)->leftatom == *AtomRunner) {
+        Binder = *BondRunner;
+        DoLog(2) && (Log() << Verbose(2) << ((Binder->Type == TreeEdge) ? "TreeEdge " : "BackEdge ") << *Binder << ": <");
+        DoLog(0) && (Log() << Verbose(0) << ((Binder->leftatom->SeparationVertex) ? "SP," : "") << "L" << Binder->leftatom->LowpointNr << " G" << Binder->leftatom->GraphNr << " Comp.");
+        Binder->leftatom->OutputComponentNumber();
+        DoLog(0) && (Log() << Verbose(0) << " ===  ");
+        DoLog(0) && (Log() << Verbose(0) << ((Binder->rightatom->SeparationVertex) ? "SP," : "") << "L" << Binder->rightatom->LowpointNr << " G" << Binder->rightatom->GraphNr << " Comp.");
+        Binder->rightatom->OutputComponentNumber();
+        DoLog(0) && (Log() << Verbose(0) << ">." << endl);
+        if (Binder->Cyclic) // cyclic ??
+          DoLog(3) && (Log() << Verbose(3) << "Lowpoint at each side are equal: CYCLIC!" << endl);
+      }
+}
+;
+
+/** Initialise each vertex as white with no predecessor, empty queue, color Root lightgray.
+ * \param *out output stream for debugging
+ * \param &BFS accounting structure
+ * \param AtomCount number of entries in the array to allocate
+ */
+void InitializeBFSAccounting(struct BFSAccounting &BFS, int AtomCount)
+{
+  BFS.AtomCount = AtomCount;
+  BFS.PredecessorList = new atom*[AtomCount];
+  BFS.ShortestPathList = new int[AtomCount];
+  BFS.ColorList = new enum Shading[AtomCount];
+  BFS.BFSStack = new StackClass<atom *> (AtomCount);
+  BFS.TouchedStack = new StackClass<atom *> (AtomCount);
+
+  for (int i = AtomCount; i--;) {
+    BFS.ShortestPathList[i] = -1;
+    BFS.PredecessorList[i] = 0;
+    BFS.ColorList[i] = white;
+  }
+};
+
+/** Free's accounting structure.
+ * \param *out output stream for debugging
+ * \param &BFS accounting structure
+ */
+void FinalizeBFSAccounting(struct BFSAccounting &BFS)
+{
+  delete[](BFS.PredecessorList);
+  delete[](BFS.ShortestPathList);
+  delete[](BFS.ColorList);
+  delete (BFS.BFSStack);
+  delete (BFS.TouchedStack);
+  BFS.AtomCount = 0;
+};
+
+/** Clean the accounting structure.
+ * \param *out output stream for debugging
+ * \param &BFS accounting structure
+ */
+void CleanBFSAccounting(struct BFSAccounting &BFS)
+{
+  atom *Walker = NULL;
+  while (!BFS.TouchedStack->IsEmpty()) {
+    Walker = BFS.TouchedStack->PopFirst();
+    BFS.PredecessorList[Walker->nr] = NULL;
+    BFS.ShortestPathList[Walker->nr] = -1;
+    BFS.ColorList[Walker->nr] = white;
+  }
+};
+
+/** Resets shortest path list and BFSStack.
+ * \param *out output stream for debugging
+ * \param *&Walker current node, pushed onto BFSAccounting::BFSStack and BFSAccounting::TouchedStack
+ * \param &BFS accounting structure
+ */
+void ResetBFSAccounting(atom *&Walker, struct BFSAccounting &BFS)
+{
+  BFS.ShortestPathList[Walker->nr] = 0;
+  BFS.BFSStack->ClearStack(); // start with empty BFS stack
+  BFS.BFSStack->Push(Walker);
+  BFS.TouchedStack->Push(Walker);
+};
+
+/** Performs a BFS from \a *Root, trying to find the same node and hence a cycle.
+ * \param *out output stream for debugging
+ * \param *&BackEdge the edge from root that we don't want to move along
+ * \param &BFS accounting structure
+ */
+void CyclicStructureAnalysis_CyclicBFSFromRootToRoot(bond *&BackEdge, struct BFSAccounting &BFS)
+{
+  atom *Walker = NULL;
+  atom *OtherAtom = NULL;
+  do { // look for Root
+    Walker = BFS.BFSStack->PopFirst();
+    DoLog(2) && (Log() << Verbose(2) << "Current Walker is " << *Walker << ", we look for SP to Root " << *BFS.Root << "." << endl);
+    for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
+      if ((*Runner) != BackEdge) { // only walk along DFS spanning tree (otherwise we always find SP of one being backedge Binder)
+        OtherAtom = (*Runner)->GetOtherAtom(Walker);
+#ifdef ADDHYDROGEN
+        if (OtherAtom->type->Z != 1) {
+#endif
+        DoLog(2) && (Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->getName() << " for bond " << *(*Runner) << "." << endl);
+        if (BFS.ColorList[OtherAtom->nr] == white) {
+          BFS.TouchedStack->Push(OtherAtom);
+          BFS.ColorList[OtherAtom->nr] = lightgray;
+          BFS.PredecessorList[OtherAtom->nr] = Walker; // Walker is the predecessor
+          BFS.ShortestPathList[OtherAtom->nr] = BFS.ShortestPathList[Walker->nr] + 1;
+          DoLog(2) && (Log() << Verbose(2) << "Coloring OtherAtom " << OtherAtom->getName() << " lightgray, its predecessor is " << Walker->getName() << " and its Shortest Path is " << BFS.ShortestPathList[OtherAtom->nr] << " egde(s) long." << endl);
+          //if (BFS.ShortestPathList[OtherAtom->nr] < MinimumRingSize[Walker->GetTrueFather()->nr]) { // Check for maximum distance
+          DoLog(3) && (Log() << Verbose(3) << "Putting OtherAtom into queue." << endl);
+          BFS.BFSStack->Push(OtherAtom);
+          //}
+        } else {
+          DoLog(3) && (Log() << Verbose(3) << "Not Adding, has already been visited." << endl);
+        }
+        if (OtherAtom == BFS.Root)
+          break;
+#ifdef ADDHYDROGEN
+      } else {
+        DoLog(2) && (Log() << Verbose(2) << "Skipping hydrogen atom " << *OtherAtom << "." << endl);
+        BFS.ColorList[OtherAtom->nr] = black;
+      }
+#endif
+      } else {
+        DoLog(2) && (Log() << Verbose(2) << "Bond " << *(*Runner) << " not Visiting, is the back edge." << endl);
+      }
+    }
+    BFS.ColorList[Walker->nr] = black;
+    DoLog(1) && (Log() << Verbose(1) << "Coloring Walker " << Walker->getName() << " black." << endl);
+    if (OtherAtom == BFS.Root) { // if we have found the root, check whether this cycle wasn't already found beforehand
+      // step through predecessor list
+      while (OtherAtom != BackEdge->rightatom) {
+        if (!OtherAtom->GetTrueFather()->IsCyclic) // if one bond in the loop is not marked as cyclic, we haven't found this cycle yet
+          break;
+        else
+          OtherAtom = BFS.PredecessorList[OtherAtom->nr];
+      }
+      if (OtherAtom == BackEdge->rightatom) { // if each atom in found cycle is cyclic, loop's been found before already
+        DoLog(3) && (Log() << Verbose(3) << "This cycle was already found before, skipping and removing seeker from search." << endl);
+        do {
+          OtherAtom = BFS.TouchedStack->PopLast();
+          if (BFS.PredecessorList[OtherAtom->nr] == Walker) {
+            DoLog(4) && (Log() << Verbose(4) << "Removing " << *OtherAtom << " from lists and stacks." << endl);
+            BFS.PredecessorList[OtherAtom->nr] = NULL;
+            BFS.ShortestPathList[OtherAtom->nr] = -1;
+            BFS.ColorList[OtherAtom->nr] = white;
+            BFS.BFSStack->RemoveItem(OtherAtom);
+          }
+        } while ((!BFS.TouchedStack->IsEmpty()) && (BFS.PredecessorList[OtherAtom->nr] == NULL));
+        BFS.TouchedStack->Push(OtherAtom); // last was wrongly popped
+        OtherAtom = BackEdge->rightatom; // set to not Root
+      } else
+        OtherAtom = BFS.Root;
+    }
+  } while ((!BFS.BFSStack->IsEmpty()) && (OtherAtom != BFS.Root) && (OtherAtom != NULL)); // || (ShortestPathList[OtherAtom->nr] < MinimumRingSize[Walker->GetTrueFather()->nr])));
+};
+
+/** Climb back the BFSAccounting::PredecessorList and find cycle members.
+ * \param *out output stream for debugging
+ * \param *&OtherAtom
+ * \param *&BackEdge denotes the edge we did not want to travel along when doing CyclicBFSFromRootToRoot()
+ * \param &BFS accounting structure
+ * \param *&MinimumRingSize minimum distance from this node possible without encountering oneself, set on return for each atom
+ * \param &MinRingSize global minimum distance from one node without encountering oneself, set on return
+ */
+void CyclicStructureAnalysis_RetrieveCycleMembers(atom *&OtherAtom, bond *&BackEdge, struct BFSAccounting &BFS, int *&MinimumRingSize, int &MinRingSize)
+{
+  atom *Walker = NULL;
+  int NumCycles = 0;
+  int RingSize = -1;
+
+  if (OtherAtom == BFS.Root) {
+    // now climb back the predecessor list and thus find the cycle members
+    NumCycles++;
+    RingSize = 1;
+    BFS.Root->GetTrueFather()->IsCyclic = true;
+    DoLog(1) && (Log() << Verbose(1) << "Found ring contains: ");
+    Walker = BFS.Root;
+    while (Walker != BackEdge->rightatom) {
+      DoLog(0) && (Log() << Verbose(0) << Walker->getName() << " <-> ");
+      Walker = BFS.PredecessorList[Walker->nr];
+      Walker->GetTrueFather()->IsCyclic = true;
+      RingSize++;
+    }
+    DoLog(0) && (Log() << Verbose(0) << Walker->getName() << "  with a length of " << RingSize << "." << endl << endl);
+    // walk through all and set MinimumRingSize
+    Walker = BFS.Root;
+    MinimumRingSize[Walker->GetTrueFather()->nr] = RingSize;
+    while (Walker != BackEdge->rightatom) {
+      Walker = BFS.PredecessorList[Walker->nr];
+      if (RingSize < MinimumRingSize[Walker->GetTrueFather()->nr])
+        MinimumRingSize[Walker->GetTrueFather()->nr] = RingSize;
+    }
+    if ((RingSize < MinRingSize) || (MinRingSize == -1))
+      MinRingSize = RingSize;
+  } else {
+    DoLog(1) && (Log() << Verbose(1) << "No ring containing " << *BFS.Root << " with length equal to or smaller than " << MinimumRingSize[BFS.Root->GetTrueFather()->nr] << " found." << endl);
+  }
+};
+
+/** From a given node performs a BFS to touch the next cycle, for whose nodes \a *&MinimumRingSize is set and set it accordingly.
+ * \param *out output stream for debugging
+ * \param *&Root node to look for closest cycle from, i.e. \a *&MinimumRingSize is set for this node
+ * \param *&MinimumRingSize minimum distance from this node possible without encountering oneself, set on return for each atom
+ * \param AtomCount number of nodes in graph
+ */
+void CyclicStructureAnalysis_BFSToNextCycle(atom *&Root, atom *&Walker, int *&MinimumRingSize, int AtomCount)
+{
+  struct BFSAccounting BFS;
+  atom *OtherAtom = Walker;
+
+  InitializeBFSAccounting(BFS, AtomCount);
+
+  ResetBFSAccounting(Walker, BFS);
+  while (OtherAtom != NULL) { // look for Root
+    Walker = BFS.BFSStack->PopFirst();
+    //Log() << Verbose(2) << "Current Walker is " << *Walker << ", we look for SP to Root " << *Root << "." << endl;
+    for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
+      // "removed (*Runner) != BackEdge) || " from next if, is u
+      if ((Walker->ListOfBonds.size() == 1)) { // only walk along DFS spanning tree (otherwise we always find SP of 1 being backedge Binder), but terminal hydrogens may be connected via backedge, hence extra check
+        OtherAtom = (*Runner)->GetOtherAtom(Walker);
+        //Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->Name << " for bond " << *Binder << "." << endl;
+        if (BFS.ColorList[OtherAtom->nr] == white) {
+          BFS.TouchedStack->Push(OtherAtom);
+          BFS.ColorList[OtherAtom->nr] = lightgray;
+          BFS.PredecessorList[OtherAtom->nr] = Walker; // Walker is the predecessor
+          BFS.ShortestPathList[OtherAtom->nr] = BFS.ShortestPathList[Walker->nr] + 1;
+          //Log() << Verbose(2) << "Coloring OtherAtom " << OtherAtom->Name << " lightgray, its predecessor is " << Walker->Name << " and its Shortest Path is " << ShortestPathList[OtherAtom->nr] << " egde(s) long." << endl;
+          if (OtherAtom->GetTrueFather()->IsCyclic) { // if the other atom is connected to a ring
+            MinimumRingSize[Root->GetTrueFather()->nr] = BFS.ShortestPathList[OtherAtom->nr] + MinimumRingSize[OtherAtom->GetTrueFather()->nr];
+            OtherAtom = NULL; //break;
+            break;
+          } else
+            BFS.BFSStack->Push(OtherAtom);
+        } else {
+          //Log() << Verbose(3) << "Not Adding, has already been visited." << endl;
+        }
+      } else {
+        //Log() << Verbose(3) << "Not Visiting, is a back edge." << endl;
+      }
+    }
+    BFS.ColorList[Walker->nr] = black;
+    //Log() << Verbose(1) << "Coloring Walker " << Walker->Name << " black." << endl;
+  }
+  //CleanAccountingLists(TouchedStack, PredecessorList, ShortestPathList, ColorList);
+
+  FinalizeBFSAccounting(BFS);
+}
+;
+
+/** All nodes that are not in cycles get assigned a \a *&MinimumRingSizeby BFS to next cycle.
+ * \param *out output stream for debugging
+ * \param *&MinimumRingSize array with minimum distance without encountering onself for each atom
+ * \param &MinRingSize global minium distance
+ * \param &NumCyles number of cycles in graph
+ * \param *mol molecule with atoms
+ */
+void CyclicStructureAnalysis_AssignRingSizetoNonCycleMembers(int *&MinimumRingSize, int &MinRingSize, int &NumCycles, const molecule * const mol)
+{
+  atom *Root = NULL;
+  atom *Walker = NULL;
+  if (MinRingSize != -1) { // if rings are present
+    // go over all atoms
+    for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
+      Root = *iter;
+
+      if (MinimumRingSize[Root->GetTrueFather()->nr] == mol->getAtomCount()) { // check whether MinimumRingSize is set, if not BFS to next where it is
+        Walker = Root;
+
+        //Log() << Verbose(1) << "---------------------------------------------------------------------------------------------------------" << endl;
+        CyclicStructureAnalysis_BFSToNextCycle(Root, Walker, MinimumRingSize, mol->getAtomCount());
+
+      }
+      DoLog(1) && (Log() << Verbose(1) << "Minimum ring size of " << *Root << " is " << MinimumRingSize[Root->GetTrueFather()->nr] << "." << endl);
+    }
+    DoLog(1) && (Log() << Verbose(1) << "Minimum ring size is " << MinRingSize << ", over " << NumCycles << " cycles total." << endl);
+  } else
+    DoLog(1) && (Log() << Verbose(1) << "No rings were detected in the molecular structure." << endl);
+}
+;
+
+/** Analyses the cycles found and returns minimum of all cycle lengths.
+ * We begin with a list of Back edges found during DepthFirstSearchAnalysis(). We go through this list - one end is the Root,
+ * the other our initial Walker - and do a Breadth First Search for the Root. We mark down each Predecessor and as soon as
+ * we have found the Root via BFS, we may climb back the closed cycle via the Predecessors. Thereby we mark atoms and bonds
+ * as cyclic and print out the cycles.
+ * \param *out output stream for debugging
+ * \param *BackEdgeStack stack with all back edges found during DFS scan. Beware: This stack contains the bonds from the total molecule, not from the subgraph!
+ * \param *&MinimumRingSize contains smallest ring size in molecular structure on return or -1 if no rings were found, if set is maximum search distance
+ * \todo BFS from the not-same-LP to find back to starting point of tributary cycle over more than one bond
+ */
+void molecule::CyclicStructureAnalysis(class StackClass<bond *> * BackEdgeStack, int *&MinimumRingSize) const
+{
+  struct BFSAccounting BFS;
+  atom *Walker = NULL;
+  atom *OtherAtom = NULL;
+  bond *BackEdge = NULL;
+  int NumCycles = 0;
+  int MinRingSize = -1;
+
+  InitializeBFSAccounting(BFS, getAtomCount());
+
+  //Log() << Verbose(1) << "Back edge list - ";
+  //BackEdgeStack->Output(out);
+
+  DoLog(1) && (Log() << Verbose(1) << "Analysing cycles ... " << endl);
+  NumCycles = 0;
+  while (!BackEdgeStack->IsEmpty()) {
+    BackEdge = BackEdgeStack->PopFirst();
+    // this is the target
+    BFS.Root = BackEdge->leftatom;
+    // this is the source point
+    Walker = BackEdge->rightatom;
+
+    ResetBFSAccounting(Walker, BFS);
+
+    DoLog(1) && (Log() << Verbose(1) << "---------------------------------------------------------------------------------------------------------" << endl);
+    OtherAtom = NULL;
+    CyclicStructureAnalysis_CyclicBFSFromRootToRoot(BackEdge, BFS);
+
+    CyclicStructureAnalysis_RetrieveCycleMembers(OtherAtom, BackEdge, BFS, MinimumRingSize, MinRingSize);
+
+    CleanBFSAccounting(BFS);
+  }
+  FinalizeBFSAccounting(BFS);
+
+  CyclicStructureAnalysis_AssignRingSizetoNonCycleMembers(MinimumRingSize, MinRingSize, NumCycles, this);
+};
+
+/** Sets the next component number.
+ * This is O(N) as the number of bonds per atom is bound.
+ * \param *vertex atom whose next atom::*ComponentNr is to be set
+ * \param nr number to use
+ */
+void molecule::SetNextComponentNumber(atom *vertex, int nr) const
+{
+  size_t i = 0;
+  if (vertex != NULL) {
+    for (; i < vertex->ListOfBonds.size(); i++) {
+      if (vertex->ComponentNr[i] == -1) { // check if not yet used
+        vertex->ComponentNr[i] = nr;
+        break;
+      } else if (vertex->ComponentNr[i] == nr) // if number is already present, don't add another time
+        break; // breaking here will not cause error!
+    }
+    if (i == vertex->ListOfBonds.size()) {
+      DoeLog(0) && (eLog()<< Verbose(0) << "Error: All Component entries are already occupied!" << endl);
+      performCriticalExit();
+    }
+  } else {
+    DoeLog(0) && (eLog()<< Verbose(0) << "Error: Given vertex is NULL!" << endl);
+    performCriticalExit();
+  }
+}
+;
+
+/** Returns next unused bond for this atom \a *vertex or NULL of none exists.
+ * \param *vertex atom to regard
+ * \return bond class or NULL
+ */
+bond * molecule::FindNextUnused(atom *vertex) const
+{
+  for (BondList::const_iterator Runner = vertex->ListOfBonds.begin(); Runner != vertex->ListOfBonds.end(); (++Runner))
+    if ((*Runner)->IsUsed() == white)
+      return ((*Runner));
+  return NULL;
+}
+;
+
+/** Resets bond::Used flag of all bonds in this molecule.
+ * \return true - success, false - -failure
+ */
+void molecule::ResetAllBondsToUnused() const
+{
+  for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
+    for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
+      if ((*BondRunner)->leftatom == *AtomRunner)
+        (*BondRunner)->ResetUsed();
+}
+;
+
+/** Output a list of flags, stating whether the bond was visited or not.
+ * \param *out output stream for debugging
+ * \param *list
+ */
+void OutputAlreadyVisited(int *list)
+{
+  DoLog(4) && (Log() << Verbose(4) << "Already Visited Bonds:\t");
+  for (int i = 1; i <= list[0]; i++)
+    DoLog(0) && (Log() << Verbose(0) << list[i] << "  ");
+  DoLog(0) && (Log() << Verbose(0) << endl);
+}
+;
+
+/** Storing the bond structure of a molecule to file.
+ * Simply stores Atom::nr and then the Atom::nr of all bond partners per line.
+ * \param &filename name of file
+ * \param path path to file, defaults to empty
+ * \return true - file written successfully, false - writing failed
+ */
+bool molecule::StoreAdjacencyToFile(std::string &filename, std::string path)
+{
+  ofstream AdjacencyFile;
+  string line;
+  bool status = true;
+
+  if (path != "")
+    line = path + "/" + filename;
+  else
+    line = filename;
+  AdjacencyFile.open(line.c_str(), ios::out);
+  DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... " << endl);
+  if (AdjacencyFile.good()) {
+    AdjacencyFile << "m\tn" << endl;
+    ActOnAllAtoms(&atom::OutputAdjacency, &AdjacencyFile);
+    AdjacencyFile.close();
+    DoLog(1) && (Log() << Verbose(1) << "\t... done." << endl);
+  } else {
+    DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line << "." << endl);
+    status = false;
+  }
+
+  return status;
+}
+;
+
+/** Storing the bond structure of a molecule to file.
+ * Simply stores Atom::nr and then the Atom::nr of all bond partners, one per line.
+ * \param &filename name of file
+ * \param path path to file, defaults to empty
+ * \return true - file written successfully, false - writing failed
+ */
+bool molecule::StoreBondsToFile(std::string &filename, std::string path)
+{
+  ofstream BondFile;
+  string line;
+  bool status = true;
+
+  if (path != "")
+    line = path + "/" + filename;
+  else
+    line = filename;
+  BondFile.open(line.c_str(), ios::out);
+  DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... " << endl);
+  if (BondFile.good()) {
+    BondFile << "m\tn" << endl;
+    ActOnAllAtoms(&atom::OutputBonds, &BondFile);
+    BondFile.close();
+    DoLog(1) && (Log() << Verbose(1) << "\t... done." << endl);
+  } else {
+    DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line << "." << endl);
+    status = false;
+  }
+
+  return status;
+}
+;
+
+bool CheckAdjacencyFileAgainstMolecule_Init(std::string &path, ifstream &File, int *&CurrentBonds)
+{
+  string filename;
+  filename = path + ADJACENCYFILE;
+  File.open(filename.c_str(), ios::out);
+  DoLog(1) && (Log() << Verbose(1) << "Looking at bond structure stored in adjacency file and comparing to present one ... " << endl);
+  if (File.fail())
+    return false;
+
+  // allocate storage structure
+  CurrentBonds = new int[8]; // contains parsed bonds of current atom
+  for(int i=0;i<8;i++)
+    CurrentBonds[i] = 0;
+  return true;
+}
+;
+
+void CheckAdjacencyFileAgainstMolecule_Finalize(ifstream &File, int *&CurrentBonds)
+{
+  File.close();
+  File.clear();
+  delete[](CurrentBonds);
+}
+;
+
+void CheckAdjacencyFileAgainstMolecule_CompareBonds(bool &status, int &NonMatchNumber, atom *&Walker, size_t &CurrentBondsOfAtom, int AtomNr, int *&CurrentBonds, atom **ListOfAtoms)
+{
+  size_t j = 0;
+  int id = -1;
+
+  //Log() << Verbose(2) << "Walker is " << *Walker << ", bond partners: ";
+  if (CurrentBondsOfAtom == Walker->ListOfBonds.size()) {
+    for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
+      id = (*Runner)->GetOtherAtom(Walker)->nr;
+      j = 0;
+      for (; (j < CurrentBondsOfAtom) && (CurrentBonds[j++] != id);)
+        ; // check against all parsed bonds
+      if (CurrentBonds[j - 1] != id) { // no match ? Then mark in ListOfAtoms
+        ListOfAtoms[AtomNr] = NULL;
+        NonMatchNumber++;
+        status = false;
+        DoeLog(2) && (eLog() << Verbose(2) << id << " can not be found in list." << endl);
+      } else {
+        //Log() << Verbose(0) << "[" << id << "]\t";
+      }
+    }
+    //Log() << Verbose(0) << endl;
+  } else {
+    DoLog(0) && (Log() << Verbose(0) << "Number of bonds for Atom " << *Walker << " does not match, parsed " << CurrentBondsOfAtom << " against " << Walker->ListOfBonds.size() << "." << endl);
+    status = false;
+  }
+}
+;
+
+/** Checks contents of adjacency file against bond structure in structure molecule.
+ * \param *out output stream for debugging
+ * \param *path path to file
+ * \param **ListOfAtoms allocated (molecule::AtomCount) and filled lookup table for ids (Atom::nr) to *Atom
+ * \return true - structure is equal, false - not equivalence
+ */
+bool molecule::CheckAdjacencyFileAgainstMolecule(std::string &path, atom **ListOfAtoms)
+{
+  ifstream File;
+  bool status = true;
+  atom *Walker = NULL;
+  int *CurrentBonds = NULL;
+  int NonMatchNumber = 0; // will number of atoms with differing bond structure
+  size_t CurrentBondsOfAtom = -1;
+  const int AtomCount = getAtomCount();
+
+  if (!CheckAdjacencyFileAgainstMolecule_Init(path, File, CurrentBonds)) {
+    DoLog(1) && (Log() << Verbose(1) << "Adjacency file not found." << endl);
+    return true;
+  }
+
+  char buffer[MAXSTRINGSIZE];
+  // Parse the file line by line and count the bonds
+  while (!File.eof()) {
+    File.getline(buffer, MAXSTRINGSIZE);
+    stringstream line;
+    line.str(buffer);
+    int AtomNr = -1;
+    line >> AtomNr;
+    CurrentBondsOfAtom = -1; // we count one too far due to line end
+    // parse into structure
+    if ((AtomNr >= 0) && (AtomNr < AtomCount)) {
+      Walker = ListOfAtoms[AtomNr];
+      while (!line.eof())
+        line >> CurrentBonds[++CurrentBondsOfAtom];
+      // compare against present bonds
+      CheckAdjacencyFileAgainstMolecule_CompareBonds(status, NonMatchNumber, Walker, CurrentBondsOfAtom, AtomNr, CurrentBonds, ListOfAtoms);
+    } else {
+      if (AtomNr != -1)
+        DoeLog(2) && (eLog() << Verbose(2) << AtomNr << " is not valid in the range of ids [" << 0 << "," << AtomCount << ")." << endl);
+    }
+  }
+  CheckAdjacencyFileAgainstMolecule_Finalize(File, CurrentBonds);
+
+  if (status) { // if equal we parse the KeySetFile
+    DoLog(1) && (Log() << Verbose(1) << "done: Equal." << endl);
+  } else
+    DoLog(1) && (Log() << Verbose(1) << "done: Not equal by " << NonMatchNumber << " atoms." << endl);
+  return status;
+}
+;
+
+/** Picks from a global stack with all back edges the ones in the fragment.
+ * \param *out output stream for debugging
+ * \param **ListOfLocalAtoms array of father atom::nr to local atom::nr (reverse of atom::father)
+ * \param *ReferenceStack stack with all the back egdes
+ * \param *LocalStack stack to be filled
+ * \return true - everything ok, false - ReferenceStack was empty
+ */
+bool molecule::PickLocalBackEdges(atom **ListOfLocalAtoms, class StackClass<bond *> *&ReferenceStack, class StackClass<bond *> *&LocalStack) const
+{
+  bool status = true;
+  if (ReferenceStack->IsEmpty()) {
+    DoLog(1) && (Log() << Verbose(1) << "ReferenceStack is empty!" << endl);
+    return false;
+  }
+  bond *Binder = ReferenceStack->PopFirst();
+  bond *FirstBond = Binder; // mark the first bond, so that we don't loop through the stack indefinitely
+  atom *Walker = NULL, *OtherAtom = NULL;
+  ReferenceStack->Push(Binder);
+
+  do { // go through all bonds and push local ones
+    Walker = ListOfLocalAtoms[Binder->leftatom->nr]; // get one atom in the reference molecule
+    if (Walker != NULL) // if this Walker exists in the subgraph ...
+      for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
+        OtherAtom = (*Runner)->GetOtherAtom(Walker);
+        if (OtherAtom == ListOfLocalAtoms[(*Runner)->rightatom->nr]) { // found the bond
+          LocalStack->Push((*Runner));
+          DoLog(3) && (Log() << Verbose(3) << "Found local edge " << *(*Runner) << "." << endl);
+          break;
+        }
+      }
+    Binder = ReferenceStack->PopFirst(); // loop the stack for next item
+    DoLog(3) && (Log() << Verbose(3) << "Current candidate edge " << Binder << "." << endl);
+    ReferenceStack->Push(Binder);
+  } while (FirstBond != Binder);
+
+  return status;
+}
+;
+
+void BreadthFirstSearchAdd_Init(struct BFSAccounting &BFS, atom *&Root, int AtomCount, int BondOrder, atom **AddedAtomList = NULL)
+{
+  BFS.AtomCount = AtomCount;
+  BFS.BondOrder = BondOrder;
+  BFS.PredecessorList = new atom*[AtomCount];
+  BFS.ShortestPathList = new int[AtomCount];
+  BFS.ColorList = new enum Shading[AtomCount];
+  BFS.BFSStack = new StackClass<atom *> (AtomCount);
+
+  BFS.Root = Root;
+  BFS.BFSStack->ClearStack();
+  BFS.BFSStack->Push(Root);
+
+  // initialise each vertex as white with no predecessor, empty queue, color Root lightgray
+  for (int i = AtomCount; i--;) {
+    BFS.PredecessorList[i] = NULL;
+    BFS.ShortestPathList[i] = -1;
+    if ((AddedAtomList != NULL) && (AddedAtomList[i] != NULL)) // mark already present atoms (i.e. Root and maybe others) as visited
+      BFS.ColorList[i] = lightgray;
+    else
+      BFS.ColorList[i] = white;
+  }
+  //BFS.ShortestPathList[Root->nr] = 0; // done by Calloc
+}
+;
+
+void BreadthFirstSearchAdd_Free(struct BFSAccounting &BFS)
+{
+  delete[](BFS.PredecessorList);
+  delete[](BFS.ShortestPathList);
+  delete[](BFS.ColorList);
+  delete (BFS.BFSStack);
+  BFS.AtomCount = 0;
+}
+;
+
+void BreadthFirstSearchAdd_UnvisitedNode(molecule *Mol, struct BFSAccounting &BFS, atom *&Walker, atom *&OtherAtom, bond *&Binder, bond *&Bond, atom **&AddedAtomList, bond **&AddedBondList, bool IsAngstroem)
+{
+  if (Binder != Bond) // let other atom white if it's via Root bond. In case it's cyclic it has to be reached again (yet Root is from OtherAtom already black, thus no problem)
+    BFS.ColorList[OtherAtom->nr] = lightgray;
+  BFS.PredecessorList[OtherAtom->nr] = Walker; // Walker is the predecessor
+  BFS.ShortestPathList[OtherAtom->nr] = BFS.ShortestPathList[Walker->nr] + 1;
+  DoLog(2) && (Log() << Verbose(2) << "Coloring OtherAtom " << OtherAtom->getName() << " " << ((BFS.ColorList[OtherAtom->nr] == white) ? "white" : "lightgray") << ", its predecessor is " << Walker->getName() << " and its Shortest Path is " << BFS.ShortestPathList[OtherAtom->nr] << " egde(s) long." << endl);
+  if ((((BFS.ShortestPathList[OtherAtom->nr] < BFS.BondOrder) && (Binder != Bond)))) { // Check for maximum distance
+    DoLog(3) && (Log() << Verbose(3));
+    if (AddedAtomList[OtherAtom->nr] == NULL) { // add if it's not been so far
+      AddedAtomList[OtherAtom->nr] = Mol->AddCopyAtom(OtherAtom);
+      DoLog(0) && (Log() << Verbose(0) << "Added OtherAtom " << OtherAtom->getName());
+      AddedBondList[Binder->nr] = Mol->CopyBond(AddedAtomList[Walker->nr], AddedAtomList[OtherAtom->nr], Binder);
+      DoLog(0) && (Log() << Verbose(0) << " and bond " << *(AddedBondList[Binder->nr]) << ", ");
+    } else { // this code should actually never come into play (all white atoms are not yet present in BondMolecule, that's why they are white in the first place)
+      DoLog(0) && (Log() << Verbose(0) << "Not adding OtherAtom " << OtherAtom->getName());
+      if (AddedBondList[Binder->nr] == NULL) {
+        AddedBondList[Binder->nr] = Mol->CopyBond(AddedAtomList[Walker->nr], AddedAtomList[OtherAtom->nr], Binder);
+        DoLog(0) && (Log() << Verbose(0) << ", added Bond " << *(AddedBondList[Binder->nr]));
+      } else
+        DoLog(0) && (Log() << Verbose(0) << ", not added Bond ");
+    }
+    DoLog(0) && (Log() << Verbose(0) << ", putting OtherAtom into queue." << endl);
+    BFS.BFSStack->Push(OtherAtom);
+  } else { // out of bond order, then replace
+    if ((AddedAtomList[OtherAtom->nr] == NULL) && (Binder->Cyclic))
+      BFS.ColorList[OtherAtom->nr] = white; // unmark if it has not been queued/added, to make it available via its other bonds (cyclic)
+    if (Binder == Bond)
+      DoLog(3) && (Log() << Verbose(3) << "Not Queueing, is the Root bond");
+    else if (BFS.ShortestPathList[OtherAtom->nr] >= BFS.BondOrder)
+      DoLog(3) && (Log() << Verbose(3) << "Not Queueing, is out of Bond Count of " << BFS.BondOrder);
+    if (!Binder->Cyclic)
+      DoLog(0) && (Log() << Verbose(0) << ", is not part of a cyclic bond, saturating bond with Hydrogen." << endl);
+    if (AddedBondList[Binder->nr] == NULL) {
+      if ((AddedAtomList[OtherAtom->nr] != NULL)) { // .. whether we add or saturate
+        AddedBondList[Binder->nr] = Mol->CopyBond(AddedAtomList[Walker->nr], AddedAtomList[OtherAtom->nr], Binder);
+      } else {
+#ifdef ADDHYDROGEN
+        if (!Mol->AddHydrogenReplacementAtom(Binder, AddedAtomList[Walker->nr], Walker, OtherAtom, IsAngstroem))
+        exit(1);
+#endif
+      }
+    }
+  }
+}
+;
+
+void BreadthFirstSearchAdd_VisitedNode(molecule *Mol, struct BFSAccounting &BFS, atom *&Walker, atom *&OtherAtom, bond *&Binder, bond *&Bond, atom **&AddedAtomList, bond **&AddedBondList, bool IsAngstroem)
+{
+  DoLog(3) && (Log() << Verbose(3) << "Not Adding, has already been visited." << endl);
+  // This has to be a cyclic bond, check whether it's present ...
+  if (AddedBondList[Binder->nr] == NULL) {
+    if ((Binder != Bond) && (Binder->Cyclic) && (((BFS.ShortestPathList[Walker->nr] + 1) < BFS.BondOrder))) {
+      AddedBondList[Binder->nr] = Mol->CopyBond(AddedAtomList[Walker->nr], AddedAtomList[OtherAtom->nr], Binder);
+    } else { // if it's root bond it has to broken (otherwise we would not create the fragments)
+#ifdef ADDHYDROGEN
+      if(!Mol->AddHydrogenReplacementAtom(Binder, AddedAtomList[Walker->nr], Walker, OtherAtom, IsAngstroem))
+      exit(1);
+#endif
+    }
+  }
+}
+;
+
+/** Adds atoms up to \a BondCount distance from \a *Root and notes them down in \a **AddedAtomList.
+ * Gray vertices are always enqueued in an StackClass<atom *> FIFO queue, the rest is usual BFS with adding vertices found was
+ * white and putting into queue.
+ * \param *out output stream for debugging
+ * \param *Mol Molecule class to add atoms to
+ * \param **AddedAtomList list with added atom pointers, index is atom father's number
+ * \param **AddedBondList list with added bond pointers, index is bond father's number
+ * \param *Root root vertex for BFS
+ * \param *Bond bond not to look beyond
+ * \param BondOrder maximum distance for vertices to add
+ * \param IsAngstroem lengths are in angstroem or bohrradii
+ */
+void molecule::BreadthFirstSearchAdd(molecule *Mol, atom **&AddedAtomList, bond **&AddedBondList, atom *Root, bond *Bond, int BondOrder, bool IsAngstroem)
+{
+  struct BFSAccounting BFS;
+  atom *Walker = NULL, *OtherAtom = NULL;
+  bond *Binder = NULL;
+
+  // add Root if not done yet
+  if (AddedAtomList[Root->nr] == NULL) // add Root if not yet present
+    AddedAtomList[Root->nr] = Mol->AddCopyAtom(Root);
+
+  BreadthFirstSearchAdd_Init(BFS, Root, BondOrder, getAtomCount(), AddedAtomList);
+
+  // and go on ... Queue always contains all lightgray vertices
+  while (!BFS.BFSStack->IsEmpty()) {
+    // we have to pop the oldest atom from stack. This keeps the atoms on the stack always of the same ShortestPath distance.
+    // e.g. if current atom is 2, push to end of stack are of length 3, but first all of length 2 would be popped. They again
+    // append length of 3 (their neighbours). Thus on stack we have always atoms of a certain length n at bottom of stack and
+    // followed by n+1 till top of stack.
+    Walker = BFS.BFSStack->PopFirst(); // pop oldest added
+    DoLog(1) && (Log() << Verbose(1) << "Current Walker is: " << Walker->getName() << ", and has " << Walker->ListOfBonds.size() << " bonds." << endl);
+    for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
+      if ((*Runner) != NULL) { // don't look at bond equal NULL
+        Binder = (*Runner);
+        OtherAtom = (*Runner)->GetOtherAtom(Walker);
+        DoLog(2) && (Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->getName() << " for bond " << *(*Runner) << "." << endl);
+        if (BFS.ColorList[OtherAtom->nr] == white) {
+          BreadthFirstSearchAdd_UnvisitedNode(Mol, BFS, Walker, OtherAtom, Binder, Bond, AddedAtomList, AddedBondList, IsAngstroem);
+        } else {
+          BreadthFirstSearchAdd_VisitedNode(Mol, BFS, Walker, OtherAtom, Binder, Bond, AddedAtomList, AddedBondList, IsAngstroem);
+        }
+      }
+    }
+    BFS.ColorList[Walker->nr] = black;
+    DoLog(1) && (Log() << Verbose(1) << "Coloring Walker " << Walker->getName() << " black." << endl);
+  }
+  BreadthFirstSearchAdd_Free(BFS);
+}
+;
+
+/** Adds a bond as a copy to a given one
+ * \param *left leftatom of new bond
+ * \param *right rightatom of new bond
+ * \param *CopyBond rest of fields in bond are copied from this
+ * \return pointer to new bond
+ */
+bond * molecule::CopyBond(atom *left, atom *right, bond *CopyBond)
+{
+  bond *Binder = AddBond(left, right, CopyBond->BondDegree);
+  Binder->Cyclic = CopyBond->Cyclic;
+  Binder->Type = CopyBond->Type;
+  return Binder;
+}
+;
+
+void BuildInducedSubgraph_Init(atom **&ParentList, int AtomCount)
+{
+  // reset parent list
+  ParentList = new atom*[AtomCount];
+  for (int i=0;i<AtomCount;i++)
+    ParentList[i] = NULL;
+  DoLog(3) && (Log() << Verbose(3) << "Resetting ParentList." << endl);
+}
+;
+
+void BuildInducedSubgraph_FillParentList(const molecule *mol, const molecule *Father, atom **&ParentList)
+{
+  // fill parent list with sons
+  DoLog(3) && (Log() << Verbose(3) << "Filling Parent List." << endl);
+  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
+    ParentList[(*iter)->father->nr] = (*iter);
+    // Outputting List for debugging
+    DoLog(4) && (Log() << Verbose(4) << "Son[" << (*iter)->father->nr << "] of " << (*iter)->father << " is " << ParentList[(*iter)->father->nr] << "." << endl);
+  }
+};
+
+void BuildInducedSubgraph_Finalize(atom **&ParentList)
+{
+  delete[](ParentList);
+}
+;
+
+bool BuildInducedSubgraph_CreateBondsFromParent(molecule *mol, const molecule *Father, atom **&ParentList)
+{
+  bool status = true;
+  atom *OtherAtom = NULL;
+  // check each entry of parent list and if ok (one-to-and-onto matching) create bonds
+  DoLog(3) && (Log() << Verbose(3) << "Creating bonds." << endl);
+  for (molecule::const_iterator iter = Father->begin(); iter != Father->end(); ++iter) {
+    if (ParentList[(*iter)->nr] != NULL) {
+      if (ParentList[(*iter)->nr]->father != (*iter)) {
+        status = false;
+      } else {
+        for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) {
+          OtherAtom = (*Runner)->GetOtherAtom((*iter));
+          if (ParentList[OtherAtom->nr] != NULL) { // if otheratom is also a father of an atom on this molecule, create the bond
+            DoLog(4) && (Log() << Verbose(4) << "Endpoints of Bond " << (*Runner) << " are both present: " << ParentList[(*iter)->nr]->getName() << " and " << ParentList[OtherAtom->nr]->getName() << "." << endl);
+            mol->AddBond(ParentList[(*iter)->nr], ParentList[OtherAtom->nr], (*Runner)->BondDegree);
+          }
+        }
+      }
+    }
+  }
+  return status;
+}
+;
+
+/** Adds bond structure to this molecule from \a Father molecule.
+ * This basically causes this molecule to become an induced subgraph of the \a Father, i.e. for every bond in Father
+ * with end points present in this molecule, bond is created in this molecule.
+ * Special care was taken to ensure that this is of complexity O(N), where N is the \a Father's molecule::AtomCount.
+ * \param *out output stream for debugging
+ * \param *Father father molecule
+ * \return true - is induced subgraph, false - there are atoms with fathers not in \a Father
+ * \todo not checked, not fully working probably
+ */
+bool molecule::BuildInducedSubgraph(const molecule *Father)
+{
+  bool status = true;
+  atom **ParentList = NULL;
+  DoLog(2) && (Log() << Verbose(2) << "Begin of BuildInducedSubgraph." << endl);
+  BuildInducedSubgraph_Init(ParentList, Father->getAtomCount());
+  BuildInducedSubgraph_FillParentList(this, Father, ParentList);
+  status = BuildInducedSubgraph_CreateBondsFromParent(this, Father, ParentList);
+  BuildInducedSubgraph_Finalize(ParentList);
+  DoLog(2) && (Log() << Verbose(2) << "End of BuildInducedSubgraph." << endl);
+  return status;
+}
+;
+
+/** For a given keyset \a *Fragment, checks whether it is connected in the current molecule.
+ * \param *out output stream for debugging
+ * \param *Fragment Keyset of fragment's vertices
+ * \return true - connected, false - disconnected
+ * \note this is O(n^2) for it's just a bug checker not meant for permanent use!
+ */
+bool molecule::CheckForConnectedSubgraph(KeySet *Fragment)
+{
+  atom *Walker = NULL, *Walker2 = NULL;
+  bool BondStatus = false;
+  int size;
+
+  DoLog(1) && (Log() << Verbose(1) << "Begin of CheckForConnectedSubgraph" << endl);
+  DoLog(2) && (Log() << Verbose(2) << "Disconnected atom: ");
+
+  // count number of atoms in graph
+  size = 0;
+  for (KeySet::iterator runner = Fragment->begin(); runner != Fragment->end(); runner++)
+    size++;
+  if (size > 1)
+    for (KeySet::iterator runner = Fragment->begin(); runner != Fragment->end(); runner++) {
+      Walker = FindAtom(*runner);
+      BondStatus = false;
+      for (KeySet::iterator runners = Fragment->begin(); runners != Fragment->end(); runners++) {
+        Walker2 = FindAtom(*runners);
+        for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
+          if ((*Runner)->GetOtherAtom(Walker) == Walker2) {
+            BondStatus = true;
+            break;
+          }
+          if (BondStatus)
+            break;
+        }
+      }
+      if (!BondStatus) {
+        DoLog(0) && (Log() << Verbose(0) << (*Walker) << endl);
+        return false;
+      }
+    }
+  else {
+    DoLog(0) && (Log() << Verbose(0) << "none." << endl);
+    return true;
+  }
+  DoLog(0) && (Log() << Verbose(0) << "none." << endl);
+
+  DoLog(1) && (Log() << Verbose(1) << "End of CheckForConnectedSubgraph" << endl);
+
+  return true;
+}
Index: src/molecule_pointcloud.cpp
===================================================================
--- src/molecule_pointcloud.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/molecule_pointcloud.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,85 @@
+/*
+ * molecule_pointcloud.cpp
+ *
+ *  Created on: Oct 5, 2009
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "atom.hpp"
+#include "config.hpp"
+#include "info.hpp"
+#include "memoryallocator.hpp"
+#include "molecule.hpp"
+
+/************************************* Functions for class molecule *********************************/
+
+/** Returns a name for this point cloud, here the molecule's name.
+ * \return name of point cloud
+ */
+const char * const molecule::GetName() const
+{
+  return name;
+};
+
+/** Determine center of all atoms.
+ * \param *out output stream for debugging
+ * \return pointer to allocated with central coordinates
+ */
+Vector *molecule::GetCenter() const
+{
+  Vector *center = DetermineCenterOfAll();
+  return center;
+};
+
+
+/** PointCloud implementation of GoPoint
+ * Uses atoms and STL stuff.
+ */
+TesselPoint* molecule::GetPoint() const
+{
+  return (*InternalPointer);
+};
+
+/** PointCloud implementation of GoToNext.
+ * Uses atoms and STL stuff.
+ */
+void molecule::GoToNext() const
+{
+  if (InternalPointer != atoms.end())
+    InternalPointer++;
+};
+
+/** PointCloud implementation of GoToFirst.
+ * Uses atoms and STL stuff.
+ */
+void molecule::GoToFirst() const
+{
+  // evil hack necessary because
+  // -# although InternalPointer is mutable
+  // -# only const_iterator begin() is called due to const in the function declaration above
+  // -# and there is no cast from const_iterator to const iterator
+  atomSet::const_iterator test = begin();
+  InternalPointer = *(reinterpret_cast<atomSet::iterator *>(&test));
+};
+
+/** PointCloud implementation of IsEmpty.
+ * Uses atoms and STL stuff.
+ */
+bool molecule::IsEmpty() const
+{
+  return (empty());
+};
+
+/** PointCloud implementation of IsLast.
+ * Uses atoms and STL stuff.
+ */
+bool molecule::IsEnd() const
+{
+  return (InternalPointer == atoms.end());
+};
+
+int molecule::GetMaxId() const {
+  return getAtomCount();
+}
Index: src/molecule_template.hpp
===================================================================
--- src/molecule_template.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/molecule_template.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,429 @@
+/*
+ * molecule_template.hpp
+ *
+ *  Created on: Oct 6, 2009
+ *      Author: heber
+ */
+
+#ifndef MOLECULE_TEMPLATE_HPP_
+#define MOLECULE_TEMPLATE_HPP_
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "atom.hpp"
+/********************************************** 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 =================================== //
+
+// zero arguments
+template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() ) const
+{
+  res result = 0;
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    result += ((*iter)->*f)();
+  }
+  return result;
+};
+template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() const ) const
+{
+  res result = 0;
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    result += ((*iter)->*f)();
+  }
+  return result;
+};
+// one argument
+template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T), T t ) const
+{
+  res result = 0;
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    result += ((*iter)->*f)(t);
+  }
+  return result;
+};
+template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T) const, T t ) const
+{
+  res result = 0;
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    result += ((*iter)->*f)(t);
+  }
+  return result;
+};
+
+
+// ================== Acting with each Atoms on same molecule ========================== //
+
+// zero arguments
+template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *)) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    (*f)((*iter));
+  }
+};
+template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *) const) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    (*f)((*iter));
+  }
+};
+
+// ================== Acting with each Atoms on copy molecule ========================== //
+
+// zero arguments
+template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) , molecule *copy) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    (copy->*f)((*iter));
+  }
+};
+template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) const, molecule *copy) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    (copy->*f)((*iter));
+  }
+};
+
+// ================== Acting with each Atoms on copy molecule if true ========================== //
+
+// zero arguments
+template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () ) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    if (((*iter)->*condition)())
+      (copy->*f)((*iter));
+  }
+};
+template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () const ) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    if (((*iter)->*condition)())
+      (copy->*f)((*iter));
+  }
+};
+template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) () ) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    if (((*iter)->*condition)())
+      (copy->*f)((*iter));
+  }
+};
+template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) () const ) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    if (((*iter)->*condition)())
+      (copy->*f)((*iter));
+  }
+};
+// one argument
+template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T), T t ) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    if (((*iter)->*condition)(t))
+      (copy->*f)((*iter));
+  }
+};
+template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T) const, T t ) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    if (((*iter)->*condition)(t))
+      (copy->*f)((*iter));
+  }
+};
+template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T), T t ) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    if (((*iter)->*condition)(t))
+      (copy->*f)((*iter));
+  }
+};
+template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T) const, T t ) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    if (((*iter)->*condition)(t))
+      (copy->*f)((*iter));
+  }
+};
+// two arguments
+template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U), T t, U u ) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    if (((*iter)->*condition)(t,u))
+      (copy->*f)((*iter));
+  }
+};
+template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U) const, T t, U u ) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    if (((*iter)->*condition)(t,u))
+      (copy->*f)((*iter));
+  }
+};
+template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U), T t, U u ) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    if (((*iter)->*condition)(t,u))
+      (copy->*f)((*iter));
+  }
+};
+template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U) const, T t, U u ) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    if (((*iter)->*condition)(t,u))
+      (copy->*f)((*iter));
+  }
+};
+// three arguments
+template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v ) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    if (((*iter)->*condition)(t,u,v))
+      (copy->*f)((*iter));
+  }
+};
+template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V) const, T t, U u, V v ) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    if (((*iter)->*condition)(t,u,v))
+      (copy->*f)((*iter));
+  }
+};
+template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v ) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    if (((*iter)->*condition)(t,u,v))
+      (copy->*f)((*iter));
+  }
+};
+template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U, V) const, T t, U u, V v ) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    if (((*iter)->*condition)(t,u,v))
+      (copy->*f)((*iter));
+  }
+};
+
+// ================== Acting on all Atoms ========================== //
+
+// zero arguments
+template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)()) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    ((*iter)->*f)();
+  }
+};
+template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)() const) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    ((*iter)->*f)();
+  }
+};
+// one argument
+template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T), T t ) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    ((*iter)->*f)(t);
+  }
+};
+template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T) const, T t ) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    ((*iter)->*f)(t);
+  }
+};
+// two argument
+template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U), T t, U u ) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    ((*iter)->*f)(t, u);
+  }
+};
+template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u ) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    ((*iter)->*f)(t, u);
+  }
+};
+// three argument
+template <typename res, typename typ, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V), T t, U u, V v) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    ((*iter)->*f)(t, u, v);
+  }
+};
+template <typename res, typename typ, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V) const, T t, U u, V v) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    ((*iter)->*f)(t, u, v);
+  }
+};
+// four arguments
+template <typename res, typename typ, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V, W), T t, U u, V v, W w) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    ((*iter)->*f)(t, u, v, w);
+  }
+};
+template <typename res, typename typ, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V, W) const, T t, U u, V v, W w) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    ((*iter)->*f)(t, u, v, w);
+  }
+};
+
+// ===================== Accessing arrays indexed by some integer for each atom ======================
+
+// for atom ints
+template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *) ) const
+{
+  int inc = 1;
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    (*Setor) (&array[((*iter)->*index)], &inc);
+  }
+};
+template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T value ) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    (*Setor) (&array[((*iter)->*index)], &value);
+  }
+};
+template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T *value ) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    (*Setor) (&array[((*iter)->*index)], value);
+  }
+};
+// for element ints
+template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *) ) const
+{
+  int inc = 1;
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    (*Setor) (&array[((*iter)->type->*index)], &inc);
+  }
+};
+template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T value ) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    (*Setor) (&array[((*iter)->type->*index)], &value);
+  }
+};
+template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T *value ) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    (*Setor) (&array[((*iter)->type->*index)], value);
+  }
+};
+
+template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ atom::*value ) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    array[((*iter)->*index)] = ((*iter)->*Setor) ((*iter)->*value);
+  }
+};
+template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ atom::*value ) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    array[((*iter)->*index)] = ((*iter)->*Setor) ((*iter)->*value);
+  }
+};
+template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ &vect ) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    array[((*iter)->*index)] = ((*iter)->*Setor) (vect);
+  }
+};
+template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ &vect ) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    array[((*iter)->*index)] = ((*iter)->*Setor) (vect);
+  }
+};
+template <typename T, typename typ, typename typ2> void molecule::SetAtomValueToIndexedArray ( T *array, int typ::*index, T typ2::*value ) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    (*iter)->*value = array[((*iter)->*index)];
+    //Log() << Verbose(2) << *(*iter) << " gets " << ((*iter)->*value); << endl;
+  }
+};
+
+template <typename T, typename typ> void molecule::SetAtomValueToValue ( T value, T typ::*ptr ) const
+{
+  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
+    (*iter)->*ptr = value;
+    //Log() << Verbose(2) << *(*iter) << " gets " << ((*iter)->*ptr) << endl;
+  }
+};
+
+
+#endif /* MOLECULE_TEMPLATE_HPP_ */
Index: src/moleculelist.cpp
===================================================================
--- src/moleculelist.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/moleculelist.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,1232 @@
+/** \file MoleculeListClass.cpp
+ *
+ * Function implementations for the class MoleculeListClass.
+ *
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include <cstring>
+
+#include "World.hpp"
+#include "atom.hpp"
+#include "bond.hpp"
+#include "bondgraph.hpp"
+#include "boundary.hpp"
+#include "config.hpp"
+#include "element.hpp"
+#include "helpers.hpp"
+#include "linkedcell.hpp"
+#include "lists.hpp"
+#include "log.hpp"
+#include "molecule.hpp"
+#include "memoryallocator.hpp"
+#include "periodentafel.hpp"
+#include "Helpers/Assert.hpp"
+
+#include "Helpers/Assert.hpp"
+
+/*********************************** Functions for class MoleculeListClass *************************/
+
+/** Constructor for MoleculeListClass.
+ */
+MoleculeListClass::MoleculeListClass(World *_world) :
+  Observable("MoleculeListClass"),
+  world(_world)
+{
+  // empty lists
+  ListOfMolecules.clear();
+  MaxIndex = 1;
+};
+
+/** Destructor for MoleculeListClass.
+ */
+MoleculeListClass::~MoleculeListClass()
+{
+  DoLog(4) && (Log() << Verbose(4) << "Clearing ListOfMolecules." << endl);
+  for(MoleculeList::iterator MolRunner = ListOfMolecules.begin(); MolRunner != ListOfMolecules.end(); ++MolRunner)
+    (*MolRunner)->signOff(this);
+  ListOfMolecules.clear(); // empty list
+};
+
+/** Insert a new molecule into the list and set its number.
+ * \param *mol molecule to add to list.
+ */
+void MoleculeListClass::insert(molecule *mol)
+{
+  OBSERVE;
+  mol->IndexNr = MaxIndex++;
+  ListOfMolecules.push_back(mol);
+  mol->signOn(this);
+};
+
+/** Erases a molecule from the list.
+ * \param *mol molecule to add to list.
+ */
+void MoleculeListClass::erase(molecule *mol)
+{
+  OBSERVE;
+  mol->signOff(this);
+  ListOfMolecules.remove(mol);
+};
+
+/** Compare whether two molecules are equal.
+ * \param *a molecule one
+ * \param *n molecule two
+ * \return lexical value (-1, 0, +1)
+ */
+int MolCompare(const void *a, const void *b)
+{
+  int *aList = NULL, *bList = NULL;
+  int Count, Counter, aCounter, bCounter;
+  int flag;
+
+  // sort each atom list and put the numbers into a list, then go through
+  //Log() << Verbose(0) << "Comparing fragment no. " << *(molecule **)a << " to " << *(molecule **)b << "." << endl;
+  // Yes those types are awkward... but check it for yourself it checks out this way
+  molecule *const *mol1_ptr= static_cast<molecule *const *>(a);
+  molecule *mol1 = *mol1_ptr;
+  molecule *const *mol2_ptr= static_cast<molecule *const *>(b);
+  molecule *mol2 = *mol2_ptr;
+  if (mol1->getAtomCount() < mol2->getAtomCount()) {
+    return -1;
+  } else {
+    if (mol1->getAtomCount() > mol2->getAtomCount())
+      return +1;
+    else {
+      Count = mol1->getAtomCount();
+      aList = new int[Count];
+      bList = new int[Count];
+
+      // fill the lists
+      Counter = 0;
+      aCounter = 0;
+      bCounter = 0;
+      molecule::const_iterator aiter = mol1->begin();
+      molecule::const_iterator biter = mol2->begin();
+      for (;(aiter != mol1->end()) && (biter != mol2->end());
+          ++aiter, ++biter) {
+        if ((*aiter)->GetTrueFather() == NULL)
+          aList[Counter] = Count + (aCounter++);
+        else
+          aList[Counter] = (*aiter)->GetTrueFather()->nr;
+        if ((*biter)->GetTrueFather() == NULL)
+          bList[Counter] = Count + (bCounter++);
+        else
+          bList[Counter] = (*biter)->GetTrueFather()->nr;
+        Counter++;
+      }
+      // check if AtomCount was for real
+      flag = 0;
+      if ((aiter == mol1->end()) && (biter != mol2->end())) {
+        flag = -1;
+      } else {
+        if ((aiter != mol1->end()) && (biter == mol2->end()))
+          flag = 1;
+      }
+      if (flag == 0) {
+        // sort the lists
+        gsl_heapsort(aList, Count, sizeof(int), CompareDoubles);
+        gsl_heapsort(bList, Count, sizeof(int), CompareDoubles);
+        // compare the lists
+
+        flag = 0;
+        for (int i = 0; i < Count; i++) {
+          if (aList[i] < bList[i]) {
+            flag = -1;
+          } else {
+            if (aList[i] > bList[i])
+              flag = 1;
+          }
+          if (flag != 0)
+            break;
+        }
+      }
+      delete[] (aList);
+      delete[] (bList);
+      return flag;
+    }
+  }
+  return -1;
+};
+
+/** Output of a list of all molecules.
+ * \param *out output stream
+ */
+void MoleculeListClass::Enumerate(ostream *out)
+{
+  periodentafel *periode = World::getInstance().getPeriode();
+  std::map<atomicNumber_t,unsigned int> counts;
+  double size=0;
+  Vector Origin;
+
+  // header
+  (*out) << "Index\tName\t\tAtoms\tFormula\tCenter\tSize" << endl;
+  (*out) << "-----------------------------------------------" << endl;
+  if (ListOfMolecules.size() == 0)
+    (*out) << "\tNone" << endl;
+  else {
+    Origin.Zero();
+    for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) {
+      // count atoms per element and determine size of bounding sphere
+      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);
+      }
+      // output Index, Name, number of atoms, chemical formula
+      (*out) << ((*ListRunner)->ActiveFlag ? "*" : " ") << (*ListRunner)->IndexNr << "\t" << (*ListRunner)->name << "\t\t" << (*ListRunner)->getAtomCount() << "\t";
+
+      std::map<atomicNumber_t,unsigned int>::reverse_iterator iter;
+      for(iter=counts.rbegin(); iter!=counts.rend();++iter){
+        atomicNumber_t Z =(*iter).first;
+        (*out) << periode->FindElement(Z)->getSymbol() << (*iter).second;
+      }
+      // Center and size
+      (*out) << "\t" << (*ListRunner)->Center << "\t" << sqrt(size) << endl;
+    }
+  }
+};
+
+/** Returns the molecule with the given index \a index.
+ * \param index index of the desired molecule
+ * \return pointer to molecule structure, NULL if not found
+ */
+molecule * MoleculeListClass::ReturnIndex(int index)
+{
+  for(MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++)
+    if ((*ListRunner)->IndexNr == index)
+      return (*ListRunner);
+  return NULL;
+};
+
+/** 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.
+ * \param *out output stream
+ */
+void MoleculeListClass::Output(ofstream *out)
+{
+  DoLog(1) && (Log() << Verbose(1) << "MoleculeList: ");
+  for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++)
+    DoLog(0) && (Log() << Verbose(0) << *ListRunner << "\t");
+  DoLog(0) && (Log() << Verbose(0) << endl);
+};
+
+/** Calculates necessary hydrogen correction due to unwanted interaction between saturated ones.
+ * If for a pair of two hydrogen atoms a and b, at least is a saturated one, and a and b are not
+ * bonded to the same atom, then we add for this pair a correction term constructed from a Morse
+ * potential function fit to QM calculations with respecting to the interatomic hydrogen distance.
+ * \param &path path to file
+ */
+bool MoleculeListClass::AddHydrogenCorrection(std::string &path)
+{
+  bond *Binder = NULL;
+  double ***FitConstant = NULL, **correction = NULL;
+  int a, b;
+  ofstream output;
+  ifstream input;
+  string line;
+  stringstream zeile;
+  double distance;
+  char ParsedLine[1023];
+  double tmp;
+  char *FragmentNumber = NULL;
+
+  DoLog(1) && (Log() << Verbose(1) << "Saving hydrogen saturation correction ... ");
+  // 0. parse in fit constant files that should have the same dimension as the final energy files
+  // 0a. find dimension of matrices with constants
+  line = path;
+  line += "1";
+  line += FITCONSTANTSUFFIX;
+  input.open(line.c_str());
+  if (input.fail()) {
+    DoLog(1) && (Log() << Verbose(1) << endl << "Unable to open " << line << ", is the directory correct?" << endl);
+    return false;
+  }
+  a = 0;
+  b = -1; // we overcount by one
+  while (!input.eof()) {
+    input.getline(ParsedLine, 1023);
+    zeile.str(ParsedLine);
+    int i = 0;
+    while (!zeile.eof()) {
+      zeile >> distance;
+      i++;
+    }
+    if (i > a)
+      a = i;
+    b++;
+  }
+  DoLog(0) && (Log() << Verbose(0) << "I recognized " << a << " columns and " << b << " rows, ");
+  input.close();
+
+  // 0b. allocate memory for constants
+  FitConstant = new double**[3];
+  for (int k = 0; k < 3; k++) {
+    FitConstant[k] = new double*[a];
+    for (int i = a; i--;) {
+      FitConstant[k][i] = new double[b];
+      for (int j = b; j--;) {
+        FitConstant[k][i][j] = 0.;
+      }
+    }
+  }
+  // 0c. parse in constants
+  for (int i = 0; i < 3; i++) {
+    line = path;
+    line.append("/");
+    line += FRAGMENTPREFIX;
+    sprintf(ParsedLine, "%d", i + 1);
+    line += ParsedLine;
+    line += FITCONSTANTSUFFIX;
+    input.open(line.c_str());
+    if (input == NULL) {
+      DoeLog(0) && (eLog()<< Verbose(0) << endl << "Unable to open " << line << ", is the directory correct?" << endl);
+      performCriticalExit();
+      return false;
+    }
+    int k = 0, l;
+    while ((!input.eof()) && (k < b)) {
+      input.getline(ParsedLine, 1023);
+      //Log() << Verbose(0) << "Current Line: " << ParsedLine << endl;
+      zeile.str(ParsedLine);
+      zeile.clear();
+      l = 0;
+      while ((!zeile.eof()) && (l < a)) {
+        zeile >> FitConstant[i][l][k];
+        //Log() << Verbose(0) << FitConstant[i][l][k] << "\t";
+        l++;
+      }
+      //Log() << Verbose(0) << endl;
+      k++;
+    }
+    input.close();
+  }
+  for (int k = 0; k < 3; k++) {
+    DoLog(0) && (Log() << Verbose(0) << "Constants " << k << ":" << endl);
+    for (int j = 0; j < b; j++) {
+      for (int i = 0; i < a; i++) {
+        DoLog(0) && (Log() << Verbose(0) << FitConstant[k][i][j] << "\t");
+      }
+      DoLog(0) && (Log() << Verbose(0) << endl);
+    }
+    DoLog(0) && (Log() << Verbose(0) << endl);
+  }
+
+  // 0d. allocate final correction matrix
+  correction = new double*[a];
+  for (int i = a; i--;)
+    correction[i] = new double[b];
+
+  // 1a. go through every molecule in the list
+  for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) {
+    // 1b. zero final correction matrix
+    for (int k = a; k--;)
+      for (int j = b; j--;)
+        correction[k][j] = 0.;
+    // 2. take every hydrogen that is a saturated one
+    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
+        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!)
+            // 4. evaluate the morse potential for each matrix component and add up
+            distance = (*runner)->x.distance((*iter)->x);
+            //Log() << Verbose(0) << "Fragment " << (*ListRunner)->name << ": " << *(*runner) << "<= " << distance << "=>" << *(*iter) << ":" << endl;
+            for (int k = 0; k < a; k++) {
+              for (int j = 0; j < b; j++) {
+                switch (k) {
+                  case 1:
+                  case 7:
+                  case 11:
+                    tmp = pow(FitConstant[0][k][j] * (1. - exp(-FitConstant[1][k][j] * (distance - FitConstant[2][k][j]))), 2);
+                    break;
+                  default:
+                    tmp = FitConstant[0][k][j] * pow(distance, FitConstant[1][k][j]) + FitConstant[2][k][j];
+                };
+                correction[k][j] -= tmp; // ground state is actually lower (disturbed by additional interaction)
+                //Log() << Verbose(0) << tmp << "\t";
+              }
+              //Log() << Verbose(0) << endl;
+            }
+            //Log() << Verbose(0) << endl;
+          }
+        }
+      }
+    }
+    // 5. write final matrix to file
+    line = path;
+    line.append("/");
+    line += FRAGMENTPREFIX;
+    FragmentNumber = FixedDigitNumber(ListOfMolecules.size(), (*ListRunner)->IndexNr);
+    line += FragmentNumber;
+    delete[] (FragmentNumber);
+    line += HCORRECTIONSUFFIX;
+    output.open(line.c_str());
+    output << "Time\t\tTotal\t\tKinetic\t\tNonLocal\tCorrelation\tExchange\tPseudo\t\tHartree\t\t-Gauss\t\tEwald\t\tIonKin\t\tETotal" << endl;
+    for (int j = 0; j < b; j++) {
+      for (int i = 0; i < a; i++)
+        output << correction[i][j] << "\t";
+      output << endl;
+    }
+    output.close();
+  }
+  for (int i = a; i--;)
+    delete[](correction[i]);
+  delete[](correction);
+
+  line = path;
+  line.append("/");
+  line += HCORRECTIONSUFFIX;
+  output.open(line.c_str());
+  output << "Time\t\tTotal\t\tKinetic\t\tNonLocal\tCorrelation\tExchange\tPseudo\t\tHartree\t\t-Gauss\t\tEwald\t\tIonKin\t\tETotal" << endl;
+  for (int j = 0; j < b; j++) {
+    for (int i = 0; i < a; i++)
+      output << 0 << "\t";
+    output << endl;
+  }
+  output.close();
+  // 6. free memory of parsed matrices
+  for (int k = 0; k < 3; k++) {
+    for (int i = a; i--;) {
+      delete[](FitConstant[k][i]);
+    }
+    delete[](FitConstant[k]);
+  }
+  delete[](FitConstant);
+  DoLog(0) && (Log() << Verbose(0) << "done." << endl);
+  return true;
+};
+
+/** Store force indices, i.e. the connection between the nuclear index in the total molecule config and the respective atom in fragment config.
+ * \param &path path to file
+ * \param *SortIndex Index to map from the BFS labeling to the sequence how of Ion_Type in the config
+ * \return true - file written successfully, false - writing failed
+ */
+bool MoleculeListClass::StoreForcesFile(std::string &path, int *SortIndex)
+{
+  bool status = true;
+  string filename(path);
+  filename += FORCESFILE;
+  ofstream ForcesFile(filename.c_str());
+  periodentafel *periode=World::getInstance().getPeriode();
+
+  // open file for the force factors
+  DoLog(1) && (Log() << Verbose(1) << "Saving  force factors ... ");
+  if (!ForcesFile.fail()) {
+    //Log() << Verbose(1) << "Final AtomicForcesList: ";
+    //output << prefix << "Forces" << endl;
+    for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) {
+      periodentafel::const_iterator elemIter;
+      for(elemIter=periode->begin();elemIter!=periode->end();++elemIter){
+        if ((*ListRunner)->ElementsInMolecule[(*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)->GetTrueFather() != NULL) && ((*atomIter)->GetTrueFather() != (*atomIter))) {// if there is a rea
+                //Log() << Verbose(0) << "Walker is " << *Walker << " with true father " << *( Walker->GetTrueFather()) << ", it
+                ForcesFile << SortIndex[(*atomIter)->GetTrueFather()->nr] << "\t";
+              } else
+                // otherwise a -1 to indicate an added saturation hydrogen
+                ForcesFile << "-1\t";
+            }
+          }
+        }
+      }
+      ForcesFile << endl;
+    }
+    ForcesFile.close();
+    DoLog(1) && (Log() << Verbose(1) << "done." << endl);
+  } else {
+    status = false;
+    DoLog(1) && (Log() << Verbose(1) << "failed to open file " << filename << "." << endl);
+  }
+  ForcesFile.close();
+
+  return status;
+};
+
+/** Writes a config file for each molecule in the given \a **FragmentList.
+ * \param *out output stream for debugging
+ * \param &prefix path and prefix to the fragment config files
+ * \param *SortIndex Index to map from the BFS labeling to the sequence how of Ion_Type in the config
+ * \return true - success (each file was written), false - something went wrong.
+ */
+bool MoleculeListClass::OutputConfigForListOfFragments(std::string &prefix, int *SortIndex)
+{
+  ofstream outputFragment;
+  std::string FragmentName;
+  char PathBackup[MAXSTRINGSIZE];
+  bool result = true;
+  bool intermediateResult = true;
+  Vector BoxDimension;
+  char *FragmentNumber = NULL;
+  char *path = NULL;
+  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];
+  // store the fragments as config and as xyz
+  for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) {
+    // save default path as it is changed for each fragment
+    path = World::getInstance().getConfig()->GetDefaultPath();
+    if (path != NULL)
+      strcpy(PathBackup, path);
+    else {
+      DoeLog(0) && (eLog()<< Verbose(0) << "OutputConfigForListOfFragments: NULL default path obtained from config!" << endl);
+      performCriticalExit();
+    }
+
+    // correct periodic
+    (*ListRunner)->ScanForPeriodicCorrection();
+
+    // output xyz file
+    FragmentNumber = FixedDigitNumber(ListOfMolecules.size(), FragmentCounter++);
+    FragmentName = prefix + FragmentNumber + ".conf.xyz";
+    outputFragment.open(FragmentName.c_str(), ios::out);
+    DoLog(2) && (Log() << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as XYZ ...");
+    if ((intermediateResult = (*ListRunner)->OutputXYZ(&outputFragment)))
+      DoLog(0) && (Log() << Verbose(0) << " done." << endl);
+    else
+      DoLog(0) && (Log() << Verbose(0) << " failed." << endl);
+    result = result && intermediateResult;
+    outputFragment.close();
+    outputFragment.clear();
+
+    // list atoms in fragment for debugging
+    DoLog(2) && (Log() << Verbose(2) << "Contained atoms: ");
+    for (molecule::const_iterator iter = (*ListRunner)->begin(); iter != (*ListRunner)->end(); ++iter) {
+      DoLog(0) && (Log() << Verbose(0) << (*iter)->getName() << " ");
+    }
+    DoLog(0) && (Log() << Verbose(0) << endl);
+
+    // center on edge
+    (*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.;
+    }
+    (*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);
+
+    // change path in config
+    FragmentName = PathBackup;
+    FragmentName += "/";
+    FragmentName += FRAGMENTPREFIX;
+    FragmentName += FragmentNumber;
+    FragmentName += "/";
+    World::getInstance().getConfig()->SetDefaultPath(FragmentName.c_str());
+
+    // and save as config
+    FragmentName = prefix + FragmentNumber + ".conf";
+    DoLog(2) && (Log() << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as config ...");
+    if ((intermediateResult = World::getInstance().getConfig()->Save(FragmentName.c_str(), (*ListRunner)->elemente, (*ListRunner))))
+      DoLog(0) && (Log() << Verbose(0) << " done." << endl);
+    else
+      DoLog(0) && (Log() << Verbose(0) << " failed." << endl);
+    result = result && intermediateResult;
+
+    // restore old config
+    World::getInstance().getConfig()->SetDefaultPath(PathBackup);
+
+    // and save as mpqc input file
+    FragmentName = prefix + FragmentNumber + ".conf";
+    DoLog(2) && (Log() << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as mpqc input ...");
+    if ((intermediateResult = World::getInstance().getConfig()->SaveMPQC(FragmentName.c_str(), (*ListRunner))))
+      DoLog(2) && (Log() << Verbose(2) << " done." << endl);
+    else
+      DoLog(0) && (Log() << Verbose(0) << " failed." << endl);
+
+    result = result && intermediateResult;
+    //outputFragment.close();
+    //outputFragment.clear();
+    delete[](FragmentNumber);
+  }
+  DoLog(0) && (Log() << Verbose(0) << " done." << endl);
+
+  // printing final number
+  DoLog(2) && (Log() << Verbose(2) << "Final number of fragments: " << FragmentCounter << "." << endl);
+
+  // restore cell_size
+  for (int i=0;i<6;i++)
+    cell_size[i] = cell_size_backup[i];
+
+  return result;
+};
+
+/** Counts the number of molecules with the molecule::ActiveFlag set.
+ * \return number of molecules with ActiveFlag set to true.
+ */
+int MoleculeListClass::NumberOfActiveMolecules()
+{
+  int count = 0;
+  for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++)
+    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);
+};
+
+/** Count all atoms in each molecule.
+ * \return number of atoms in the MoleculeListClass.
+ * TODO: the inner loop should be done by some (double molecule::CountAtom()) function
+ */
+int MoleculeListClass::CountAllAtoms() const
+{
+  int AtomNo = 0;
+  for (MoleculeList::const_iterator MolWalker = ListOfMolecules.begin(); MolWalker != ListOfMolecules.end(); MolWalker++) {
+    AtomNo += (*MolWalker)->size();
+  }
+  return AtomNo;
+}
+
+/***********
+ * Methods Moved here from the menus
+ */
+
+void MoleculeListClass::flipChosen() {
+  int j;
+  Log() << Verbose(0) << "Enter index of molecule: ";
+  cin >> j;
+  for(MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++)
+    if ((*ListRunner)->IndexNr == j)
+      (*ListRunner)->ActiveFlag = !(*ListRunner)->ActiveFlag;
+}
+
+void MoleculeListClass::createNewMolecule(periodentafel *periode) {
+  OBSERVE;
+  molecule *mol = NULL;
+  mol = World::getInstance().createMolecule();
+  insert(mol);
+};
+
+void MoleculeListClass::loadFromXYZ(periodentafel *periode){
+  molecule *mol = NULL;
+  Vector center;
+  char filename[MAXSTRINGSIZE];
+  Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl;
+  mol = World::getInstance().createMolecule();
+  do {
+    Log() << Verbose(0) << "Enter file name: ";
+    cin >> filename;
+  } while (!mol->AddXYZFile(filename));
+  mol->SetNameFromFilename(filename);
+  // 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];
+  insert(mol);
+}
+
+void MoleculeListClass::setMoleculeFilename() {
+  char filename[MAXSTRINGSIZE];
+  int nr;
+  molecule *mol = NULL;
+  do {
+    Log() << Verbose(0) << "Enter index of molecule: ";
+    cin >> nr;
+    mol = ReturnIndex(nr);
+  } while (mol == NULL);
+  Log() << Verbose(0) << "Enter name: ";
+  cin >> filename;
+  mol->SetNameFromFilename(filename);
+}
+
+void MoleculeListClass::parseXYZIntoMolecule(){
+  char filename[MAXSTRINGSIZE];
+  int nr;
+  molecule *mol = NULL;
+  mol = NULL;
+  do {
+   Log() << Verbose(0) << "Enter index of molecule: ";
+   cin >> nr;
+   mol = ReturnIndex(nr);
+  } while (mol == NULL);
+  Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl;
+  do {
+   Log() << Verbose(0) << "Enter file name: ";
+   cin >> filename;
+  } while (!mol->AddXYZFile(filename));
+  mol->SetNameFromFilename(filename);
+};
+
+void MoleculeListClass::eraseMolecule(){
+  int nr;
+  molecule *mol = NULL;
+  Log() << Verbose(0) << "Enter index of molecule: ";
+  cin >> nr;
+  for(MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++)
+    if (nr == (*ListRunner)->IndexNr) {
+      mol = *ListRunner;
+      ListOfMolecules.erase(ListRunner);
+      World::getInstance().destroyMolecule(mol);
+      break;
+    }
+};
+
+
+/******************************************* Class MoleculeLeafClass ************************************************/
+
+/** Constructor for MoleculeLeafClass root leaf.
+ * \param *Up Leaf on upper level
+ * \param *PreviousLeaf NULL - We are the first leaf on this level, otherwise points to previous in list
+ */
+//MoleculeLeafClass::MoleculeLeafClass(MoleculeLeafClass *Up = NULL, MoleculeLeafClass *Previous = NULL)
+MoleculeLeafClass::MoleculeLeafClass(MoleculeLeafClass *PreviousLeaf = NULL)
+{
+  //  if (Up != NULL)
+  //    if (Up->DownLeaf == NULL) // are we the first down leaf for the upper leaf?
+  //      Up->DownLeaf = this;
+  //  UpLeaf = Up;
+  //  DownLeaf = NULL;
+  Leaf = NULL;
+  previous = PreviousLeaf;
+  if (previous != NULL) {
+    MoleculeLeafClass *Walker = previous->next;
+    previous->next = this;
+    next = Walker;
+  } else {
+    next = NULL;
+  }
+};
+
+/** Destructor for MoleculeLeafClass.
+ */
+MoleculeLeafClass::~MoleculeLeafClass()
+{
+  //  if (DownLeaf != NULL) {// drop leaves further down
+  //    MoleculeLeafClass *Walker = DownLeaf;
+  //    MoleculeLeafClass *Next;
+  //    do {
+  //      Next = Walker->NextLeaf;
+  //      delete(Walker);
+  //      Walker = Next;
+  //    } while (Walker != NULL);
+  //    // Last Walker sets DownLeaf automatically to NULL
+  //  }
+  // remove the leaf itself
+  if (Leaf != NULL) {
+    World::getInstance().destroyMolecule(Leaf);
+    Leaf = NULL;
+  }
+  // remove this Leaf from level list
+  if (previous != NULL)
+    previous->next = next;
+  //  } else { // we are first in list (connects to UpLeaf->DownLeaf)
+  //    if ((NextLeaf != NULL) && (NextLeaf->UpLeaf == NULL))
+  //      NextLeaf->UpLeaf = UpLeaf;  // either null as we are top level or the upleaf of the first node
+  //    if (UpLeaf != NULL)
+  //      UpLeaf->DownLeaf = NextLeaf;  // either null as we are only leaf or NextLeaf if we are just the first
+  //  }
+  //  UpLeaf = NULL;
+  if (next != NULL) // are we last in list
+    next->previous = previous;
+  next = NULL;
+  previous = NULL;
+};
+
+/** Adds \a molecule leaf to the tree.
+ * \param *ptr ptr to molecule to be added
+ * \param *Previous previous MoleculeLeafClass referencing level and which on the level
+ * \return true - success, false - something went wrong
+ */
+bool MoleculeLeafClass::AddLeaf(molecule *ptr, MoleculeLeafClass *Previous)
+{
+  return false;
+};
+
+/** Fills the bond structure of this chain list subgraphs that are derived from a complete \a *reference molecule.
+ * Calls this routine in each MoleculeLeafClass::next subgraph if it's not NULL.
+ * \param *out output stream for debugging
+ * \param *reference reference molecule with the bond structure to be copied
+ * \param **&ListOfLocalAtoms Lookup table for this subgraph and index of each atom in \a *reference, may be NULL on start, then it is filled
+ * \param FreeList true - ***ListOfLocalAtoms is free'd before return, false - it is not
+ * \return true - success, false - faoilure
+ */
+bool MoleculeLeafClass::FillBondStructureFromReference(const molecule * const reference, atom **&ListOfLocalAtoms, bool FreeList)
+{
+  atom *OtherWalker = NULL;
+  atom *Father = NULL;
+  bool status = true;
+  int AtomNo;
+
+  DoLog(1) && (Log() << Verbose(1) << "Begin of FillBondStructureFromReference." << endl);
+  // fill ListOfLocalAtoms if NULL was given
+  if (!FillListOfLocalAtoms(ListOfLocalAtoms, reference->getAtomCount(), FreeList)) {
+    DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl);
+    return false;
+  }
+
+  if (status) {
+    DoLog(1) && (Log() << Verbose(1) << "Creating adjacency list for subgraph " << Leaf << "." << endl);
+    // remove every bond from the list
+    for(molecule::iterator AtomRunner = Leaf->begin(); AtomRunner != Leaf->end(); ++AtomRunner)
+      for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin())
+        if ((*BondRunner)->leftatom == *AtomRunner)
+          delete((*BondRunner));
+
+    for(molecule::const_iterator iter = Leaf->begin(); iter != Leaf->end(); ++iter) {
+      Father = (*iter)->GetTrueFather();
+      AtomNo = Father->nr; // global id of the current walker
+      for (BondList::const_iterator Runner = Father->ListOfBonds.begin(); Runner != Father->ListOfBonds.end(); (++Runner)) {
+        OtherWalker = ListOfLocalAtoms[(*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr]; // local copy of current bond partner of walker
+        if (OtherWalker != NULL) {
+          if (OtherWalker->nr > (*iter)->nr)
+            Leaf->AddBond((*iter), OtherWalker, (*Runner)->BondDegree);
+        } else {
+          DoLog(1) && (Log() << Verbose(1) << "OtherWalker = ListOfLocalAtoms[" << (*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr << "] is NULL!" << endl);
+          status = false;
+        }
+      }
+    }
+  }
+
+  if ((FreeList) && (ListOfLocalAtoms != NULL)) {
+    // free the index lookup list
+    delete[](ListOfLocalAtoms);
+  }
+  DoLog(1) && (Log() << Verbose(1) << "End of FillBondStructureFromReference." << endl);
+  return status;
+};
+
+/** Fills the root stack for sites to be used as root in fragmentation depending on order or adaptivity criteria
+ * Again, as in \sa FillBondStructureFromReference steps recursively through each Leaf in this chain list of molecule's.
+ * \param *out output stream for debugging
+ * \param *&RootStack stack to be filled
+ * \param *AtomMask defines true/false per global Atom::nr to mask in/out each nuclear site
+ * \param &FragmentCounter counts through the fragments in this MoleculeLeafClass
+ * \return true - stack is non-empty, fragmentation necessary, false - stack is empty, no more sites to update
+ */
+bool MoleculeLeafClass::FillRootStackForSubgraphs(KeyStack *&RootStack, bool *AtomMask, int &FragmentCounter)
+{
+  atom *Father = NULL;
+
+  if (RootStack != NULL) {
+    // find first root candidates
+    if (&(RootStack[FragmentCounter]) != NULL) {
+      RootStack[FragmentCounter].clear();
+      for(molecule::const_iterator iter = Leaf->begin(); iter != Leaf->end(); ++iter) {
+        Father = (*iter)->GetTrueFather();
+        if (AtomMask[Father->nr]) // apply mask
+#ifdef ADDHYDROGEN
+          if ((*iter)->type->Z != 1) // skip hydrogen
+#endif
+          RootStack[FragmentCounter].push_front((*iter)->nr);
+      }
+      if (next != NULL)
+        next->FillRootStackForSubgraphs(RootStack, AtomMask, ++FragmentCounter);
+    } else {
+      DoLog(1) && (Log() << Verbose(1) << "Rootstack[" << FragmentCounter << "] is NULL." << endl);
+      return false;
+    }
+    FragmentCounter--;
+    return true;
+  } else {
+    DoLog(1) && (Log() << Verbose(1) << "Rootstack is NULL." << endl);
+    return false;
+  }
+};
+
+/** Fills a lookup list of father's Atom::nr -> atom for each subgraph.
+ * \param *out output stream from debugging
+ * \param **&ListOfLocalAtoms Lookup table for each subgraph and index of each atom in global molecule, may be NULL on start, then it is filled
+ * \param GlobalAtomCount number of atoms in the complete molecule
+ * \param &FreeList true - ***ListOfLocalAtoms is free'd before return, false - it is not
+ * \return true - success, false - failure (ListOfLocalAtoms != NULL)
+ */
+bool MoleculeLeafClass::FillListOfLocalAtoms(atom **&ListOfLocalAtoms, const int GlobalAtomCount, bool &FreeList)
+{
+  bool status = true;
+
+  if (ListOfLocalAtoms == NULL) { // allocate and fill list of this fragment/subgraph
+    status = status && Leaf->CreateFatherLookupTable(ListOfLocalAtoms, GlobalAtomCount);
+    FreeList = FreeList && true;
+  } else
+    return false;
+
+  return status;
+};
+
+/** The indices per keyset are compared to the respective father's Atom::nr in each subgraph and thus put into \a **&FragmentList.
+ * \param *out output stream fro debugging
+ * \param *reference reference molecule with the bond structure to be copied
+ * \param *KeySetList list with all keysets
+ * \param ***ListOfLocalAtoms Lookup table for each subgraph and index of each atom in global molecule, may be NULL on start, then it is filled
+ * \param **&FragmentList list to be allocated and returned
+ * \param &FragmentCounter counts the fragments as we move along the list
+ * \param FreeList true - ***ListOfLocalAtoms is free'd before return, false - it is not
+ * \retuen true - success, false - failure
+ */
+bool MoleculeLeafClass::AssignKeySetsToFragment(molecule *reference, Graph *KeySetList, atom ***&ListOfLocalAtoms, Graph **&FragmentList, int &FragmentCounter, bool FreeList)
+{
+  bool status = true;
+  int KeySetCounter = 0;
+
+  DoLog(1) && (Log() << Verbose(1) << "Begin of AssignKeySetsToFragment." << endl);
+  // fill ListOfLocalAtoms if NULL was given
+  if (!FillListOfLocalAtoms(ListOfLocalAtoms[FragmentCounter], reference->getAtomCount(), FreeList)) {
+    DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl);
+    return false;
+  }
+
+  // allocate fragment list
+  if (FragmentList == NULL) {
+    KeySetCounter = Count();
+    FragmentList = new Graph*[KeySetCounter];
+    for (int i=0;i<KeySetCounter;i++)
+      FragmentList[i] = NULL;
+    KeySetCounter = 0;
+  }
+
+  if ((KeySetList != NULL) && (KeySetList->size() != 0)) { // if there are some scanned keysets at all
+    // assign scanned keysets
+    if (FragmentList[FragmentCounter] == NULL)
+      FragmentList[FragmentCounter] = new Graph;
+    KeySet *TempSet = new KeySet;
+    for (Graph::iterator runner = KeySetList->begin(); runner != KeySetList->end(); runner++) { // key sets contain global numbers!
+      if (ListOfLocalAtoms[FragmentCounter][reference->FindAtom(*((*runner).first.begin()))->nr] != NULL) {// as we may assume that that bond structure is unchanged, we only test the first key in each set
+        // translate keyset to local numbers
+        for (KeySet::iterator sprinter = (*runner).first.begin(); sprinter != (*runner).first.end(); sprinter++)
+          TempSet->insert(ListOfLocalAtoms[FragmentCounter][reference->FindAtom(*sprinter)->nr]->nr);
+        // insert into FragmentList
+        FragmentList[FragmentCounter]->insert(GraphPair(*TempSet, pair<int, double> (KeySetCounter++, (*runner).second.second)));
+      }
+      TempSet->clear();
+    }
+    delete (TempSet);
+    if (KeySetCounter == 0) {// if there are no keysets, delete the list
+      DoLog(1) && (Log() << Verbose(1) << "KeySetCounter is zero, deleting FragmentList." << endl);
+      delete (FragmentList[FragmentCounter]);
+    } else
+      DoLog(1) && (Log() << Verbose(1) << KeySetCounter << " keysets were assigned to subgraph " << FragmentCounter << "." << endl);
+    FragmentCounter++;
+    if (next != NULL)
+      next->AssignKeySetsToFragment(reference, KeySetList, ListOfLocalAtoms, FragmentList, FragmentCounter, FreeList);
+    FragmentCounter--;
+  } else
+    DoLog(1) && (Log() << Verbose(1) << "KeySetList is NULL or empty." << endl);
+
+  if ((FreeList) && (ListOfLocalAtoms != NULL)) {
+    // free the index lookup list
+    delete[](ListOfLocalAtoms[FragmentCounter]);
+  }
+  DoLog(1) && (Log() << Verbose(1) << "End of AssignKeySetsToFragment." << endl);
+  return status;
+};
+
+/** Translate list into global numbers (i.e. ones that are valid in "this" molecule, not in MolecularWalker->Leaf)
+ * \param *out output stream for debugging
+ * \param **FragmentList Graph with local numbers per fragment
+ * \param &FragmentCounter counts the fragments as we move along the list
+ * \param &TotalNumberOfKeySets global key set counter
+ * \param &TotalGraph Graph to be filled with global numbers
+ */
+void MoleculeLeafClass::TranslateIndicesToGlobalIDs(Graph **FragmentList, int &FragmentCounter, int &TotalNumberOfKeySets, Graph &TotalGraph)
+{
+  DoLog(1) && (Log() << Verbose(1) << "Begin of TranslateIndicesToGlobalIDs." << endl);
+  KeySet *TempSet = new KeySet;
+  if (FragmentList[FragmentCounter] != NULL) {
+    for (Graph::iterator runner = FragmentList[FragmentCounter]->begin(); runner != FragmentList[FragmentCounter]->end(); runner++) {
+      for (KeySet::iterator sprinter = (*runner).first.begin(); sprinter != (*runner).first.end(); sprinter++)
+        TempSet->insert((Leaf->FindAtom(*sprinter))->GetTrueFather()->nr);
+      TotalGraph.insert(GraphPair(*TempSet, pair<int, double> (TotalNumberOfKeySets++, (*runner).second.second)));
+      TempSet->clear();
+    }
+    delete (TempSet);
+  } else {
+    DoLog(1) && (Log() << Verbose(1) << "FragmentList is NULL." << endl);
+  }
+  if (next != NULL)
+    next->TranslateIndicesToGlobalIDs(FragmentList, ++FragmentCounter, TotalNumberOfKeySets, TotalGraph);
+  FragmentCounter--;
+  DoLog(1) && (Log() << Verbose(1) << "End of TranslateIndicesToGlobalIDs." << endl);
+};
+
+/** Simply counts the number of items in the list, from given MoleculeLeafClass.
+ * \return number of items
+ */
+int MoleculeLeafClass::Count() const
+{
+  if (next != NULL)
+    return next->Count() + 1;
+  else
+    return 1;
+};
+
Index: src/orbitals.db
===================================================================
--- src/orbitals.db	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/orbitals.db	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,91 @@
+# atomicnumber numberoforbitals
+1	1
+2	0
+3	1
+4	2
+5	3
+6	4
+7	3
+8	2
+9	1
+10	0
+11	1
+12	2
+13	3
+14	4
+15	3
+16	2
+17	1
+18	0
+19	1
+20	4
+21	3
+22	4
+23	5
+24	6
+25	4
+26	3
+27	3
+28	2
+29	2
+30	2
+31	3
+32	4
+33	3
+34	2
+35	1
+36	0
+37	1
+38	2
+39	3
+40	4
+41	5
+42	6
+43	6
+44	8
+45	4
+46	4
+47	1
+48	2
+49	3
+50	4
+51	3
+52	2
+53	1
+54	0
+55	1
+56	2
+57	3
+58	4
+59	3
+60	4
+61	3
+62	3
+63	3
+64	3
+65	4
+66	3
+67	3
+68	3
+69	3	
+70	3
+71	3
+72	4
+73	5
+74	6
+75	7
+76	8
+77	6
+78	6
+79	3
+80	2
+81	3
+82	4
+83	3
+84	4
+86	0
+88	2
+89	3
+90	4
+91	5
+92	6
Index: src/parser.cpp
===================================================================
--- src/parser.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/parser.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,1149 @@
+/** \file parsing.cpp
+ *
+ * Declarations of various class functions for the parsing of value files.
+ *
+ */
+
+// ======================================= 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
+
+// ======================================= FUNCTIONS ==========================================
+
+/** Test if given filename can be opened.
+ * \param filename name of file
+ * \param test true - no error message, false - print error
+ * \return given file exists
+ */
+bool FilePresent(const char *filename, bool test)
+{
+  ifstream input;
+
+  input.open(filename, ios::in);
+  if (input == NULL) {
+    if (!test)
+      DoLog(0) && (Log() << Verbose(0) << endl << "FilePresent: Unable to open " << filename << ", is the directory correct?" << endl);
+    return false;
+  }
+  input.close();
+  return true;
+};
+
+/** Test the given parameters.
+ * \param argc argument count
+ * \param **argv arguments array
+ * \return given inputdir is valid
+ */
+bool TestParams(int argc, char **argv)
+{
+  ifstream input;
+  stringstream line;
+
+  line << argv[1] << FRAGMENTPREFIX << KEYSETFILE;
+  return FilePresent(line.str().c_str(), false);
+};
+
+// ======================================= CLASS MatrixContainer =============================
+
+/** Constructor of MatrixContainer class.
+ */
+MatrixContainer::MatrixContainer() {
+  Indices = NULL;
+  Header = new char*[1];
+  Matrix = new double**[1]; // one more each for the total molecule
+  RowCounter = new int[1];
+  ColumnCounter = new int[1];
+  Header[0] = NULL;
+  Matrix[0] = NULL;
+  RowCounter[0] = -1;
+  MatrixCounter = 0;
+  ColumnCounter[0] = -1;
+};
+
+/** Destructor of MatrixContainer class.
+ */
+MatrixContainer::~MatrixContainer() {
+  if (Matrix != NULL) {
+    // free Matrix[MatrixCounter]
+    if ((ColumnCounter != NULL) && (RowCounter != NULL) && (Matrix[MatrixCounter] != NULL))
+      for(int j=RowCounter[MatrixCounter]+1;j--;)
+        delete[](Matrix[MatrixCounter][j]);
+    //if (MatrixCounter != 0)
+    delete[](Matrix[MatrixCounter]);
+    // free all matrices but ultimate one
+    for(int i=MatrixCounter;i--;) {
+      if ((ColumnCounter != NULL) && (RowCounter != NULL)) {
+          for(int j=RowCounter[i]+1;j--;)
+            delete[](Matrix[i][j]);
+          delete[](Matrix[i]);
+      }
+    }
+    delete[](Matrix);
+  }
+  // free indices
+  if (Indices != NULL)
+    for(int i=MatrixCounter+1;i--;) {
+      delete[](Indices[i]);
+    }
+  delete[](Indices);
+  
+  // free header and counters
+  if (Header != NULL)
+    for(int i=MatrixCounter+1;i--;)
+      delete[](Header[i]);
+  delete[](Header);
+  delete[](RowCounter);
+  delete[](ColumnCounter);
+};
+
+/** Either copies index matrix from another MatrixContainer or initialises with trivial mapping if NULL.
+ * This either copies the index matrix or just maps 1 to 1, 2 to 2 and so on for all fragments.
+ * \param *Matrix pointer to other MatrixContainer
+ * \return true - copy/initialisation sucessful, false - dimension false for copying
+ */
+bool MatrixContainer::InitialiseIndices(class MatrixContainer *Matrix) 
+{
+  DoLog(0) && (Log() << Verbose(0) << "Initialising indices");
+  if (Matrix == NULL) {
+    DoLog(0) && (Log() << Verbose(0) << " with trivial mapping." << endl);
+    Indices = new int*[MatrixCounter + 1];
+    for(int i=MatrixCounter+1;i--;) {
+      Indices[i] = new int[RowCounter[i]];
+      for(int j=RowCounter[i];j--;)
+        Indices[i][j] = j;
+    }
+  } else {
+    DoLog(0) && (Log() << Verbose(0) << " from other MatrixContainer." << endl);
+    if (MatrixCounter != Matrix->MatrixCounter)
+      return false;
+    Indices = new int*[MatrixCounter + 1];
+    for(int i=MatrixCounter+1;i--;) {
+      if (RowCounter[i] != Matrix->RowCounter[i])
+        return false;
+      Indices[i] = new int[Matrix->RowCounter[i]];
+      for(int j=Matrix->RowCounter[i];j--;) {
+        Indices[i][j] = Matrix->Indices[i][j];
+        //Log() << Verbose(0) << Indices[i][j] << "\t";
+      }
+      //Log() << Verbose(0) << endl;
+    }
+  }
+  return true; 
+};
+
+/** Parsing a number of matrices.
+ *    -# open the matrix file
+ *    -# skip some lines (\a skiplines)
+ *    -# scan header lines for number of columns
+ *    -# scan lines for number of rows
+ *    -# allocate matrix
+ *    -# loop over found column and row counts and parse in each entry
+ * \param *name directory with files
+ * \param skiplines number of inital lines to skip
+ * \param skiplines number of inital columns to skip
+ * \param MatrixNr index number in Matrix array to parse into
+ * \return parsing successful
+ */
+bool MatrixContainer::ParseMatrix(const char *name, int skiplines, int skipcolumns, int MatrixNr)
+{
+  ifstream input;
+  stringstream line;
+  string token;
+  char filename[1023];
+
+  input.open(name, ios::in);
+  //Log() << Verbose(1) << "Opening " << name << " ... "  << input << endl;
+  if (input == NULL) {
+    DoeLog(1) && (eLog()<< Verbose(1) << endl << "MatrixContainer::ParseMatrix: Unable to open " << name << ", is the directory correct?" << endl);
+    //performCriticalExit();
+    return false;
+  }
+
+  // parse header
+  if (Header[MatrixNr] != NULL)
+    delete[] Header[MatrixNr];
+  Header[MatrixNr] = new char[1024];
+  for (int m=skiplines+1;m--;)
+    input.getline(Header[MatrixNr], 1023);
+  
+  // scan header for number of columns
+  line.str(Header[MatrixNr]);
+  for(int k=skipcolumns;k--;)
+    line >> Header[MatrixNr];
+  //Log() << Verbose(0) << line.str() << endl;
+  ColumnCounter[MatrixNr]=0;
+  while ( getline(line,token, '\t') ) {
+    if (token.length() > 0)
+      ColumnCounter[MatrixNr]++;
+  }
+  //Log() << Verbose(0) << line.str() << endl;
+  //Log() << Verbose(1) << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << "." << endl;
+  if (ColumnCounter[MatrixNr] == 0) {
+    DoeLog(0) && (eLog()<< Verbose(0) << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << " from file " << name << ", this is probably an error!" << endl);
+    performCriticalExit();
+  }
+  
+  // scan rest for number of rows/lines
+  RowCounter[MatrixNr]=-1;    // counts one line too much
+  while (!input.eof()) {
+    input.getline(filename, 1023);
+    //Log() << Verbose(0) << "Comparing: " << strncmp(filename,"MeanForce",9) << endl;
+    RowCounter[MatrixNr]++; // then line was not last MeanForce
+    if (strncmp(filename,"MeanForce", 9) == 0) {
+      break;
+    }
+  }
+  //Log() << Verbose(1) << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << "." << endl;
+  if (RowCounter[MatrixNr] == 0) {
+    DoeLog(0) && (eLog()<< Verbose(0) << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << ", this is probably an error!" << endl);
+    performCriticalExit();
+  }
+
+  // allocate matrix if it's not zero dimension in one direction
+  if ((ColumnCounter[MatrixNr] > 0) && (RowCounter[MatrixNr] > -1)) {
+    if (Matrix[MatrixNr] != NULL)
+      delete[] Matrix[MatrixNr];
+    Matrix[MatrixNr] = new double*[RowCounter[MatrixNr] + 1];
+    for(int j=0;j<RowCounter[MatrixNr]+1;j++)
+      Matrix[MatrixNr][j] = 0;
+
+    // parse in each entry for this matrix
+    input.clear();
+    input.seekg(ios::beg);
+    for (int m=skiplines+1;m--;)
+      input.getline(Header[MatrixNr], 1023);    // skip header
+    line.str(Header[MatrixNr]);
+    for(int k=skipcolumns;k--;)  // skip columns in header too
+      line >> filename;
+    strncpy(Header[MatrixNr], line.str().c_str(), 1023);  
+    for(int j=0;j<RowCounter[MatrixNr];j++) {
+      if (Matrix[MatrixNr][j] != NULL)
+        delete[] Matrix[MatrixNr][j];
+      Matrix[MatrixNr][j] = new double[ColumnCounter[MatrixNr]];
+      for(int k=0;k<ColumnCounter[MatrixNr];k++)
+        Matrix[MatrixNr][j][k] = 0;
+
+      input.getline(filename, 1023);
+      stringstream lines(filename);
+      //Log() << Verbose(2) << "Matrix at level " << j << ":";// << filename << endl;
+      for(int k=skipcolumns;k--;)
+        lines >> filename;
+      for(int k=0;(k<ColumnCounter[MatrixNr]) && (!lines.eof());k++) {
+        lines >> Matrix[MatrixNr][j][k];
+        //Log() << Verbose(1) << " " << setprecision(2) << Matrix[MatrixNr][j][k] << endl;
+      }
+      if (Matrix[MatrixNr][ RowCounter[MatrixNr] ] != NULL)
+        delete[] Matrix[MatrixNr][ RowCounter[MatrixNr] ];
+      Matrix[MatrixNr][ RowCounter[MatrixNr] ] = new double[ColumnCounter[MatrixNr]];
+      for(int j=ColumnCounter[MatrixNr];j--;)
+        Matrix[MatrixNr][ RowCounter[MatrixNr] ][j] = 0.;
+    }
+  } else {
+    DoeLog(1) && (eLog()<< Verbose(1) << "Matrix nr. " << MatrixNr << " has column and row count of (" << ColumnCounter[MatrixNr] << "," << RowCounter[MatrixNr] << "), could not allocate nor parse!" << endl); 
+  }
+  input.close();
+  return true;
+};
+
+/** Parsing a number of matrices.
+ * -# First, count the number of matrices by counting lines in KEYSETFILE
+ * -# Then,
+ *    -# construct the fragment number
+ *    -# open the matrix file
+ *    -# skip some lines (\a skiplines)
+ *    -# scan header lines for number of columns
+ *    -# scan lines for number of rows
+ *    -# allocate matrix
+ *    -# loop over found column and row counts and parse in each entry
+ * -# Finally, allocate one additional matrix (\a MatrixCounter) containing combined or temporary values
+ * \param *name directory with files
+ * \param *prefix prefix of each matrix file
+ * \param *suffix suffix of each matrix file
+ * \param skiplines number of inital lines to skip
+ * \param skiplines number of inital columns to skip
+ * \return parsing successful
+ */
+bool MatrixContainer::ParseFragmentMatrix(const char *name, const char *prefix, string suffix, int skiplines, int skipcolumns)
+{
+  char filename[1023];
+  ifstream input;
+  char *FragmentNumber = NULL;
+  stringstream file;
+  string token;
+
+  // count the number of matrices
+  MatrixCounter = -1; // we count one too much
+  file << name << FRAGMENTPREFIX << KEYSETFILE;
+  input.open(file.str().c_str(), ios::in);
+  if (input == NULL) {
+    DoLog(0) && (Log() << Verbose(0) << endl << "MatrixContainer::ParseFragmentMatrix: Unable to open " << file.str() << ", is the directory correct?" << endl);
+    return false;
+  }
+  while (!input.eof()) {
+    input.getline(filename, 1023);
+    stringstream zeile(filename);
+    MatrixCounter++;
+  }
+  input.close();
+  DoLog(0) && (Log() << Verbose(0) << "Determined " << MatrixCounter << " fragments." << endl);
+
+  DoLog(0) && (Log() << Verbose(0) << "Parsing through each fragment and retrieving " << prefix << suffix << "." << endl);
+  delete[](Header);
+  delete[](Matrix);
+  delete[](RowCounter);
+  delete[](ColumnCounter);
+  Header = new char*[MatrixCounter + 1]; // one more each for the total molecule
+  Matrix = new double**[MatrixCounter + 1]; // one more each for the total molecule
+  RowCounter = new int[MatrixCounter + 1];
+  ColumnCounter = new int[MatrixCounter + 1];
+  for(int i=MatrixCounter+1;i--;) {
+    Matrix[i] = NULL;
+    Header[i] = NULL;
+    RowCounter[i] = -1;
+    ColumnCounter[i] = -1;
+  }
+  for(int i=0; i < MatrixCounter;i++) {
+    // open matrix file
+    FragmentNumber = FixedDigitNumber(MatrixCounter, i);
+    file.str(" ");
+    file << name << FRAGMENTPREFIX << FragmentNumber << prefix << suffix;
+    if (!ParseMatrix(file.str().c_str(), skiplines, skipcolumns, i))
+      return false;
+    delete[](FragmentNumber);
+  }
+  return true;
+};
+
+/** Allocates and resets the memory for a number \a MCounter of matrices.
+ * \param **GivenHeader Header line for each matrix
+ * \param MCounter number of matrices
+ * \param *RCounter number of rows for each matrix
+ * \param *CCounter number of columns for each matrix
+ * \return Allocation successful 
+ */
+bool MatrixContainer::AllocateMatrix(char **GivenHeader, int MCounter, int *RCounter, int *CCounter)
+{
+  MatrixCounter = MCounter;
+  Header = new char*[MatrixCounter + 1];
+  Matrix = new double**[MatrixCounter + 1]; // one more each for the total molecule
+  RowCounter = new int[MatrixCounter + 1];
+  ColumnCounter = new int[MatrixCounter + 1];
+  for(int i=MatrixCounter+1;i--;) {
+    Header[i] = new char[1024];
+    strncpy(Header[i], GivenHeader[i], 1023);
+    RowCounter[i] = RCounter[i];
+    ColumnCounter[i] = CCounter[i];
+    Matrix[i] = new double*[RowCounter[i] + 1];
+    for(int j=RowCounter[i]+1;j--;) {
+      Matrix[i][j] = new double[ColumnCounter[i]];
+      for(int k=ColumnCounter[i];k--;)
+        Matrix[i][j][k] = 0.;
+    }
+  }
+  return true;
+};
+
+/** Resets all values in MatrixContainer::Matrix.
+ * \return true if successful
+ */
+bool MatrixContainer::ResetMatrix()
+{
+  for(int i=MatrixCounter+1;i--;)
+    for(int j=RowCounter[i]+1;j--;)
+      for(int k=ColumnCounter[i];k--;)
+        Matrix[i][j][k] = 0.;
+   return true;
+};
+
+/** Scans all elements of MatrixContainer::Matrix for greatest absolute value.
+ * \return greatest value of MatrixContainer::Matrix
+ */
+double MatrixContainer::FindMaxValue()
+{
+  double max = Matrix[0][0][0];
+  for(int i=MatrixCounter+1;i--;)
+    for(int j=RowCounter[i]+1;j--;)
+      for(int k=ColumnCounter[i];k--;)
+        if (fabs(Matrix[i][j][k]) > max)
+          max = fabs(Matrix[i][j][k]);
+  if (fabs(max) < MYEPSILON)
+    max += MYEPSILON;
+ return max;
+};
+
+/** Scans all elements of MatrixContainer::Matrix for smallest absolute value.
+ * \return smallest value of MatrixContainer::Matrix
+ */
+double MatrixContainer::FindMinValue()
+{
+  double min = Matrix[0][0][0];
+  for(int i=MatrixCounter+1;i--;)
+    for(int j=RowCounter[i]+1;j--;)
+      for(int k=ColumnCounter[i];k--;)
+        if (fabs(Matrix[i][j][k]) < min)
+          min = fabs(Matrix[i][j][k]);
+  if (fabs(min) < MYEPSILON)
+    min += MYEPSILON;
+  return min;
+};
+
+/** Sets all values in the last of MatrixContainer::Matrix to \a value.
+ * \param value reset value
+ * \param skipcolumns skip initial columns
+ * \return true if successful
+ */
+bool MatrixContainer::SetLastMatrix(double value, int skipcolumns)
+{
+  for(int j=RowCounter[MatrixCounter]+1;j--;)
+    for(int k=skipcolumns;k<ColumnCounter[MatrixCounter];k++)
+      Matrix[MatrixCounter][j][k] = value;
+   return true;
+};
+
+/** Sets all values in the last of MatrixContainer::Matrix to \a value.
+ * \param **values matrix with each value (must have at least same dimensions!)
+ * \param skipcolumns skip initial columns
+ * \return true if successful
+ */
+bool MatrixContainer::SetLastMatrix(double **values, int skipcolumns)
+{
+  for(int j=RowCounter[MatrixCounter]+1;j--;)
+    for(int k=skipcolumns;k<ColumnCounter[MatrixCounter];k++)
+      Matrix[MatrixCounter][j][k] = values[j][k];
+   return true;
+};
+
+/** Sums the entries with each factor and put into last element of \a ***Matrix.
+ * Sums over "E"-terms to create the "F"-terms
+ * \param Matrix MatrixContainer with matrices (LevelCounter by *ColumnCounter) with all the energies.
+ * \param KeySets KeySetContainer with bond Order and association mapping of each fragment to an order
+ * \param Order bond order
+ * \return true if summing was successful
+ */
+bool MatrixContainer::SumSubManyBodyTerms(class MatrixContainer &MatrixValues, class KeySetsContainer &KeySets, int Order)
+{
+  // go through each order
+  for (int CurrentFragment=0;CurrentFragment<KeySets.FragmentsPerOrder[Order];CurrentFragment++) {
+    //Log() << Verbose(0) << "Current Fragment is " << CurrentFragment << "/" << KeySets.OrderSet[Order][CurrentFragment] << "." << endl;
+    // then go per order through each suborder and pick together all the terms that contain this fragment
+    for(int SubOrder=0;SubOrder<=Order;SubOrder++) { // go through all suborders up to the desired order
+      for (int j=0;j<KeySets.FragmentsPerOrder[SubOrder];j++) { // go through all possible fragments of size suborder
+        if (KeySets.Contains(KeySets.OrderSet[Order][CurrentFragment], KeySets.OrderSet[SubOrder][j])) {
+          //Log() << Verbose(0) << "Current other fragment is " << j << "/" << KeySets.OrderSet[SubOrder][j] << "." << endl;
+          // if the fragment's indices are all in the current fragment
+          for(int k=0;k<RowCounter[ KeySets.OrderSet[SubOrder][j] ];k++) { // go through all atoms in this fragment
+            int m = MatrixValues.Indices[ KeySets.OrderSet[SubOrder][j] ][k];
+            //Log() << Verbose(0) << "Current index is " << k << "/" << m << "." << endl;
+            if (m != -1) { // if it's not an added hydrogen
+              for (int l=0;l<RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ];l++) { // look for the corresponding index in the current fragment
+                //Log() << Verbose(0) << "Comparing " << m << " with " << MatrixValues.Indices[ KeySets.OrderSet[Order][CurrentFragment] ][l] << "." << endl;
+                if (m == MatrixValues.Indices[ KeySets.OrderSet[Order][CurrentFragment] ][l]) {
+                  m = l;
+                  break;
+                }
+              }
+              //Log() << Verbose(0) << "Corresponding index in CurrentFragment is " << m << "." << endl;
+              if (m > RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ]) {
+                DoeLog(0) && (eLog()<< Verbose(0) << "In fragment No. " << KeySets.OrderSet[Order][CurrentFragment]   << " current force index " << m << " is greater than " << RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ] << "!" << endl);
+                performCriticalExit();
+                return false;
+              }
+              if (Order == SubOrder) { // equal order is always copy from Energies
+                for(int l=ColumnCounter[ KeySets.OrderSet[SubOrder][j] ];l--;) // then adds/subtract each column
+                  Matrix[ KeySets.OrderSet[Order][CurrentFragment] ][m][l] += MatrixValues.Matrix[ KeySets.OrderSet[SubOrder][j] ][k][l];
+              } else {
+                for(int l=ColumnCounter[ KeySets.OrderSet[SubOrder][j] ];l--;)
+                  Matrix[ KeySets.OrderSet[Order][CurrentFragment] ][m][l] -= Matrix[ KeySets.OrderSet[SubOrder][j] ][k][l];
+              }
+            }
+            //if ((ColumnCounter[ KeySets.OrderSet[SubOrder][j] ]>1) && (RowCounter[0]-1 >= 1))
+             //Log() << Verbose(0) << "Fragments[ KeySets.OrderSet[" << Order << "][" << CurrentFragment << "]=" << KeySets.OrderSet[Order][CurrentFragment] << " ][" << RowCounter[0]-1 << "][" << 1 << "] = " <<  Matrix[ KeySets.OrderSet[Order][CurrentFragment] ][RowCounter[0]-1][1] << endl;
+          }
+        } else {
+          //Log() << Verbose(0) << "Fragment " << KeySets.OrderSet[SubOrder][j] << " is not contained in fragment " << KeySets.OrderSet[Order][CurrentFragment] << "." << endl;
+        }
+      }
+    }
+   //Log() << Verbose(0) << "Final Fragments[ KeySets.OrderSet[" << Order << "][" << CurrentFragment << "]=" << KeySets.OrderSet[Order][CurrentFragment] << " ][" << KeySets.AtomCounter[0]-1 << "][" << 1 << "] = " <<  Matrix[ KeySets.OrderSet[Order][CurrentFragment] ][KeySets.AtomCounter[0]-1][1] << endl;
+  }
+
+  return true;
+};
+
+/** Writes the summed total fragment terms \f$F_{ij}\f$ to file.
+ * \param *name inputdir
+ * \param *prefix prefix before \a EnergySuffix
+ * \return file was written
+ */
+bool MatrixContainer::WriteTotalFragments(const char *name, const char *prefix)
+{
+  ofstream output;
+  char *FragmentNumber = NULL;
+
+  DoLog(0) && (Log() << Verbose(0) << "Writing fragment files." << endl);
+  for(int i=0;i<MatrixCounter;i++) {
+    stringstream line;
+    FragmentNumber = FixedDigitNumber(MatrixCounter, i);
+    line << name << FRAGMENTPREFIX << FragmentNumber << "/" << prefix;
+    delete[](FragmentNumber);
+    output.open(line.str().c_str(), ios::out);
+    if (output == NULL) {
+      DoeLog(0) && (eLog()<< Verbose(0) << "MatrixContainer::WriteTotalFragments: Unable to open output energy file " << line.str() << "!" << endl);
+      performCriticalExit();
+      return false;
+    }
+    output << Header[i] << endl;
+    for(int j=0;j<RowCounter[i];j++) {
+      for(int k=0;k<ColumnCounter[i];k++)
+        output << scientific << Matrix[i][j][k] << "\t";
+      output << endl;
+    }
+    output.close();
+  }
+  return true;
+};
+
+/** Writes the summed total values in the last matrix to file.
+ * \param *name inputdir
+ * \param *prefix prefix
+ * \param *suffix suffix
+ * \return file was written
+ */
+bool MatrixContainer::WriteLastMatrix(const char *name, const char *prefix, const char *suffix)
+{
+  ofstream output;
+  stringstream line;
+
+  DoLog(0) && (Log() << Verbose(0) << "Writing matrix values of " << suffix << "." << endl);
+  line << name << prefix << suffix;
+  output.open(line.str().c_str(), ios::out);
+  if (output == NULL) {
+    DoeLog(0) && (eLog()<< Verbose(0) << "MatrixContainer::WriteLastMatrix: Unable to open output matrix file " << line.str() << "!" << endl);
+    performCriticalExit();
+    return false;
+  }
+  output << Header[MatrixCounter] << endl;
+  for(int j=0;j<RowCounter[MatrixCounter];j++) {
+    for(int k=0;k<ColumnCounter[MatrixCounter];k++)
+      output << scientific << Matrix[MatrixCounter][j][k] << "\t";
+    output << endl;
+  }
+  output.close();
+  return true;
+};
+
+// ======================================= CLASS EnergyMatrix =============================
+
+/** Create a trivial energy index mapping.
+ * This just maps 1 to 1, 2 to 2 and so on for all fragments.
+ * \return creation sucessful
+ */
+bool EnergyMatrix::ParseIndices()
+{
+  DoLog(0) && (Log() << Verbose(0) << "Parsing energy indices." << endl);
+  Indices = new int*[MatrixCounter + 1];
+  for(int i=MatrixCounter+1;i--;) {
+    Indices[i] = new int[RowCounter[i]];
+    for(int j=RowCounter[i];j--;)
+      Indices[i][j] = j;
+  }
+  return true;
+};
+
+/** Sums the energy with each factor and put into last element of \a EnergyMatrix::Matrix.
+ * Sums over the "F"-terms in ANOVA decomposition.
+ * \param Matrix MatrixContainer with matrices (LevelCounter by *ColumnCounter) with all the energies.
+ * \param CorrectionFragments MatrixContainer with hydrogen saturation correction per fragments
+ * \param KeySets KeySetContainer with bond Order and association mapping of each fragment to an order
+ * \param Order bond order
+ * \parsm sign +1 or -1
+ * \return true if summing was successful
+ */
+bool EnergyMatrix::SumSubEnergy(class EnergyMatrix &Fragments, class EnergyMatrix *CorrectionFragments, class KeySetsContainer &KeySets, int Order, double sign)
+{
+  // sum energy
+  if (CorrectionFragments == NULL)
+    for(int i=KeySets.FragmentsPerOrder[Order];i--;)
+      for(int j=RowCounter[ KeySets.OrderSet[Order][i] ];j--;)
+        for(int k=ColumnCounter[ KeySets.OrderSet[Order][i] ];k--;)
+          Matrix[MatrixCounter][j][k] += sign*Fragments.Matrix[ KeySets.OrderSet[Order][i] ][j][k];
+  else
+    for(int i=KeySets.FragmentsPerOrder[Order];i--;)
+      for(int j=RowCounter[ KeySets.OrderSet[Order][i] ];j--;)
+        for(int k=ColumnCounter[ KeySets.OrderSet[Order][i] ];k--;)
+          Matrix[MatrixCounter][j][k] += sign*(Fragments.Matrix[ KeySets.OrderSet[Order][i] ][j][k] + CorrectionFragments->Matrix[ KeySets.OrderSet[Order][i] ][j][k]);
+  return true;
+};
+
+/** Calls MatrixContainer::ParseFragmentMatrix() and additionally allocates last plus one matrix.
+ * \param *name directory with files
+ * \param *prefix prefix of each matrix file
+ * \param *suffix suffix of each matrix file
+ * \param skiplines number of inital lines to skip
+ * \param skiplines number of inital columns to skip
+ * \return parsing successful
+ */
+bool EnergyMatrix::ParseFragmentMatrix(const char *name, const char *prefix, string suffix, int skiplines, int skipcolumns)
+{
+  char filename[1024];
+  bool status = MatrixContainer::ParseFragmentMatrix(name, prefix, suffix, skiplines, skipcolumns);
+
+  if (status) {
+    // count maximum of columns
+    RowCounter[MatrixCounter] = 0;
+    ColumnCounter[MatrixCounter] = 0;
+    for(int j=0; j < MatrixCounter;j++) { // (energy matrix might be bigger than number of atoms in terms of rows)
+      if (RowCounter[j] > RowCounter[MatrixCounter])
+        RowCounter[MatrixCounter] = RowCounter[j];
+      if (ColumnCounter[j] > ColumnCounter[MatrixCounter])  // take maximum of all for last matrix
+        ColumnCounter[MatrixCounter] = ColumnCounter[j];
+    }
+    // allocate last plus one matrix
+    DoLog(0) && (Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl);
+    Matrix[MatrixCounter] = new double*[RowCounter[MatrixCounter] + 1];
+    for(int j=0;j<=RowCounter[MatrixCounter];j++)
+      Matrix[MatrixCounter][j] = new double[ColumnCounter[MatrixCounter]];
+    
+    // try independently to parse global energysuffix file if present
+    strncpy(filename, name, 1023);
+    strncat(filename, prefix, 1023-strlen(filename));
+    strncat(filename, suffix.c_str(), 1023-strlen(filename));
+    ParseMatrix(filename, skiplines, skipcolumns, MatrixCounter);
+  }
+  return status;
+};
+
+// ======================================= CLASS ForceMatrix =============================
+
+/** Parsing force Indices of each fragment
+ * \param *name directory with \a ForcesFile
+ * \return parsing successful
+ */
+bool ForceMatrix::ParseIndices(const char *name)
+{
+  ifstream input;
+  char *FragmentNumber = NULL;
+  char filename[1023];
+  stringstream line;
+
+  DoLog(0) && (Log() << Verbose(0) << "Parsing force indices for " << MatrixCounter << " matrices." << endl);
+  Indices = new int*[MatrixCounter + 1];
+  line << name << FRAGMENTPREFIX << FORCESFILE;
+  input.open(line.str().c_str(), ios::in);
+  //Log() << Verbose(0) << "Opening " << line.str() << " ... "  << input << endl;
+  if (input == NULL) {
+    DoLog(0) && (Log() << Verbose(0) << endl << "ForceMatrix::ParseIndices: Unable to open " << line.str() << ", is the directory correct?" << endl);
+    return false;
+  }
+  for (int i=0;(i<MatrixCounter) && (!input.eof());i++) {
+    // get the number of atoms for this fragment
+    input.getline(filename, 1023);
+    line.str(filename);
+    // parse the values
+    Indices[i] = new int[RowCounter[i]];
+    FragmentNumber = FixedDigitNumber(MatrixCounter, i);
+    //Log() << Verbose(0) << FRAGMENTPREFIX << FragmentNumber << "[" << RowCounter[i] << "]:";
+    delete[](FragmentNumber);
+    for(int j=0;(j<RowCounter[i]) && (!line.eof());j++) {
+      line >> Indices[i][j];
+      //Log() << Verbose(0) << " " << Indices[i][j];
+    }
+    //Log() << Verbose(0) << endl;
+  }
+  Indices[MatrixCounter] = new int[RowCounter[MatrixCounter]];
+  for(int j=RowCounter[MatrixCounter];j--;) {
+    Indices[MatrixCounter][j] = j;
+  }
+  input.close();
+  return true;
+};
+
+
+/** Sums the forces and puts into last element of \a ForceMatrix::Matrix.
+ * \param Matrix MatrixContainer with matrices (LevelCounter by *ColumnCounter) with all the energies.
+ * \param KeySets KeySetContainer with bond Order and association mapping of each fragment to an order
+ * \param Order bond order
+ *  \param sign +1 or -1
+ * \return true if summing was successful
+ */
+bool ForceMatrix::SumSubForces(class ForceMatrix &Fragments, class KeySetsContainer &KeySets, int Order, double sign)
+{
+  int FragmentNr;
+  // sum forces
+  for(int i=0;i<KeySets.FragmentsPerOrder[Order];i++) {
+    FragmentNr = KeySets.OrderSet[Order][i];
+    for(int l=0;l<RowCounter[ FragmentNr ];l++) {
+      int j = Indices[ FragmentNr ][l];
+      if (j > RowCounter[MatrixCounter]) {
+        DoeLog(0) && (eLog()<< Verbose(0) << "Current force index " << j << " is greater than " << RowCounter[MatrixCounter] << "!" << endl);
+        performCriticalExit();
+        return false;
+      }
+      if (j != -1) {
+        //if (j == 0) Log() << Verbose(0) << "Summing onto ion 0, type 0 from fragment " << FragmentNr << ", ion " << l << "." << endl;
+        for(int k=2;k<ColumnCounter[MatrixCounter];k++)
+          Matrix[MatrixCounter][j][k] += sign*Fragments.Matrix[ FragmentNr ][l][k];
+      }
+    }
+  }
+  return true;
+};
+
+
+/** Calls MatrixContainer::ParseFragmentMatrix() and additionally allocates last plus one matrix.
+ * \param *name directory with files
+ * \param *prefix prefix of each matrix file
+ * \param *suffix suffix of each matrix file
+ * \param skiplines number of inital lines to skip
+ * \param skiplines number of inital columns to skip
+ * \return parsing successful
+ */
+bool ForceMatrix::ParseFragmentMatrix(const char *name, const char *prefix, string suffix, int skiplines, int skipcolumns)
+{
+  char filename[1023];
+  ifstream input;
+  stringstream file;
+  int nr;
+  bool status = MatrixContainer::ParseFragmentMatrix(name, prefix, suffix, skiplines, skipcolumns);
+
+  if (status) {
+    // count number of atoms for last plus one matrix
+    file << name << FRAGMENTPREFIX << KEYSETFILE;
+    input.open(file.str().c_str(), ios::in);
+    if (input == NULL) {
+      DoLog(0) && (Log() << Verbose(0) << endl << "ForceMatrix::ParseFragmentMatrix: Unable to open " << file.str() << ", is the directory correct?" << endl);
+      return false;
+    }
+    RowCounter[MatrixCounter] = 0;
+    while (!input.eof()) {
+      input.getline(filename, 1023);
+      stringstream zeile(filename);
+      while (!zeile.eof()) {
+        zeile >> nr;
+        //Log() << Verbose(0) << "Current index: " << nr << "." << endl;
+        if (nr > RowCounter[MatrixCounter])
+          RowCounter[MatrixCounter] = nr;
+      }
+    }
+    RowCounter[MatrixCounter]++;    // nr start at 0, count starts at 1
+    input.close();
+
+    ColumnCounter[MatrixCounter] = 0;
+    for(int j=0; j < MatrixCounter;j++) { // (energy matrix might be bigger than number of atoms in terms of rows)
+      if (ColumnCounter[j] > ColumnCounter[MatrixCounter])  // take maximum of all for last matrix
+        ColumnCounter[MatrixCounter] = ColumnCounter[j];
+    }
+  
+    // allocate last plus one matrix
+    DoLog(0) && (Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl);
+    Matrix[MatrixCounter] = new double*[RowCounter[MatrixCounter] + 1];
+    for(int j=0;j<=RowCounter[MatrixCounter];j++)
+      Matrix[MatrixCounter][j] = new double[ColumnCounter[MatrixCounter]];
+
+    // try independently to parse global forcesuffix file if present
+    strncpy(filename, name, 1023);
+    strncat(filename, prefix, 1023-strlen(filename));
+    strncat(filename, suffix.c_str(), 1023-strlen(filename));
+    ParseMatrix(filename, skiplines, skipcolumns, MatrixCounter);
+  }
+ 
+
+  return status;
+};
+
+// ======================================= CLASS HessianMatrix =============================
+
+/** Parsing force Indices of each fragment
+ * \param *name directory with \a ForcesFile
+ * \return parsing successful 
+ */
+bool HessianMatrix::ParseIndices(char *name) 
+{
+  ifstream input;
+  char *FragmentNumber = NULL;
+  char filename[1023];
+  stringstream line;
+  
+  DoLog(0) && (Log() << Verbose(0) << "Parsing hessian indices for " << MatrixCounter << " matrices." << endl);
+  Indices = new int*[MatrixCounter + 1];
+  line << name << FRAGMENTPREFIX << FORCESFILE;
+  input.open(line.str().c_str(), ios::in);
+  //Log() << Verbose(0) << "Opening " << line.str() << " ... "  << input << endl;
+  if (input == NULL) {
+    DoLog(0) && (Log() << Verbose(0) << endl << "HessianMatrix::ParseIndices: Unable to open " << line.str() << ", is the directory correct?" << endl);
+    return false;
+  }
+  for (int i=0;(i<MatrixCounter) && (!input.eof());i++) {
+    // get the number of atoms for this fragment
+    input.getline(filename, 1023);
+    line.str(filename);
+    // parse the values
+    Indices[i] = new int[RowCounter[i]];
+    FragmentNumber = FixedDigitNumber(MatrixCounter, i);
+    //Log() << Verbose(0) << FRAGMENTPREFIX << FragmentNumber << "[" << RowCounter[i] << "]:";
+    delete[](FragmentNumber);
+    for(int j=0;(j<RowCounter[i]) && (!line.eof());j++) {
+      line >> Indices[i][j];
+      //Log() << Verbose(0) << " " << Indices[i][j];
+    }
+    //Log() << Verbose(0) << endl;
+  }
+  Indices[MatrixCounter] = new int[RowCounter[MatrixCounter]];
+  for(int j=RowCounter[MatrixCounter];j--;) {
+    Indices[MatrixCounter][j] = j;
+  }
+  input.close();
+  return true;
+};
+
+
+/** Sums the hessian entries and puts into last element of \a HessianMatrix::Matrix.
+ * \param Matrix MatrixContainer with matrices (LevelCounter by *ColumnCounter) with all the energies.
+ * \param KeySets KeySetContainer with bond Order and association mapping of each fragment to an order
+ * \param Order bond order
+ *  \param sign +1 or -1
+ * \return true if summing was successful
+ */
+bool HessianMatrix::SumSubHessians(class HessianMatrix &Fragments, class KeySetsContainer &KeySets, int Order, double sign)
+{
+  int FragmentNr;
+  // sum forces
+  for(int i=0;i<KeySets.FragmentsPerOrder[Order];i++) {
+    FragmentNr = KeySets.OrderSet[Order][i];
+    for(int l=0;l<RowCounter[ FragmentNr ];l++) {
+      int j = Indices[ FragmentNr ][l];
+      if (j > RowCounter[MatrixCounter]) {
+        DoeLog(0) && (eLog()<< Verbose(0) << "Current hessian index " << j << " is greater than " << RowCounter[MatrixCounter] << ", where i=" << i << ", Order=" << Order << ", l=" << l << " and FragmentNr=" << FragmentNr << "!" << endl);
+        performCriticalExit();
+        return false;
+      }
+      if (j != -1) {
+        for(int m=0;m<ColumnCounter[ FragmentNr ];m++) {
+          int k = Indices[ FragmentNr ][m];
+          if (k > ColumnCounter[MatrixCounter]) {
+            DoeLog(0) && (eLog()<< Verbose(0) << "Current hessian index " << k << " is greater than " << ColumnCounter[MatrixCounter] << ", where m=" << m << ", j=" << j << ", i=" << i << ", Order=" << Order << ", l=" << l << " and FragmentNr=" << FragmentNr << "!" << endl);
+            performCriticalExit();
+            return false;
+          }
+          if (k != -1) {
+            //Log() << Verbose(0) << "Adding " << sign*Fragments.Matrix[ FragmentNr ][l][m] << " from [" << l << "][" << m << "] onto [" << j << "][" << k << "]." << endl;
+            Matrix[MatrixCounter][j][k] += sign*Fragments.Matrix[ FragmentNr ][l][m];
+          }
+        }
+      }
+    }
+  }
+  return true;
+};
+
+/** Constructor for class HessianMatrix.
+ */
+HessianMatrix::HessianMatrix() : MatrixContainer() 
+{
+   IsSymmetric = true;
+}
+
+/** Sums the hessian entries with each factor and put into last element of \a ***Matrix.
+ * Sums over "E"-terms to create the "F"-terms
+ * \param Matrix MatrixContainer with matrices (LevelCounter by *ColumnCounter) with all the energies.
+ * \param KeySets KeySetContainer with bond Order and association mapping of each fragment to an order
+ * \param Order bond order
+ * \return true if summing was successful
+ */
+bool HessianMatrix::SumSubManyBodyTerms(class MatrixContainer &MatrixValues, class KeySetsContainer &KeySets, int Order)
+{
+  // go through each order
+  for (int CurrentFragment=0;CurrentFragment<KeySets.FragmentsPerOrder[Order];CurrentFragment++) {
+    //Log() << Verbose(0) << "Current Fragment is " << CurrentFragment << "/" << KeySets.OrderSet[Order][CurrentFragment] << "." << endl;
+    // then go per order through each suborder and pick together all the terms that contain this fragment
+    for(int SubOrder=0;SubOrder<=Order;SubOrder++) { // go through all suborders up to the desired order
+      for (int j=0;j<KeySets.FragmentsPerOrder[SubOrder];j++) { // go through all possible fragments of size suborder
+        if (KeySets.Contains(KeySets.OrderSet[Order][CurrentFragment], KeySets.OrderSet[SubOrder][j])) {
+          //Log() << Verbose(0) << "Current other fragment is " << j << "/" << KeySets.OrderSet[SubOrder][j] << "." << endl;
+          // if the fragment's indices are all in the current fragment
+          for(int k=0;k<RowCounter[ KeySets.OrderSet[SubOrder][j] ];k++) { // go through all atoms in this fragment
+            int m = MatrixValues.Indices[ KeySets.OrderSet[SubOrder][j] ][k];
+            //Log() << Verbose(0) << "Current row index is " << k << "/" << m << "." << endl;
+            if (m != -1) { // if it's not an added hydrogen
+              for (int l=0;l<RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ];l++) { // look for the corresponding index in the current fragment
+                //Log() << Verbose(0) << "Comparing " << m << " with " << MatrixValues.Indices[ KeySets.OrderSet[Order][CurrentFragment] ][l] << "." << endl;
+                if (m == MatrixValues.Indices[ KeySets.OrderSet[Order][CurrentFragment] ][l]) {
+                  m = l;
+                  break;  
+                }
+              }
+              //Log() << Verbose(0) << "Corresponding row index for " << k << " in CurrentFragment is " << m << "." << endl;
+              if (m > RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ]) {
+                DoeLog(0) && (eLog()<< Verbose(0) << "In fragment No. " << KeySets.OrderSet[Order][CurrentFragment]   << " current row index " << m << " is greater than " << RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ] << "!" << endl);
+                performCriticalExit();
+                return false;
+              }
+              
+              for(int l=0;l<ColumnCounter[ KeySets.OrderSet[SubOrder][j] ];l++) {
+                int n = MatrixValues.Indices[ KeySets.OrderSet[SubOrder][j] ][l];
+                //Log() << Verbose(0) << "Current column index is " << l << "/" << n << "." << endl;
+                if (n != -1) { // if it's not an added hydrogen
+                  for (int p=0;p<ColumnCounter[ KeySets.OrderSet[Order][CurrentFragment] ];p++) { // look for the corresponding index in the current fragment
+                    //Log() << Verbose(0) << "Comparing " << n << " with " << MatrixValues.Indices[ KeySets.OrderSet[Order][CurrentFragment] ][p] << "." << endl;
+                    if (n == MatrixValues.Indices[ KeySets.OrderSet[Order][CurrentFragment] ][p]) {
+                      n = p;
+                      break;  
+                    }
+                  }
+                  //Log() << Verbose(0) << "Corresponding column index for " << l << " in CurrentFragment is " << n << "." << endl;
+                  if (n > ColumnCounter[ KeySets.OrderSet[Order][CurrentFragment] ]) {
+                    DoeLog(0) && (eLog()<< Verbose(0) << "In fragment No. " << KeySets.OrderSet[Order][CurrentFragment]   << " current column index " << n << " is greater than " << ColumnCounter[ KeySets.OrderSet[Order][CurrentFragment] ] << "!" << endl);
+                    performCriticalExit();
+                    return false;
+                  }
+                  if (Order == SubOrder) { // equal order is always copy from Energies
+                    //Log() << Verbose(0) << "Adding " << MatrixValues.Matrix[ KeySets.OrderSet[SubOrder][j] ][k][l] << " from [" << k << "][" << l << "] onto [" << m << "][" << n << "]." << endl;
+                    Matrix[ KeySets.OrderSet[Order][CurrentFragment] ][m][n] += MatrixValues.Matrix[ KeySets.OrderSet[SubOrder][j] ][k][l];
+                  } else {
+                    //Log() << Verbose(0) << "Subtracting " << Matrix[ KeySets.OrderSet[SubOrder][j] ][k][l] << " from [" << k << "][" << l << "] onto [" << m << "][" << n << "]." << endl;
+                    Matrix[ KeySets.OrderSet[Order][CurrentFragment] ][m][n] -= Matrix[ KeySets.OrderSet[SubOrder][j] ][k][l];
+                  }
+                }
+              }
+            }
+            //if ((ColumnCounter[ KeySets.OrderSet[SubOrder][j] ]>1) && (RowCounter[0]-1 >= 1))
+             //Log() << Verbose(0) << "Fragments[ KeySets.OrderSet[" << Order << "][" << CurrentFragment << "]=" << KeySets.OrderSet[Order][CurrentFragment] << " ][" << RowCounter[0]-1 << "][" << 1 << "] = " <<  Matrix[ KeySets.OrderSet[Order][CurrentFragment] ][RowCounter[0]-1][1] << endl;
+          }
+        } else {
+          //Log() << Verbose(0) << "Fragment " << KeySets.OrderSet[SubOrder][j] << " is not contained in fragment " << KeySets.OrderSet[Order][CurrentFragment] << "." << endl;
+        }
+      }
+    }
+   //Log() << Verbose(0) << "Final Fragments[ KeySets.OrderSet[" << Order << "][" << CurrentFragment << "]=" << KeySets.OrderSet[Order][CurrentFragment] << " ][" << KeySets.AtomCounter[0]-1 << "][" << 1 << "] = " <<  Matrix[ KeySets.OrderSet[Order][CurrentFragment] ][KeySets.AtomCounter[0]-1][1] << endl;
+  }
+  
+  return true;
+};
+
+/** Calls MatrixContainer::ParseFragmentMatrix() and additionally allocates last plus one matrix.
+ * \param *name directory with files
+ * \param *prefix prefix of each matrix file
+ * \param *suffix suffix of each matrix file
+ * \param skiplines number of inital lines to skip
+ * \param skiplines number of inital columns to skip
+ * \return parsing successful
+ */ 
+bool HessianMatrix::ParseFragmentMatrix(const char *name, const char *prefix, string suffix, int skiplines, int skipcolumns)
+{
+  char filename[1023];
+  ifstream input;
+  stringstream file;
+  int nr;
+  bool status = MatrixContainer::ParseFragmentMatrix(name, prefix, suffix, skiplines, skipcolumns);
+
+  if (status) {
+    // count number of atoms for last plus one matrix
+    file << name << FRAGMENTPREFIX << KEYSETFILE;
+    input.open(file.str().c_str(), ios::in);
+    if (input == NULL) {
+      DoLog(0) && (Log() << Verbose(0) << endl << "HessianMatrix::ParseFragmentMatrix: Unable to open " << file.str() << ", is the directory correct?" << endl);
+      return false;
+    }
+    RowCounter[MatrixCounter] = 0;
+    ColumnCounter[MatrixCounter] = 0;
+    while (!input.eof()) {
+      input.getline(filename, 1023);
+      stringstream zeile(filename);
+      while (!zeile.eof()) {
+        zeile >> nr;
+        //Log() << Verbose(0) << "Current index: " << nr << "." << endl;
+        if (nr > RowCounter[MatrixCounter]) {
+          RowCounter[MatrixCounter] = nr;
+          ColumnCounter[MatrixCounter] = nr;
+        }
+      }
+    }
+    RowCounter[MatrixCounter]++;    // nr start at 0, count starts at 1
+    ColumnCounter[MatrixCounter]++;    // nr start at 0, count starts at 1
+    input.close();
+  
+    // allocate last plus one matrix
+    DoLog(0) && (Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl);
+    Matrix[MatrixCounter] = new double*[RowCounter[MatrixCounter] + 1];
+    for(int j=0;j<=RowCounter[MatrixCounter];j++)
+      Matrix[MatrixCounter][j] = new double[ColumnCounter[MatrixCounter]];
+
+    // try independently to parse global forcesuffix file if present
+    strncpy(filename, name, 1023);
+    strncat(filename, prefix, 1023-strlen(filename));
+    strncat(filename, suffix.c_str(), 1023-strlen(filename));
+    ParseMatrix(filename, skiplines, skipcolumns, MatrixCounter);
+  }
+
+
+  return status;
+};
+
+// ======================================= CLASS KeySetsContainer =============================
+
+/** Constructor of KeySetsContainer class.
+ */
+KeySetsContainer::KeySetsContainer() {
+  KeySets = NULL;
+  AtomCounter = NULL;
+  FragmentCounter = 0;
+  Order = 0;
+  FragmentsPerOrder = 0;
+  OrderSet = NULL;
+};
+
+/** Destructor of KeySetsContainer class.
+ */
+KeySetsContainer::~KeySetsContainer() {
+  for(int i=FragmentCounter;i--;)
+    delete[](KeySets[i]);
+  for(int i=Order;i--;)
+    delete[](OrderSet[i]);
+  delete[](KeySets);
+  delete[](OrderSet);
+  delete[](AtomCounter);
+  delete[](FragmentsPerOrder);
+};
+
+/** Parsing KeySets into array.
+ * \param *name directory with keyset file
+ * \param *ACounter number of atoms per fragment
+ * \param FCounter number of fragments
+ * \return parsing succesful
+ */
+bool KeySetsContainer::ParseKeySets(const char *name, const int *ACounter, const int FCounter) {
+  ifstream input;
+  char *FragmentNumber = NULL;
+  stringstream file;
+  char filename[1023];
+
+  FragmentCounter = FCounter;
+  DoLog(0) && (Log() << Verbose(0) << "Parsing key sets." << endl);
+  KeySets = new int*[FragmentCounter];
+  for(int i=FragmentCounter;i--;)
+    KeySets[i] = NULL;
+  file << name << FRAGMENTPREFIX << KEYSETFILE;
+  input.open(file.str().c_str(), ios::in);
+  if (input == NULL) {
+    DoLog(0) && (Log() << Verbose(0) << endl << "KeySetsContainer::ParseKeySets: Unable to open " << file.str() << ", is the directory correct?" << endl);
+    return false;
+  }
+
+  AtomCounter = new int[FragmentCounter];
+  for(int i=0;(i<FragmentCounter) && (!input.eof());i++) {
+    stringstream line;
+    AtomCounter[i] = ACounter[i];
+    // parse the values
+    KeySets[i] = new int[AtomCounter[i]];
+    for(int j=AtomCounter[i];j--;)
+      KeySets[i][j] = -1;
+    FragmentNumber = FixedDigitNumber(FragmentCounter, i);
+    //Log() << Verbose(0) << FRAGMENTPREFIX << FragmentNumber << "[" << AtomCounter[i] << "]:";
+    delete[](FragmentNumber);
+    input.getline(filename, 1023);
+    line.str(filename);
+    for(int j=0;(j<AtomCounter[i]) && (!line.eof());j++) {
+      line >> KeySets[i][j];
+      //Log() << Verbose(0) << " " << KeySets[i][j];
+    }
+    //Log() << Verbose(0) << endl;
+  }
+  input.close();
+  return true;
+};
+
+/** Parse many body terms, associating each fragment to a certain bond order.
+ * \return parsing succesful
+ */
+bool KeySetsContainer::ParseManyBodyTerms()
+{
+  int Counter;
+
+  DoLog(0) && (Log() << Verbose(0) << "Creating Fragment terms." << endl);
+  // scan through all to determine maximum order
+  Order=0;
+  for(int i=FragmentCounter;i--;) {
+    Counter=0;
+    for(int j=AtomCounter[i];j--;)
+      if (KeySets[i][j] != -1)
+        Counter++;
+    if (Counter > Order)
+      Order = Counter;
+  }
+  DoLog(0) && (Log() << Verbose(0) << "Found Order is " << Order << "." << endl);
+
+  // scan through all to determine fragments per order
+  FragmentsPerOrder = new int[Order];
+  for(int i=Order;i--;)
+    FragmentsPerOrder[i] = 0;
+  for(int i=FragmentCounter;i--;) {
+    Counter=0;
+    for(int j=AtomCounter[i];j--;)
+      if (KeySets[i][j] != -1)
+        Counter++;
+    FragmentsPerOrder[Counter-1]++;
+  }
+  for(int i=0;i<Order;i++)
+    DoLog(0) && (Log() << Verbose(0) << "Found No. of Fragments of Order " << i+1 << " is " << FragmentsPerOrder[i] << "." << endl);
+
+  // scan through all to gather indices to each order set
+  OrderSet = new int*[Order];
+  for(int i=Order;i--;)
+    OrderSet[i] = new int[FragmentsPerOrder[i]];
+  for(int i=Order;i--;)
+    FragmentsPerOrder[i] = 0;
+  for(int i=FragmentCounter;i--;) {
+    Counter=0;
+    for(int j=AtomCounter[i];j--;)
+      if (KeySets[i][j] != -1)
+        Counter++;
+    OrderSet[Counter-1][FragmentsPerOrder[Counter-1]] = i;
+    FragmentsPerOrder[Counter-1]++;
+  }
+  DoLog(0) && (Log() << Verbose(0) << "Printing OrderSet." << endl);
+  for(int i=0;i<Order;i++) {
+    for (int j=0;j<FragmentsPerOrder[i];j++) {
+      DoLog(0) && (Log() << Verbose(0) << " " << OrderSet[i][j]);
+    }
+    DoLog(0) && (Log() << Verbose(0) << endl);
+  }
+  DoLog(0) && (Log() << Verbose(0) << endl);
+
+
+  return true;
+};
+
+/** Compares each entry in \a *SmallerSet if it is containted in \a *GreaterSet.
+ * \param GreaterSet index to greater set
+ * \param SmallerSet index to smaller set
+ * \return true if all keys of SmallerSet contained in GreaterSet
+ */
+bool KeySetsContainer::Contains(const int GreaterSet, const int SmallerSet)
+{
+  bool result = true;
+  bool intermediate;
+  if ((GreaterSet < 0) || (SmallerSet < 0) || (GreaterSet > FragmentCounter) || (SmallerSet > FragmentCounter)) // index out of bounds
+    return false;
+  for(int i=AtomCounter[SmallerSet];i--;) {
+    intermediate = false;
+    for (int j=AtomCounter[GreaterSet];j--;)
+      intermediate = (intermediate || ((KeySets[SmallerSet][i] == KeySets[GreaterSet][j]) || (KeySets[SmallerSet][i] == -1)));
+    result = result && intermediate;
+  }
+
+  return result;
+};
+
+
+// ======================================= END =============================================
Index: src/parser.hpp
===================================================================
--- src/parser.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/parser.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,138 @@
+/** \file parser.hpp
+ *
+ * Definitions of various class functions for the parsing of value files.
+ *
+ */
+
+
+#ifndef PARSER_HPP_
+#define PARSER_HPP_
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+/****************************************** forward declarations *****************************/
+
+class EnergyMatrix;
+class ForceMatrix;
+class HessianMatrix;
+class KeySetsContainer;
+class MatrixContainer;
+
+/********************************************** definitions *********************************/
+
+#define EnergySuffix ".energy.all"
+#define EnergyFragmentSuffix ".energyfragment.all"
+#define ForcesSuffix ".forces.all"
+#define ForceFragmentSuffix ".forcefragment.all"
+#define HcorrectionSuffix ".Hcorrection.all"
+#define HcorrectionFragmentSuffix ".Hcorrectionfragment.all"
+#define HessianSuffix ".hessian_xx.all"
+#define HessianFragmentSuffix ".hessianfragment_xx.all"
+#define OrderSuffix ".Order"
+#define ShieldingSuffix ".sigma_all.csv"
+#define ShieldingPASSuffix ".sigma_all_PAS.csv"
+#define ShieldingFragmentSuffix ".sigma_all_fragment.all"
+#define ShieldingPASFragmentSuffix ".sigma_all_PAS_fragment.all"
+#define ChiSuffix ".chi_all.csv"
+#define ChiPASSuffix ".chi_all_PAS.csv"
+#define ChiFragmentSuffix ".chi_all_fragment.all"
+#define ChiPASFragmentSuffix ".chi_all_PAS_fragment.all"
+#define TimeSuffix ".speed"
+
+// ======================================= FUNCTIONS ==========================================
+
+bool FilePresent(const char *filename, bool test);
+bool TestParams(int argc, char **argv);
+
+// ======================================= CLASS KeySetsContainer =============================
+
+class KeySetsContainer {
+  public:
+    int **KeySets;
+    int *AtomCounter;
+    int FragmentCounter;
+    int Order;
+    int *FragmentsPerOrder;
+    int **OrderSet;
+
+  KeySetsContainer();
+  ~KeySetsContainer();
+
+  bool ParseKeySets(const char *name, const int *ACounter, const int FCounter);
+  bool ParseManyBodyTerms();
+  bool Contains(const int GreaterSet, const int SmallerSet);
+};
+
+// ======================================= CLASS MatrixContainer =============================
+
+class MatrixContainer {
+  public:
+    double ***Matrix;
+    int **Indices;
+    char **Header;
+    int MatrixCounter;
+    int *RowCounter;
+    int *ColumnCounter;
+  
+  MatrixContainer();
+  virtual ~MatrixContainer();
+  
+  bool InitialiseIndices(class MatrixContainer *Matrix = NULL);
+  bool ParseMatrix(const char *name, int skiplines, int skipcolumns, int MatrixNr);
+  virtual bool ParseFragmentMatrix(const char *name, const char *prefix, string suffix, int skiplines, int skipcolumns);
+  bool AllocateMatrix(char **GivenHeader, int MCounter, int *RCounter, int *CCounter);
+  bool ResetMatrix();
+  double FindMinValue();
+  double FindMaxValue();
+  bool SetLastMatrix(double value, int skipcolumns);
+  bool SetLastMatrix(double **values, int skipcolumns);
+  //bool ParseIndices();
+  //bool SumSubValues();
+  bool SumSubManyBodyTerms(class MatrixContainer &Matrix, class KeySetsContainer &KeySets, int Order);
+  bool WriteTotalFragments(const char *name, const char *prefix);
+  bool WriteLastMatrix(const char *name, const char *prefix, const char *suffix);
+};
+
+// ======================================= CLASS EnergyMatrix =============================
+
+class EnergyMatrix : public MatrixContainer {
+  public:
+    bool ParseIndices();
+    bool SumSubEnergy(class EnergyMatrix &Fragments, class EnergyMatrix *CorrectionFragments, class KeySetsContainer &KeySets, int Order, double sign);
+    bool ParseFragmentMatrix(const char *name, const char *prefix, string suffix, int skiplines, int skipcolumns);
+};
+
+// ======================================= CLASS ForceMatrix =============================
+
+class ForceMatrix : public MatrixContainer {
+  public:
+    bool ParseIndices(const char *name);
+    bool SumSubForces(class ForceMatrix &Fragments, class KeySetsContainer &KeySets, int Order, double sign);
+    bool ParseFragmentMatrix(const char *name, const char *prefix, string suffix, int skiplines, int skipcolumns);
+};
+
+// ======================================= CLASS HessianMatrix =============================
+
+class HessianMatrix : public MatrixContainer { 
+  public: 
+    HessianMatrix();
+    //~HessianMatrix();
+    bool ParseIndices(char *name);
+    bool SumSubManyBodyTerms(class MatrixContainer &MatrixValues, class KeySetsContainer &KeySets, int Order);
+    bool SumSubHessians(class HessianMatrix &Fragments, class KeySetsContainer &KeySets, int Order, double sign);
+    bool ParseFragmentMatrix(const char *name, const char *prefix, string suffix, int skiplines, int skipcolumns);
+  private:
+    bool IsSymmetric;
+};
+
+
+// ======================================= END =============================================
+
+#endif /*PARSER_HPP_*/
Index: src/periodentafel.cpp
===================================================================
--- src/periodentafel.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/periodentafel.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,493 @@
+/** \file periodentafel.cpp
+ *
+ * Function implementations for the class periodentafel.
+ *
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+using namespace std;
+
+#include <iomanip>
+#include <iostream>
+#include <fstream>
+#include <cstring>
+
+#include "Helpers/Assert.hpp"
+#include "element.hpp"
+#include "elements_db.hpp"
+#include "helpers.hpp"
+#include "lists.hpp"
+#include "log.hpp"
+#include "periodentafel.hpp"
+#include "verbose.hpp"
+
+using namespace std;
+
+/************************************* Functions for class periodentafel ***************************/
+
+/** constructor for class periodentafel
+ * Initialises start and end of list and resets periodentafel::checkliste to false.
+ */
+periodentafel::periodentafel()
+{
+  {
+    stringstream input(elementsDB,ios_base::in);
+    bool status = LoadElementsDatabase(&input);
+    ASSERT(status,  "General element initialization failed");
+  }
+  {
+    stringstream input(valenceDB,ios_base::in);
+    bool status = LoadValenceDatabase(&input);
+    ASSERT(status, "Valence entry of element initialization failed");
+  }
+  {
+    stringstream input(orbitalsDB,ios_base::in);
+    bool status = LoadOrbitalsDatabase(&input);
+    ASSERT(status, "Orbitals entry of element initialization failed");
+  }
+  {
+    stringstream input(HbondangleDB,ios_base::in);
+    bool status = LoadHBondAngleDatabase(&input);
+    ASSERT(status, "HBond angle entry of element initialization failed");
+  }
+  {
+    stringstream input(HbonddistanceDB,ios_base::in);
+    bool status = LoadHBondLengthsDatabase(&input);
+    ASSERT(status, "HBond distance entry of element initialization failed");
+  }
+};
+
+/** destructor for class periodentafel
+ * Removes every element and afterwards deletes start and end of list.
+ * TODO: Handle when elements have changed and store databases then
+ */
+periodentafel::~periodentafel()
+{
+  CleanupPeriodtable();
+};
+
+/** Adds element to period table list
+ * \param *pointer element to be added
+ * \return iterator to added element
+ */
+periodentafel::iterator periodentafel::AddElement(element * const 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");
+  pair<iterator,bool> res = elements.insert(pair<atomicNumber_t,element*>(Z,pointer));
+  return res.first;
+};
+
+/** Removes element from list.
+ * \param *pointer element to be removed
+ */
+size_t periodentafel::RemoveElement(element * const pointer)
+{
+  return RemoveElement(pointer->getNumber());
+};
+
+/** Removes element from list.
+ * \param Z element to be removed
+ */
+size_t periodentafel::RemoveElement(atomicNumber_t Z)
+{
+  return elements.erase(Z);
+};
+
+/** Removes every element from the period table.
+ */
+void periodentafel::CleanupPeriodtable()
+{
+  for(iterator iter=elements.begin();iter!=elements.end();++iter){
+    delete(*iter).second;
+  }
+  elements.clear();
+};
+
+/** Finds an element by its atomic number.
+ * If element is not yet in list, returns NULL.
+ * \param Z atomic number
+ * \return pointer to element or NULL if not found
+ */
+element * const periodentafel::FindElement(atomicNumber_t Z) const
+{
+  const_iterator res = elements.find(Z);
+  return res!=elements.end()?((*res).second):0;
+};
+
+/** Finds an element by its atomic number.
+ * If element is not yet in list, datas are asked and stored in database.
+ * \param shorthand chemical symbol of the element, e.g. H for hydrogene
+ * \return pointer to element
+ */
+element * const periodentafel::FindElement(const char * const shorthand) const
+{
+  element *res = 0;
+  for(const_iterator iter=elements.begin();iter!=elements.end();++iter) {
+    if((*iter).second->getSymbol() == shorthand){
+      res = (*iter).second;
+      break;
+    }
+  }
+  return res;
+};
+
+/** Asks for element number and returns pointer to element
+ * \return desired element or NULL
+ */
+element * const periodentafel::AskElement() const
+{
+  element * walker = NULL;
+  int Z;
+  do {
+    DoLog(0) && (Log() << Verbose(0) << "Atomic number Z: ");
+    cin >> Z;
+    walker = this->FindElement(Z);  // give type
+  } while (walker == NULL);
+  return walker;
+};
+
+/** Asks for element and if not found, presents mask to enter info.
+ * \return pointer to either present or newly created element
+ */
+element * const periodentafel::EnterElement()
+{
+  atomicNumber_t Z = 0;
+  DoLog(0) && (Log() << Verbose(0) << "Atomic number: " << Z << endl);
+  cin >> Z;
+  element * const res = FindElement(Z);
+  if (!res) {
+    // TODO: make this using the constructor
+    DoLog(0) && (Log() << Verbose(0) << "Element not found in database, please enter." << endl);
+    element *tmp = new element;
+    tmp->Z = Z;
+    DoLog(0) && (Log() << Verbose(0) << "Mass: " << endl);
+    cin >> tmp->mass;
+    DoLog(0) && (Log() << Verbose(0) << "Name [max 64 chars]: " << endl);
+    cin >> tmp->name;
+    DoLog(0) && (Log() << Verbose(0) << "Short form [max 3 chars]: " << endl);
+    cin >> tmp->symbol;
+    AddElement(tmp);
+    return tmp;
+  }
+  return res;
+};
+
+
+/******************** Access to iterators ****************************/
+periodentafel::const_iterator periodentafel::begin(){
+  return elements.begin();
+}
+
+periodentafel::const_iterator periodentafel::end(){
+  return elements.end();
+}
+
+periodentafel::reverse_iterator periodentafel::rbegin(){
+  return reverse_iterator(elements.end());
+}
+
+periodentafel::reverse_iterator periodentafel::rend(){
+  return reverse_iterator(elements.begin());
+}
+
+/** Prints period table to given stream.
+ * \param output stream
+ */
+bool periodentafel::Output(ostream * const output) const
+{
+  bool result = true;
+  if (output != NULL) {
+    for(const_iterator iter=elements.begin(); iter !=elements.end();++iter){
+      result = result && (*iter).second->Output(output);
+    }
+    return result;
+  } else
+    return false;
+};
+
+/** 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
+ */
+bool periodentafel::LoadPeriodentafel(const char *path)
+{
+  ifstream input;
+  bool status = true;
+  bool otherstatus = true;
+  char filename[255];
+
+  // fill elements DB
+  strncpy(filename, path, MAXSTRINGSIZE);
+  strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
+  strncat(filename, STANDARDELEMENTSDB, MAXSTRINGSIZE-strlen(filename));
+  input.open(filename);
+  if (!input.fail())
+    DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as elements database." << endl);
+  status = status && LoadElementsDatabase(&input);
+  input.close();
+  input.clear();
+
+  // fill valence DB per element
+  strncpy(filename, path, MAXSTRINGSIZE);
+  strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
+  strncat(filename, STANDARDVALENCEDB, MAXSTRINGSIZE-strlen(filename));
+  input.open(filename);
+  if (!input.fail())
+    DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as valence database." << endl);
+  otherstatus = otherstatus && LoadValenceDatabase(&input);
+  input.close();
+  input.clear();
+
+  // fill orbitals DB per element
+  strncpy(filename, path, MAXSTRINGSIZE);
+  strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
+  strncat(filename, STANDARDORBITALDB, MAXSTRINGSIZE-strlen(filename));
+  input.open(filename);
+  if (!input.fail())
+    DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as orbitals database." << endl);
+  otherstatus = otherstatus && LoadOrbitalsDatabase(&input);
+  input.close();
+  input.clear();
+
+  // fill H-BondAngle DB per element
+  strncpy(filename, path, MAXSTRINGSIZE);
+  strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
+  strncat(filename, STANDARDHBONDANGLEDB, MAXSTRINGSIZE-strlen(filename));
+  input.open(filename);
+  if (!input.fail())
+    DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as H bond angle database." << endl);
+  otherstatus = otherstatus && LoadHBondAngleDatabase(&input);
+  input.close();
+  input.clear();
+
+  // fill H-BondDistance DB per element
+  strncpy(filename, path, MAXSTRINGSIZE);
+  strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
+  strncat(filename, STANDARDHBONDDISTANCEDB, MAXSTRINGSIZE-strlen(filename));
+  input.open(filename);
+  if (!input.fail())
+    DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as H bond length database." << endl);
+  otherstatus = otherstatus && LoadHBondLengthsDatabase(&input);
+  input.close();
+  input.clear();
+
+  if (!otherstatus){
+    DoeLog(2) && (eLog()<< Verbose(2) << "Something went wrong while parsing the other databases!" << endl);
+  }
+
+  return status;
+};
+
+/** load the element info.
+ * \param *input stream to parse from
+ * \return true - parsing successful, false - something went wrong
+ */
+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
+    DoLog(0) && (Log() << Verbose(0) <<  "Parsed elements:");
+    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;
+      //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++;
+      } else {
+        DoeLog(2) && (eLog() << Verbose(2) << "Detected empty line or invalid element in elements db, discarding." << endl);
+        DoLog(0) && (Log() << Verbose(0) << " <?>");
+        delete(neues);
+      }
+    }
+    DoLog(0) && (Log() << Verbose(0) << endl);
+  } else {
+    DoeLog(1) && (eLog() << Verbose(1) << "Could not open the database." << endl);
+    status = false;
+  }
+
+  if (counter == 0)
+    status = false;
+
+  return status;
+}
+
+/** load the valence info.
+ * \param *input stream to parse from
+ * \return true - parsing successful, false - something went wrong
+ */
+bool periodentafel::LoadValenceDatabase(istream *input)
+{
+  char dummy[MAXSTRINGSIZE];
+  if (!(*input).fail()) {
+    (*input).getline(dummy, MAXSTRINGSIZE);
+    while (!(*input).eof()) {
+      atomicNumber_t Z;
+      (*input) >> Z;
+      ASSERT(elements.count(Z), "Element not present");
+      (*input) >> ws;
+      (*input) >> elements[Z]->Valence;
+      (*input) >> ws;
+      //Log() << Verbose(3) << "Element " << Z << " has " << FindElement(Z)->Valence << " valence electrons." << endl;
+    }
+    return true;
+  } else
+		return false;
+}
+
+/** load the orbitals info.
+ * \param *input stream to parse from
+ * \return true - parsing successful, false - something went wrong
+ */
+bool periodentafel::LoadOrbitalsDatabase(istream *input)
+{
+  char dummy[MAXSTRINGSIZE];
+  if (!(*input).fail()) {
+    (*input).getline(dummy, MAXSTRINGSIZE);
+    while (!(*input).eof()) {
+      atomicNumber_t Z;
+      (*input) >> Z;
+      ASSERT(elements.count(Z), "Element not present");
+      (*input) >> ws;
+      (*input) >> elements[Z]->NoValenceOrbitals;
+      (*input) >> ws;
+      //Log() << Verbose(3) << "Element " << Z << " has " << FindElement(Z)->NoValenceOrbitals << " number of singly occupied valence orbitals." << endl;
+    }
+    return true;
+  } else
+    return false;
+}
+
+/** load the hbond angles info.
+ * \param *input stream to parse from
+ * \return true - parsing successful, false - something went wrong
+ */
+bool periodentafel::LoadHBondAngleDatabase(istream *input)
+{
+  char dummy[MAXSTRINGSIZE];
+  if (!(*input).fail()) {
+    (*input).getline(dummy, MAXSTRINGSIZE);
+    while (!(*input).eof()) {
+      atomicNumber_t Z;
+      (*input) >> Z;
+      ASSERT(elements.count(Z), "Element not present");
+      (*input) >> ws;
+      (*input) >> elements[Z]->HBondAngle[0];
+      (*input) >> elements[Z]->HBondAngle[1];
+      (*input) >> elements[Z]->HBondAngle[2];
+      (*input) >> ws;
+      //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->HBondAngle[0] << ", " << FindElement((int)tmp)->HBondAngle[1] << ", " << FindElement((int)tmp)->HBondAngle[2] << " degrees bond angle for one, two, three connected hydrogens." << endl;
+    }
+    return true;
+  } else
+		return false;
+}
+
+/** load the hbond lengths info.
+ * \param *input stream to parse from
+ * \return true - parsing successful, false - something went wrong
+ */
+bool periodentafel::LoadHBondLengthsDatabase(istream *input)
+{
+  char dummy[MAXSTRINGSIZE];
+  if (!(*input).fail()) {
+    (*input).getline(dummy, MAXSTRINGSIZE);
+    while (!(*input).eof()) {
+      atomicNumber_t Z;
+      (*input) >> Z;
+      ASSERT(elements.count(Z), "Element not present");
+      (*input) >> ws;
+      (*input) >> elements[Z]->HBondDistance[0];
+      (*input) >> elements[Z]->HBondDistance[1];
+      (*input) >> elements[Z]->HBondDistance[2];
+      (*input) >> ws;
+      //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->HBondDistance[0] << " Angstrom typical distance to hydrogen." << endl;
+    }
+    return true;
+  } else
+		return false;
+}
+
+/** Stores element list to file.
+ */
+bool periodentafel::StorePeriodentafel(const char *path) const
+{
+  bool result = true;
+  ofstream f;
+  char filename[MAXSTRINGSIZE];
+
+  strncpy(filename, path, MAXSTRINGSIZE);
+  strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
+  strncat(filename, STANDARDELEMENTSDB, MAXSTRINGSIZE-strlen(filename));
+  f.open(filename);
+  if (f != NULL) {
+    f << header1 << endl;
+    f << header2 << endl;
+    for(const_iterator iter=elements.begin();iter!=elements.end();++iter){
+         result = result && (*iter).second->Output(&f);
+    }
+    f.close();
+    return true;
+  } else
+    return result;
+};
Index: src/periodentafel.hpp
===================================================================
--- src/periodentafel.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/periodentafel.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,75 @@
+#ifndef PERIODENTAFEL_HPP_
+#define PERIODENTAFEL_HPP_
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <iostream>
+#include <map>
+#include <iterator>
+
+#include "unittests/periodentafelTest.hpp"
+#include "defs.hpp"
+#include "types.hpp"
+
+/****************************************** forward declarations *****************************/
+
+class element;
+
+/********************************************** declarations *******************************/
+
+
+/** Periodentafel is a list of all elements sorted by their atomic number.
+ */
+class periodentafel {
+  /******* Types *********/
+  friend class periodentafelTest;
+  private:
+    typedef std::map<atomicNumber_t,element*> elementSet;
+  public:
+    typedef elementSet::iterator iterator;
+    typedef elementSet::const_iterator const_iterator;
+    typedef std::reverse_iterator<const_iterator> reverse_iterator;
+  public:
+
+    char header1[MAXSTRINGSIZE]; //!< store first header line
+    char header2[MAXSTRINGSIZE]; //!< store second header line
+
+  periodentafel();
+  ~periodentafel();
+
+  iterator AddElement(element * const pointer);
+  size_t RemoveElement(element * const 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_iterator begin();
+  const_iterator end();
+  reverse_iterator rbegin();
+  reverse_iterator rend();
+  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;
+
+  private:
+
+  bool LoadElementsDatabase(std::istream *input);
+  bool LoadValenceDatabase(std::istream *input);
+  bool LoadOrbitalsDatabase(std::istream *input);
+  bool LoadHBondAngleDatabase(std::istream *input);
+  bool LoadHBondLengthsDatabase(std::istream *input);
+
+    elementSet elements;
+};
+
+
+#endif /*PERIODENTAFEL_HPP_*/
Index: src/stackclass.hpp
===================================================================
--- src/stackclass.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/stackclass.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,229 @@
+#ifndef STACKCLASS_HPP_
+#define STACKCLASS_HPP_
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "verbose.hpp"
+#include "memoryallocator.hpp"
+
+/****************************************** forward declarations *****************************/
+
+template <typename T> class StackClass;
+
+/******************************** Functions for class StackClass ********************************/
+
+/* Stack of Stuff.
+ * Is used during DepthFirstSearchAnalysis() to detect nonseparable components.
+ */
+template <typename T> class StackClass {
+  public:
+  StackClass<T>(int dimension);
+  ~StackClass<T>();
+
+  bool Push(T object);
+  T PopFirst();
+  T PopLast();
+  bool RemoveItem(T ptr);
+  void ClearStack();
+  bool IsEmpty() const;
+  bool IsFull() const;
+  int ItemCount() const;
+  void Output(ofstream * const out) const;
+
+  private:
+    T *StackList;   //!< the list containing the atom pointers
+    int EntryCount;     //!< number of entries in the stack
+    int CurrentLastEntry;   //!< Current last entry (newest item on stack)
+    int CurrentFirstEntry;   //!< Current first entry (oldest item on stack)
+    int NextFreeField;       //!< Current index of next free field
+};
+
+/** Constructor of class StackClass.
+ */
+template <typename T> StackClass<T>::StackClass(int dimension) : StackList(NULL), EntryCount(dimension), CurrentLastEntry(0), CurrentFirstEntry(0), NextFreeField(0)
+{
+  StackList = new T[EntryCount];
+  for (int i=0;i<EntryCount;i++)
+    StackList[i] = NULL;
+};
+
+/** Destructor of class StackClass.
+ */
+template <typename T> StackClass<T>::~StackClass()
+{
+  delete[](StackList);
+};
+
+/** Pushes an object onto the stack.
+ * \param *object atom to be pushed on stack
+ * \return true - sucess, false - failure, meaning stack field was occupied
+ */
+template <typename T> bool StackClass<T>::Push(T object)
+{
+  if (!IsFull()) {    // check whether free field is really not occupied
+    StackList[NextFreeField] = object;
+    CurrentLastEntry = NextFreeField;
+    NextFreeField = (NextFreeField + 1) % EntryCount; // step on to next free field
+    return true;
+  } else {
+    DoeLog(1) && (eLog()<< Verbose(1) << "Stack is full, " << "Stack: CurrentLastEntry " << CurrentLastEntry<< "\tCurrentFirstEntry " << CurrentFirstEntry << "\tNextFreeField " << NextFreeField << "\tEntryCount " << EntryCount << "!" << endl);
+    return false;
+  }
+};
+
+/** Pops first/oldest atom from stack.
+ * First in, last out.
+ * \return atom pointer from stack, NULL - if failure (no atom pointer in field)
+ */
+template <typename T> T StackClass<T>::PopFirst()
+{
+  T Walker = NULL;
+  if (!IsEmpty()) {
+    Walker = StackList[CurrentFirstEntry];
+    if (Walker == NULL)
+      DoeLog(1) && (eLog()<< Verbose(1) << "Stack's field is empty!" << endl);
+    StackList[CurrentFirstEntry] = NULL;
+    if (CurrentFirstEntry != CurrentLastEntry) { // hasn't last item been popped as well?
+      CurrentFirstEntry = (CurrentFirstEntry + 1) % EntryCount; // step back from current free field to last used (somehow modulo does not work in -1)
+    } else {
+      CurrentFirstEntry = (CurrentFirstEntry + 1) % EntryCount; // step back from current free field to last used (somehow modulo does not work in -1)
+      CurrentLastEntry = CurrentFirstEntry;
+    }
+  } else
+    DoeLog(1) && (eLog()<< Verbose(1) << "Stack is empty!" << endl);
+  return Walker;
+};
+
+/** Pops last element from stack.
+ * First in, first out.
+ * \return element pointer from stack, NULL - if failure (no atom pointer in field)
+ */
+template <typename T> T StackClass<T>::PopLast()
+{
+  T Walker = NULL;
+  if (!IsEmpty()) {
+    Walker = StackList[CurrentLastEntry];
+    StackList[CurrentLastEntry] = NULL;
+    if (Walker == NULL)
+      DoeLog(1) && (eLog()<< Verbose(1) << "Stack's field is empty!" << endl);
+    NextFreeField = CurrentLastEntry;
+    if (CurrentLastEntry != CurrentFirstEntry)  // has there been more than one item on stack
+      CurrentLastEntry = (CurrentLastEntry + (EntryCount-1)) % EntryCount; // step back from current free field to last (modulo does not work in -1, thus go EntryCount-1 instead)
+  } else {
+    DoeLog(1) && (eLog()<< Verbose(1) << "Stack is empty!" << endl);
+  }
+  return Walker;
+};
+
+/** Removes a certain item from the stack.
+ * Item is seeked between \a CurrentFirstEntry and \a CurrentLastEntry, if found, place in stack is NULL'd and
+ * all subsequent items shifted by one position downward (with wrapping taken into account).
+ * \param *ptr adress of item
+ * \return true - item was removed, false - item was not found
+ */
+template <typename T> bool StackClass<T>::RemoveItem(T ptr)
+{
+  bool found = false;
+  DoLog(5) && (Log() << Verbose(5) << "First " << CurrentFirstEntry<< "\tLast " << CurrentLastEntry<< "\tNext " << NextFreeField<< "\tCount " << EntryCount<< "." << endl);
+  int i=CurrentFirstEntry;
+  if (!IsEmpty())
+    do {
+      if (StackList[i] == ptr) {  // if item found, remove
+        DoLog(5) && (Log() << Verbose(5) << "Item " << *ptr << " was number " << i << " on stack, removing it." << endl);
+        found = true;
+        StackList[i] = NULL;
+      }
+      if ((found) && (StackList[i] != NULL)) {  // means we have to shift (and not the removed item)
+        if (i == 0) { // we are down to first item in stack, have to put onto last item
+          DoLog(5) && (Log() << Verbose(5) << "Shifting item 0 to place " << EntryCount-1 << "." << endl);
+          StackList[EntryCount-1] = StackList[0];
+        } else {
+          DoLog(5) && (Log() << Verbose(5) << "Shifting item " << i << " to place " << i-1 << "." << endl);
+          StackList[i-1] = StackList[i];
+        }
+      }
+      i=((i + 1) % EntryCount); // step on
+    } while (i!=NextFreeField);
+  else
+    DoeLog(1) && (eLog()<< Verbose(1) << "Stack is already empty!" << endl);
+  if (found) {
+    NextFreeField = CurrentLastEntry;
+    if (CurrentLastEntry != CurrentFirstEntry)  // has there been more than one item on stack
+      CurrentLastEntry = (CurrentLastEntry + (EntryCount-1)) % EntryCount;
+  }
+  return found;
+};
+
+
+/** Puts contents of stack into ofstream \a *out.
+ * \param *out ofstream for output
+ */
+template <typename T> void StackClass<T>::Output(ofstream * const out) const
+{
+  *out << "Contents of Stack: ";
+  for(int i=0;i<EntryCount;i++) {
+    *out << "\t";
+    if (i == CurrentFirstEntry)
+      *out << " 1";
+    if  (i == CurrentLastEntry)
+      *out << " "<< EntryCount;
+    if (i ==  NextFreeField)
+      *out << " F";
+    *out << ": " << StackList[i];
+  }
+  *out << endl;
+};
+
+/** Checks whether stack is empty.
+ * Simply checks whether StackClass::NextFreeField is equal to StackClass::CurrentFirstEntry and
+ * StackClass::CurrentFirstEntry is equal to StackClass::CurrentLastEntry.
+ * \return true - empty, false - not
+ */
+template <typename T> bool StackClass<T>::IsEmpty() const
+{
+  return((NextFreeField == CurrentFirstEntry) && (CurrentLastEntry == CurrentFirstEntry));
+};
+
+/** Checks whether stack is full.
+ * Simply checks whether StackClass::NextFreeField is equal to StackClass::CurrentFirstEntry and
+ * StackClass::CurrentFirstEntry is _not_ equal to StackClass::CurrentLastEntry.
+ * \return true - full, false - not
+ */
+template <typename T> bool StackClass<T>::IsFull() const
+{
+  return((NextFreeField == CurrentFirstEntry) && (CurrentLastEntry != CurrentFirstEntry));
+};
+
+/** Returns number of items on stack.
+ * Simply returns difference between StackClass::Stacklist entry StackClass::CurrentEntry-1.
+ * \return number of items on stack
+ * \warning will never return correct item count if stack is full, i.e. count would be StackClass::EntryCount.
+ */
+template <typename T> int StackClass<T>::ItemCount() const
+{
+  //Log() << Verbose(0) << "Stack: CurrentLastEntry " << CurrentLastEntry<< "\tCurrentFirstEntry " << CurrentFirstEntry << "\tEntryCount " << EntryCount << "." << endl;
+  return((NextFreeField + (EntryCount - CurrentFirstEntry)) % EntryCount);
+};
+
+/** Clears the stack from all atoms.
+ * \return true - sucess, false - failure
+ */
+template <typename T> void StackClass<T>::ClearStack()
+{
+  for(int i=EntryCount; i--;)
+    StackList[i] = NULL;
+  CurrentFirstEntry = 0;
+  CurrentLastEntry = 0;
+  NextFreeField = 0;
+};
+
+
+
+#endif /*STACKCLASS_HPP_*/
Index: src/tesselation.cpp
===================================================================
--- src/tesselation.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/tesselation.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,5090 @@
+/*
+ * tesselation.cpp
+ *
+ *  Created on: Aug 3, 2009
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include <fstream>
+
+#include "helpers.hpp"
+#include "info.hpp"
+#include "linkedcell.hpp"
+#include "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 "Exceptions/LinearDependenceException.hpp"
+#include "Helpers/Assert.hpp"
+
+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 ===========================================
+
+/** Constructor of class Tesselation.
+ */
+Tesselation::Tesselation() :
+  PointsOnBoundaryCount(0), LinesOnBoundaryCount(0), TrianglesOnBoundaryCount(0), LastTriangle(NULL), TriangleFilesWritten(0), InternalPointer(PointsOnBoundary.begin())
+{
+  Info FunctionInfo(__func__);
+}
+;
+
+/** Destructor of class Tesselation.
+ * We have to free all points, lines and triangles.
+ */
+Tesselation::~Tesselation()
+{
+  Info FunctionInfo(__func__);
+  DoLog(0) && (Log() << Verbose(0) << "Free'ing TesselStruct ... " << endl);
+  for (TriangleMap::iterator runner = TrianglesOnBoundary.begin(); runner != TrianglesOnBoundary.end(); runner++) {
+    if (runner->second != NULL) {
+      delete (runner->second);
+      runner->second = NULL;
+    } else
+      DoeLog(1) && (eLog() << Verbose(1) << "The triangle " << runner->first << " has already been free'd." << endl);
+  }
+  DoLog(0) && (Log() << Verbose(0) << "This envelope was written to file " << TriangleFilesWritten << " times(s)." << endl);
+}
+;
+
+/** PointCloud implementation of GetCenter
+ * Uses PointsOnBoundary and STL stuff.
+ */
+Vector * Tesselation::GetCenter(ofstream *out) const
+{
+  Info FunctionInfo(__func__);
+  Vector *Center = new Vector(0., 0., 0.);
+  int num = 0;
+  for (GoToFirst(); (!IsEnd()); GoToNext()) {
+    (*Center) += (*GetPoint()->node);
+    num++;
+  }
+  Center->Scale(1. / num);
+  return Center;
+}
+;
+
+/** PointCloud implementation of GoPoint
+ * Uses PointsOnBoundary and STL stuff.
+ */
+TesselPoint * Tesselation::GetPoint() const
+{
+  Info FunctionInfo(__func__);
+  return (InternalPointer->second->node);
+}
+;
+
+/** PointCloud implementation of GoToNext.
+ * Uses PointsOnBoundary and STL stuff.
+ */
+void Tesselation::GoToNext() const
+{
+  Info FunctionInfo(__func__);
+  if (InternalPointer != PointsOnBoundary.end())
+    InternalPointer++;
+}
+;
+
+/** PointCloud implementation of GoToFirst.
+ * Uses PointsOnBoundary and STL stuff.
+ */
+void Tesselation::GoToFirst() const
+{
+  Info FunctionInfo(__func__);
+  InternalPointer = PointsOnBoundary.begin();
+}
+;
+
+/** PointCloud implementation of IsEmpty.
+ * Uses PointsOnBoundary and STL stuff.
+ */
+bool Tesselation::IsEmpty() const
+{
+  Info FunctionInfo(__func__);
+  return (PointsOnBoundary.empty());
+}
+;
+
+/** PointCloud implementation of IsLast.
+ * Uses PointsOnBoundary and STL stuff.
+ */
+bool Tesselation::IsEnd() const
+{
+  Info FunctionInfo(__func__);
+  return (InternalPointer == PointsOnBoundary.end());
+}
+;
+
+/** Gueses first starting triangle of the convex envelope.
+ * We guess the starting triangle by taking the smallest distance between two points and looking for a fitting third.
+ * \param *out output stream for debugging
+ * \param PointsOnBoundary set of boundary points defining the convex envelope of the cluster
+ */
+void Tesselation::GuessStartingTriangle()
+{
+  Info FunctionInfo(__func__);
+  // 4b. create a starting triangle
+  // 4b1. create all distances
+  DistanceMultiMap DistanceMMap;
+  double distance, tmp;
+  Vector PlaneVector, TrialVector;
+  PointMap::iterator A, B, C; // three nodes of the first triangle
+  A = PointsOnBoundary.begin(); // the first may be chosen arbitrarily
+
+  // with A chosen, take each pair B,C and sort
+  if (A != PointsOnBoundary.end()) {
+    B = A;
+    B++;
+    for (; B != PointsOnBoundary.end(); B++) {
+      C = B;
+      C++;
+      for (; C != PointsOnBoundary.end(); C++) {
+        tmp = A->second->node->node->DistanceSquared(*B->second->node->node);
+        distance = tmp * tmp;
+        tmp = A->second->node->node->DistanceSquared(*C->second->node->node);
+        distance += tmp * tmp;
+        tmp = B->second->node->node->DistanceSquared(*C->second->node->node);
+        distance += tmp * tmp;
+        DistanceMMap.insert(DistanceMultiMapPair(distance, pair<PointMap::iterator, PointMap::iterator> (B, C)));
+      }
+    }
+  }
+  //    // listing distances
+  //    Log() << Verbose(1) << "Listing DistanceMMap:";
+  //    for(DistanceMultiMap::iterator runner = DistanceMMap.begin(); runner != DistanceMMap.end(); runner++) {
+  //      Log() << Verbose(0) << " " << runner->first << "(" << *runner->second.first->second << ", " << *runner->second.second->second << ")";
+  //    }
+  //    Log() << Verbose(0) << endl;
+  // 4b2. pick three baselines forming a triangle
+  // 1. we take from the smallest sum of squared distance as the base line BC (with peak A) onward as the triangle candidate
+  DistanceMultiMap::iterator baseline = DistanceMMap.begin();
+  for (; baseline != DistanceMMap.end(); baseline++) {
+    // we take from the smallest sum of squared distance as the base line BC (with peak A) onward as the triangle candidate
+    // 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();
+    DoLog(2) && (Log() << Verbose(2) << "Plane vector of candidate triangle is " << PlaneVector << endl);
+    // 4. loop over all points
+    double sign = 0.;
+    PointMap::iterator checker = PointsOnBoundary.begin();
+    for (; checker != PointsOnBoundary.end(); checker++) {
+      // (neglecting A,B,C)
+      if ((checker == A) || (checker == baseline->second.first) || (checker == baseline->second.second))
+        continue;
+      // 4a. project onto plane vector
+      TrialVector = (*checker->second->node->node);
+      TrialVector.SubtractVector(*A->second->node->node);
+      distance = TrialVector.ScalarProduct(PlaneVector);
+      if (fabs(distance) < 1e-4) // we need to have a small epsilon around 0 which is still ok
+        continue;
+      DoLog(2) && (Log() << Verbose(2) << "Projection of " << checker->second->node->getName() << " yields distance of " << distance << "." << endl);
+      tmp = distance / fabs(distance);
+      // 4b. Any have different sign to than before? (i.e. would lie outside convex hull with this starting triangle)
+      if ((sign != 0) && (tmp != sign)) {
+        // 4c. If so, break 4. loop and continue with next candidate in 1. loop
+        DoLog(2) && (Log() << Verbose(2) << "Current candidates: " << A->second->node->getName() << "," << baseline->second.first->second->node->getName() << "," << baseline->second.second->second->node->getName() << " leaves " << checker->second->node->getName() << " outside the convex hull." << endl);
+        break;
+      } else { // note the sign for later
+        DoLog(2) && (Log() << Verbose(2) << "Current candidates: " << A->second->node->getName() << "," << baseline->second.first->second->node->getName() << "," << baseline->second.second->second->node->getName() << " leave " << checker->second->node->getName() << " inside the convex hull." << endl);
+        sign = tmp;
+      }
+      // 4d. Check whether the point is inside the triangle (check distance to each node
+      tmp = checker->second->node->node->DistanceSquared(*A->second->node->node);
+      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)))
+        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)))
+        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)))
+        innerpoint++;
+      // 4e. If so, break 4. loop and continue with next candidate in 1. loop
+      if (innerpoint == 3)
+        break;
+    }
+    // 5. come this far, all on same side? Then break 1. loop and construct triangle
+    if (checker == PointsOnBoundary.end()) {
+      DoLog(2) && (Log() << Verbose(2) << "Looks like we have a candidate!" << endl);
+      break;
+    }
+  }
+  if (baseline != DistanceMMap.end()) {
+    BPS[0] = baseline->second.first->second;
+    BPS[1] = baseline->second.second->second;
+    BLS[0] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount);
+    BPS[0] = A->second;
+    BPS[1] = baseline->second.second->second;
+    BLS[1] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount);
+    BPS[0] = baseline->second.first->second;
+    BPS[1] = A->second;
+    BLS[2] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount);
+
+    // 4b3. insert created triangle
+    BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
+    TrianglesOnBoundary.insert(TrianglePair(TrianglesOnBoundaryCount, BTS));
+    TrianglesOnBoundaryCount++;
+    for (int i = 0; i < NDIM; i++) {
+      LinesOnBoundary.insert(LinePair(LinesOnBoundaryCount, BTS->lines[i]));
+      LinesOnBoundaryCount++;
+    }
+
+    DoLog(1) && (Log() << Verbose(1) << "Starting triangle is " << *BTS << "." << endl);
+  } else {
+    DoeLog(0) && (eLog() << Verbose(0) << "No starting triangle found." << endl);
+  }
+}
+;
+
+/** Tesselates the convex envelope of a cluster from a single starting triangle.
+ * The starting triangle is made out of three baselines. Each line in the final tesselated cluster may belong to at most
+ * 2 triangles. Hence, we go through all current lines:
+ * -# if the lines contains to only one triangle
+ * -# We search all points in the boundary
+ *    -# if the triangle is in forward direction of the baseline (at most 90 degrees angle between vector orthogonal to
+ *       baseline in triangle plane pointing out of the triangle and normal vector of new triangle)
+ *    -# if the triangle with the baseline and the current point has the smallest of angles (comparison between normal vectors)
+ *    -# then we have a new triangle, whose baselines we again add (or increase their TriangleCount)
+ * \param *out output stream for debugging
+ * \param *configuration for IsAngstroem
+ * \param *cloud cluster of points
+ */
+void Tesselation::TesselateOnBoundary(const PointCloud * const cloud)
+{
+  Info FunctionInfo(__func__);
+  bool flag;
+  PointMap::iterator winner;
+  class BoundaryPointSet *peak = NULL;
+  double SmallestAngle, TempAngle;
+  Vector NormalVector, VirtualNormalVector, CenterVector, TempVector, helper, PropagationVector, *Center = NULL;
+  LineMap::iterator LineChecker[2];
+
+  Center = cloud->GetCenter();
+  // create a first tesselation with the given BoundaryPoints
+  do {
+    flag = false;
+    for (LineMap::iterator baseline = LinesOnBoundary.begin(); baseline != LinesOnBoundary.end(); baseline++)
+      if (baseline->second->triangles.size() == 1) {
+        // 5a. go through each boundary point if not _both_ edges between either endpoint of the current line and this point exist (and belong to 2 triangles)
+        SmallestAngle = M_PI;
+
+        // get peak point with respect to this base line's only triangle
+        BTS = baseline->second->triangles.begin()->second; // there is only one triangle so far
+        DoLog(0) && (Log() << Verbose(0) << "Current baseline is between " << *(baseline->second) << "." << endl);
+        for (int i = 0; i < 3; i++)
+          if ((BTS->endpoints[i] != baseline->second->endpoints[0]) && (BTS->endpoints[i] != baseline->second->endpoints[1]))
+            peak = BTS->endpoints[i];
+        DoLog(1) && (Log() << Verbose(1) << " and has peak " << *peak << "." << endl);
+
+        // 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);
+
+        // offset to center of triangle
+        CenterVector.Zero();
+        for (int i = 0; i < 3; i++)
+          CenterVector += BTS->getEndpoint(i);
+        CenterVector.Scale(1. / 3.);
+        DoLog(2) && (Log() << Verbose(2) << "CenterVector of base triangle is " << CenterVector << endl);
+
+        // normal vector of triangle
+        NormalVector = (*Center) - CenterVector;
+        BTS->GetNormalVector(NormalVector);
+        NormalVector = BTS->NormalVector;
+        DoLog(2) && (Log() << Verbose(2) << "NormalVector of base triangle is " << NormalVector << endl);
+
+        // vector in propagation direction (out of triangle)
+        // 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!
+        //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
+          PropagationVector.Scale(-1.);
+        DoLog(2) && (Log() << Verbose(2) << "PropagationVector of base triangle is " << PropagationVector << endl);
+        winner = PointsOnBoundary.end();
+
+        // loop over all points and calculate angle between normal vector of new and present triangle
+        for (PointMap::iterator target = PointsOnBoundary.begin(); target != PointsOnBoundary.end(); target++) {
+          if ((target->second != baseline->second->endpoints[0]) && (target->second != baseline->second->endpoints[1])) { // don't take the same endpoints
+            DoLog(1) && (Log() << Verbose(1) << "Target point is " << *(target->second) << ":" << endl);
+
+            // first check direction, so that triangles don't intersect
+            VirtualNormalVector = (*target->second->node->node) - BaseLineCenter;
+            VirtualNormalVector.ProjectOntoPlane(NormalVector);
+            TempAngle = VirtualNormalVector.Angle(PropagationVector);
+            DoLog(2) && (Log() << Verbose(2) << "VirtualNormalVector is " << VirtualNormalVector << " and PropagationVector is " << PropagationVector << "." << endl);
+            if (TempAngle > (M_PI / 2.)) { // no bends bigger than Pi/2 (90 degrees)
+              DoLog(2) && (Log() << Verbose(2) << "Angle on triangle plane between propagation direction and base line to " << *(target->second) << " is " << TempAngle << ", bad direction!" << endl);
+              continue;
+            } else
+              DoLog(2) && (Log() << Verbose(2) << "Angle on triangle plane between propagation direction and base line to " << *(target->second) << " is " << TempAngle << ", good direction!" << endl);
+
+            // check first and second endpoint (if any connecting line goes to target has at least not more than 1 triangle)
+            LineChecker[0] = baseline->second->endpoints[0]->lines.find(target->first);
+            LineChecker[1] = baseline->second->endpoints[1]->lines.find(target->first);
+            if (((LineChecker[0] != baseline->second->endpoints[0]->lines.end()) && (LineChecker[0]->second->triangles.size() == 2))) {
+              DoLog(2) && (Log() << Verbose(2) << *(baseline->second->endpoints[0]) << " has line " << *(LineChecker[0]->second) << " to " << *(target->second) << " as endpoint with " << LineChecker[0]->second->triangles.size() << " triangles." << endl);
+              continue;
+            }
+            if (((LineChecker[1] != baseline->second->endpoints[1]->lines.end()) && (LineChecker[1]->second->triangles.size() == 2))) {
+              DoLog(2) && (Log() << Verbose(2) << *(baseline->second->endpoints[1]) << " has line " << *(LineChecker[1]->second) << " to " << *(target->second) << " as endpoint with " << LineChecker[1]->second->triangles.size() << " triangles." << endl);
+              continue;
+            }
+
+            // check whether the envisaged triangle does not already exist (if both lines exist and have same endpoint)
+            if ((((LineChecker[0] != baseline->second->endpoints[0]->lines.end()) && (LineChecker[1] != baseline->second->endpoints[1]->lines.end()) && (GetCommonEndpoint(LineChecker[0]->second, LineChecker[1]->second) == peak)))) {
+              DoLog(4) && (Log() << Verbose(4) << "Current target is peak!" << endl);
+              continue;
+            }
+
+            // 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);
+            helper.ProjectOntoPlane(TempVector);
+            if (fabs(helper.NormSquared()) < MYEPSILON) {
+              DoLog(2) && (Log() << Verbose(2) << "Chosen set of vectors is linear dependent." << endl);
+              continue;
+            }
+
+            // 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));
+            TempVector -= (*Center);
+            // make it always point outward
+            if (VirtualNormalVector.ScalarProduct(TempVector) < 0)
+              VirtualNormalVector.Scale(-1.);
+            // calculate angle
+            TempAngle = NormalVector.Angle(VirtualNormalVector);
+            DoLog(2) && (Log() << Verbose(2) << "NormalVector is " << VirtualNormalVector << " and the angle is " << TempAngle << "." << endl);
+            if ((SmallestAngle - TempAngle) > MYEPSILON) { // set to new possible winner
+              SmallestAngle = TempAngle;
+              winner = target;
+              DoLog(2) && (Log() << Verbose(2) << "New winner " << *winner->second->node << " due to smaller angle between normal vectors." << endl);
+            } 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.ProjectOntoPlane(BaseLine);
+              // ...the one with the smaller angle is the better candidate
+              TempVector = (*target->second->node->node) - BaseLineCenter;
+              TempVector.ProjectOntoPlane(VirtualNormalVector);
+              TempAngle = TempVector.Angle(helper);
+              TempVector = (*winner->second->node->node) - BaseLineCenter;
+              TempVector.ProjectOntoPlane(VirtualNormalVector);
+              if (TempAngle < TempVector.Angle(helper)) {
+                TempAngle = NormalVector.Angle(VirtualNormalVector);
+                SmallestAngle = TempAngle;
+                winner = target;
+                DoLog(2) && (Log() << Verbose(2) << "New winner " << *winner->second->node << " due to smaller angle " << TempAngle << " to propagation direction." << endl);
+              } else
+                DoLog(2) && (Log() << Verbose(2) << "Keeping old winner " << *winner->second->node << " due to smaller angle to propagation direction." << endl);
+            } else
+              DoLog(2) && (Log() << Verbose(2) << "Keeping old winner " << *winner->second->node << " due to smaller angle between normal vectors." << endl);
+          }
+        } // end of loop over all boundary points
+
+        // 5b. The point of the above whose triangle has the greatest angle with the triangle the current line belongs to (it only belongs to one, remember!): New triangle
+        if (winner != PointsOnBoundary.end()) {
+          DoLog(0) && (Log() << Verbose(0) << "Winning target point is " << *(winner->second) << " with angle " << SmallestAngle << "." << endl);
+          // create the lins of not yet present
+          BLS[0] = baseline->second;
+          // 5c. add lines to the line set if those were new (not yet part of a triangle), delete lines that belong to two triangles)
+          LineChecker[0] = baseline->second->endpoints[0]->lines.find(winner->first);
+          LineChecker[1] = baseline->second->endpoints[1]->lines.find(winner->first);
+          if (LineChecker[0] == baseline->second->endpoints[0]->lines.end()) { // create
+            BPS[0] = baseline->second->endpoints[0];
+            BPS[1] = winner->second;
+            BLS[1] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount);
+            LinesOnBoundary.insert(LinePair(LinesOnBoundaryCount, BLS[1]));
+            LinesOnBoundaryCount++;
+          } else
+            BLS[1] = LineChecker[0]->second;
+          if (LineChecker[1] == baseline->second->endpoints[1]->lines.end()) { // create
+            BPS[0] = baseline->second->endpoints[1];
+            BPS[1] = winner->second;
+            BLS[2] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount);
+            LinesOnBoundary.insert(LinePair(LinesOnBoundaryCount, BLS[2]));
+            LinesOnBoundaryCount++;
+          } else
+            BLS[2] = LineChecker[1]->second;
+          BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
+          BTS->GetCenter(&helper);
+          helper -= (*Center);
+          helper *= -1;
+          BTS->GetNormalVector(helper);
+          TrianglesOnBoundary.insert(TrianglePair(TrianglesOnBoundaryCount, BTS));
+          TrianglesOnBoundaryCount++;
+        } else {
+          DoeLog(2) && (eLog() << Verbose(2) << "I could not determine a winner for this baseline " << *(baseline->second) << "." << endl);
+        }
+
+        // 5d. If the set of lines is not yet empty, go to 5. and continue
+      } else
+        DoLog(0) && (Log() << Verbose(0) << "Baseline candidate " << *(baseline->second) << " has a triangle count of " << baseline->second->triangles.size() << "." << endl);
+  } while (flag);
+
+  // exit
+  delete (Center);
+}
+;
+
+/** Inserts all points outside of the tesselated surface into it by adding new triangles.
+ * \param *out output stream for debugging
+ * \param *cloud cluster of points
+ * \param *LC LinkedCell structure to find nearest point quickly
+ * \return true - all straddling points insert, false - something went wrong
+ */
+bool Tesselation::InsertStraddlingPoints(const PointCloud *cloud, const LinkedCell *LC)
+{
+  Info FunctionInfo(__func__);
+  Vector Intersection, Normal;
+  TesselPoint *Walker = NULL;
+  Vector *Center = cloud->GetCenter();
+  TriangleList *triangles = NULL;
+  bool AddFlag = false;
+  LinkedCell *BoundaryPoints = NULL;
+  bool SuccessFlag = true;
+
+  cloud->GoToFirst();
+  BoundaryPoints = new LinkedCell(this, 5.);
+  while (!cloud->IsEnd()) { // we only have to go once through all points, as boundary can become only bigger
+    if (AddFlag) {
+      delete (BoundaryPoints);
+      BoundaryPoints = new LinkedCell(this, 5.);
+      AddFlag = false;
+    }
+    Walker = cloud->GetPoint();
+    DoLog(0) && (Log() << Verbose(0) << "Current point is " << *Walker << "." << endl);
+    // get the next triangle
+    triangles = FindClosestTrianglesToVector(Walker->node, BoundaryPoints);
+    if (triangles != NULL)
+      BTS = triangles->front();
+    else
+      BTS = NULL;
+    delete triangles;
+    if ((BTS == NULL) || (BTS->ContainsBoundaryPoint(Walker))) {
+      DoLog(0) && (Log() << Verbose(0) << "No triangles found, probably a tesselation point itself." << endl);
+      cloud->GoToNext();
+      continue;
+    } else {
+    }
+    DoLog(0) && (Log() << Verbose(0) << "Closest triangle is " << *BTS << "." << endl);
+    // get the intersection point
+    if (BTS->GetIntersectionInsideTriangle(Center, Walker->node, &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) {
+        // inside, next!
+        DoLog(0) && (Log() << Verbose(0) << *Walker << " is inside wrt triangle " << *BTS << "." << endl);
+      } else {
+        // outside!
+        DoLog(0) && (Log() << Verbose(0) << *Walker << " is outside wrt triangle " << *BTS << "." << endl);
+        class BoundaryLineSet *OldLines[3], *NewLines[3];
+        class BoundaryPointSet *OldPoints[3], *NewPoint;
+        // store the three old lines and old points
+        for (int i = 0; i < 3; i++) {
+          OldLines[i] = BTS->lines[i];
+          OldPoints[i] = BTS->endpoints[i];
+        }
+        Normal = BTS->NormalVector;
+        // add Walker to boundary points
+        DoLog(0) && (Log() << Verbose(0) << "Adding " << *Walker << " to BoundaryPoints." << endl);
+        AddFlag = true;
+        if (AddBoundaryPoint(Walker, 0))
+          NewPoint = BPS[0];
+        else
+          continue;
+        // remove triangle
+        DoLog(0) && (Log() << Verbose(0) << "Erasing triangle " << *BTS << "." << endl);
+        TrianglesOnBoundary.erase(BTS->Nr);
+        delete (BTS);
+        // create three new boundary lines
+        for (int i = 0; i < 3; i++) {
+          BPS[0] = NewPoint;
+          BPS[1] = OldPoints[i];
+          NewLines[i] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount);
+          DoLog(1) && (Log() << Verbose(1) << "Creating new line " << *NewLines[i] << "." << endl);
+          LinesOnBoundary.insert(LinePair(LinesOnBoundaryCount, NewLines[i])); // no need for check for unique insertion as BPS[0] is definitely a new one
+          LinesOnBoundaryCount++;
+        }
+        // create three new triangle with new point
+        for (int i = 0; i < 3; i++) { // find all baselines
+          BLS[0] = OldLines[i];
+          int n = 1;
+          for (int j = 0; j < 3; j++) {
+            if (NewLines[j]->IsConnectedTo(BLS[0])) {
+              if (n > 2) {
+                DoeLog(2) && (eLog() << Verbose(2) << BLS[0] << " connects to all of the new lines?!" << endl);
+                return false;
+              } else
+                BLS[n++] = NewLines[j];
+            }
+          }
+          // create the triangle
+          BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
+          Normal.Scale(-1.);
+          BTS->GetNormalVector(Normal);
+          Normal.Scale(-1.);
+          DoLog(0) && (Log() << Verbose(0) << "Created new triangle " << *BTS << "." << endl);
+          TrianglesOnBoundary.insert(TrianglePair(TrianglesOnBoundaryCount, BTS));
+          TrianglesOnBoundaryCount++;
+        }
+      }
+    } else { // something is wrong with FindClosestTriangleToPoint!
+      DoeLog(1) && (eLog() << Verbose(1) << "The closest triangle did not produce an intersection!" << endl);
+      SuccessFlag = false;
+      break;
+    }
+    cloud->GoToNext();
+  }
+
+  // exit
+  delete (Center);
+  delete (BoundaryPoints);
+  return SuccessFlag;
+}
+;
+
+/** Adds a point to the tesselation::PointsOnBoundary list.
+ * \param *Walker point to add
+ * \param n TesselStruct::BPS index to put pointer into
+ * \return true - new point was added, false - point already present
+ */
+bool Tesselation::AddBoundaryPoint(TesselPoint * Walker, const int n)
+{
+  Info FunctionInfo(__func__);
+  PointTestPair InsertUnique;
+  BPS[n] = new class BoundaryPointSet(Walker);
+  InsertUnique = PointsOnBoundary.insert(PointPair(Walker->nr, BPS[n]));
+  if (InsertUnique.second) { // if new point was not present before, increase counter
+    PointsOnBoundaryCount++;
+    return true;
+  } else {
+    delete (BPS[n]);
+    BPS[n] = InsertUnique.first->second;
+    return false;
+  }
+}
+;
+
+/** Adds point to Tesselation::PointsOnBoundary if not yet present.
+ * Tesselation::TPS is set to either this new BoundaryPointSet or to the existing one of not unique.
+ * @param Candidate point to add
+ * @param n index for this point in Tesselation::TPS array
+ */
+void Tesselation::AddTesselationPoint(TesselPoint* Candidate, const int n)
+{
+  Info FunctionInfo(__func__);
+  PointTestPair InsertUnique;
+  TPS[n] = new class BoundaryPointSet(Candidate);
+  InsertUnique = PointsOnBoundary.insert(PointPair(Candidate->nr, TPS[n]));
+  if (InsertUnique.second) { // if new point was not present before, increase counter
+    PointsOnBoundaryCount++;
+  } else {
+    delete TPS[n];
+    DoLog(0) && (Log() << Verbose(0) << "Node " << *((InsertUnique.first)->second->node) << " is already present in PointsOnBoundary." << endl);
+    TPS[n] = (InsertUnique.first)->second;
+  }
+}
+;
+
+/** Sets point to a present Tesselation::PointsOnBoundary.
+ * Tesselation::TPS is set to the existing one or NULL if not found.
+ * @param Candidate point to set to
+ * @param n index for this point in Tesselation::TPS array
+ */
+void Tesselation::SetTesselationPoint(TesselPoint* Candidate, const int n) const
+{
+  Info FunctionInfo(__func__);
+  PointMap::const_iterator FindPoint = PointsOnBoundary.find(Candidate->nr);
+  if (FindPoint != PointsOnBoundary.end())
+    TPS[n] = FindPoint->second;
+  else
+    TPS[n] = NULL;
+}
+;
+
+/** Function tries to add line from current Points in BPS to BoundaryLineSet.
+ * If successful it raises the line count and inserts the new line into the BLS,
+ * if unsuccessful, it writes the line which had been present into the BLS, deleting the new constructed one.
+ * @param *OptCenter desired OptCenter if there are more than one candidate line
+ * @param *candidate third point of the triangle to be, for checking between multiple open line candidates
+ * @param *a first endpoint
+ * @param *b second endpoint
+ * @param n index of Tesselation::BLS giving the line with both endpoints
+ */
+void Tesselation::AddTesselationLine(const Vector * const OptCenter, const BoundaryPointSet * const candidate, class BoundaryPointSet *a, class BoundaryPointSet *b, const int n)
+{
+  bool insertNewLine = true;
+  LineMap::iterator FindLine = a->lines.find(b->node->nr);
+  BoundaryLineSet *WinningLine = NULL;
+  if (FindLine != a->lines.end()) {
+    DoLog(1) && (Log() << Verbose(1) << "INFO: There is at least one line between " << *a << " and " << *b << ": " << *(FindLine->second) << "." << endl);
+
+    pair<LineMap::iterator, LineMap::iterator> FindPair;
+    FindPair = a->lines.equal_range(b->node->nr);
+
+    for (FindLine = FindPair.first; (FindLine != FindPair.second) && (insertNewLine); FindLine++) {
+      DoLog(1) && (Log() << Verbose(1) << "INFO: Checking line " << *(FindLine->second) << " ..." << endl);
+      // If there is a line with less than two attached triangles, we don't need a new line.
+      if (FindLine->second->triangles.size() == 1) {
+        CandidateMap::iterator Finder = OpenLines.find(FindLine->second);
+        if (!Finder->second->pointlist.empty())
+          DoLog(1) && (Log() << Verbose(1) << "INFO: line " << *(FindLine->second) << " is open with candidate " << **(Finder->second->pointlist.begin()) << "." << endl);
+        else
+          DoLog(1) && (Log() << Verbose(1) << "INFO: line " << *(FindLine->second) << " is open with no candidate." << endl);
+        // get open line
+        for (TesselPointList::const_iterator CandidateChecker = Finder->second->pointlist.begin(); CandidateChecker != Finder->second->pointlist.end(); ++CandidateChecker) {
+          if ((*(CandidateChecker) == candidate->node) && (OptCenter == NULL || OptCenter->DistanceSquared(Finder->second->OptCenter) < MYEPSILON )) { // stop searching if candidate matches
+            DoLog(1) && (Log() << Verbose(1) << "ACCEPT: Candidate " << *(*CandidateChecker) << " has the right center " << Finder->second->OptCenter << "." << endl);
+            insertNewLine = false;
+            WinningLine = FindLine->second;
+            break;
+          } else {
+            DoLog(1) && (Log() << Verbose(1) << "REJECT: Candidate " << *(*CandidateChecker) << "'s center " << Finder->second->OptCenter << " does not match desired on " << *OptCenter << "." << endl);
+          }
+        }
+      }
+    }
+  }
+
+  if (insertNewLine) {
+    AddNewTesselationTriangleLine(a, b, n);
+  } else {
+    AddExistingTesselationTriangleLine(WinningLine, n);
+  }
+}
+;
+
+/**
+ * Adds lines from each of the current points in the BPS to BoundaryLineSet.
+ * Raises the line count and inserts the new line into the BLS.
+ *
+ * @param *a first endpoint
+ * @param *b second endpoint
+ * @param n index of Tesselation::BLS giving the line with both endpoints
+ */
+void Tesselation::AddNewTesselationTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, const int n)
+{
+  Info FunctionInfo(__func__);
+  DoLog(0) && (Log() << Verbose(0) << "Adding open line [" << LinesOnBoundaryCount << "|" << *(a->node) << " and " << *(b->node) << "." << endl);
+  BPS[0] = a;
+  BPS[1] = b;
+  BLS[n] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount); // this also adds the line to the local maps
+  // add line to global map
+  LinesOnBoundary.insert(LinePair(LinesOnBoundaryCount, BLS[n]));
+  // increase counter
+  LinesOnBoundaryCount++;
+  // also add to open lines
+  CandidateForTesselation *CFT = new CandidateForTesselation(BLS[n]);
+  OpenLines.insert(pair<BoundaryLineSet *, CandidateForTesselation *> (BLS[n], CFT));
+}
+;
+
+/** Uses an existing line for a new triangle.
+ * Sets Tesselation::BLS[\a n] and removes the lines from Tesselation::OpenLines.
+ * \param *FindLine the line to add
+ * \param n index of the line to set in Tesselation::BLS
+ */
+void Tesselation::AddExistingTesselationTriangleLine(class BoundaryLineSet *Line, int n)
+{
+  Info FunctionInfo(__func__);
+  DoLog(0) && (Log() << Verbose(0) << "Using existing line " << *Line << endl);
+
+  // set endpoints and line
+  BPS[0] = Line->endpoints[0];
+  BPS[1] = Line->endpoints[1];
+  BLS[n] = Line;
+  // remove existing line from OpenLines
+  CandidateMap::iterator CandidateLine = OpenLines.find(BLS[n]);
+  if (CandidateLine != OpenLines.end()) {
+    DoLog(1) && (Log() << Verbose(1) << " Removing line from OpenLines." << endl);
+    delete (CandidateLine->second);
+    OpenLines.erase(CandidateLine);
+  } else {
+    DoeLog(1) && (eLog() << Verbose(1) << "Line exists and is attached to less than two triangles, but not in OpenLines!" << endl);
+  }
+}
+;
+
+/** Function adds triangle to global list.
+ * Furthermore, the triangle receives the next free id and id counter \a TrianglesOnBoundaryCount is increased.
+ */
+void Tesselation::AddTesselationTriangle()
+{
+  Info FunctionInfo(__func__);
+  DoLog(1) && (Log() << Verbose(1) << "Adding triangle to global TrianglesOnBoundary map." << endl);
+
+  // add triangle to global map
+  TrianglesOnBoundary.insert(TrianglePair(TrianglesOnBoundaryCount, BTS));
+  TrianglesOnBoundaryCount++;
+
+  // set as last new triangle
+  LastTriangle = BTS;
+
+  // NOTE: add triangle to local maps is done in constructor of BoundaryTriangleSet
+}
+;
+
+/** Function adds triangle to global list.
+ * Furthermore, the triangle number is set to \a nr.
+ * \param nr triangle number
+ */
+void Tesselation::AddTesselationTriangle(const int nr)
+{
+  Info FunctionInfo(__func__);
+  DoLog(0) && (Log() << Verbose(0) << "Adding triangle to global TrianglesOnBoundary map." << endl);
+
+  // add triangle to global map
+  TrianglesOnBoundary.insert(TrianglePair(nr, BTS));
+
+  // set as last new triangle
+  LastTriangle = BTS;
+
+  // NOTE: add triangle to local maps is done in constructor of BoundaryTriangleSet
+}
+;
+
+/** Removes a triangle from the tesselation.
+ * Removes itself from the TriangleMap's of its lines, calls for them RemoveTriangleLine() if they are no more connected.
+ * Removes itself from memory.
+ * \param *triangle to remove
+ */
+void Tesselation::RemoveTesselationTriangle(class BoundaryTriangleSet *triangle)
+{
+  Info FunctionInfo(__func__);
+  if (triangle == NULL)
+    return;
+  for (int i = 0; i < 3; i++) {
+    if (triangle->lines[i] != NULL) {
+      DoLog(0) && (Log() << Verbose(0) << "Removing triangle Nr." << triangle->Nr << " in line " << *triangle->lines[i] << "." << endl);
+      triangle->lines[i]->triangles.erase(triangle->Nr);
+      if (triangle->lines[i]->triangles.empty()) {
+        DoLog(0) && (Log() << Verbose(0) << *triangle->lines[i] << " is no more attached to any triangle, erasing." << endl);
+        RemoveTesselationLine(triangle->lines[i]);
+      } else {
+        DoLog(0) && (Log() << Verbose(0) << *triangle->lines[i] << " is still attached to another triangle: " << endl);
+        OpenLines.insert(pair<BoundaryLineSet *, CandidateForTesselation *> (triangle->lines[i], NULL));
+        for (TriangleMap::iterator TriangleRunner = triangle->lines[i]->triangles.begin(); TriangleRunner != triangle->lines[i]->triangles.end(); TriangleRunner++)
+          DoLog(0) && (Log() << Verbose(0) << "\t[" << (TriangleRunner->second)->Nr << "|" << *((TriangleRunner->second)->endpoints[0]) << ", " << *((TriangleRunner->second)->endpoints[1]) << ", " << *((TriangleRunner->second)->endpoints[2]) << "] \t");
+        DoLog(0) && (Log() << Verbose(0) << endl);
+        //        for (int j=0;j<2;j++) {
+        //          Log() << Verbose(0) << "Lines of endpoint " << *(triangle->lines[i]->endpoints[j]) << ": ";
+        //          for(LineMap::iterator LineRunner = triangle->lines[i]->endpoints[j]->lines.begin(); LineRunner != triangle->lines[i]->endpoints[j]->lines.end(); LineRunner++)
+        //            Log() << Verbose(0) << "[" << *(LineRunner->second) << "] \t";
+        //          Log() << Verbose(0) << endl;
+        //        }
+      }
+      triangle->lines[i] = NULL; // free'd or not: disconnect
+    } else
+      DoeLog(1) && (eLog() << Verbose(1) << "This line " << i << " has already been free'd." << endl);
+  }
+
+  if (TrianglesOnBoundary.erase(triangle->Nr))
+    DoLog(0) && (Log() << Verbose(0) << "Removing triangle Nr. " << triangle->Nr << "." << endl);
+  delete (triangle);
+}
+;
+
+/** Removes a line from the tesselation.
+ * Removes itself from each endpoints' LineMap, then removes itself from global LinesOnBoundary list and free's the line.
+ * \param *line line to remove
+ */
+void Tesselation::RemoveTesselationLine(class BoundaryLineSet *line)
+{
+  Info FunctionInfo(__func__);
+  int Numbers[2];
+
+  if (line == NULL)
+    return;
+  // get other endpoint number for finding copies of same line
+  if (line->endpoints[1] != NULL)
+    Numbers[0] = line->endpoints[1]->Nr;
+  else
+    Numbers[0] = -1;
+  if (line->endpoints[0] != NULL)
+    Numbers[1] = line->endpoints[0]->Nr;
+  else
+    Numbers[1] = -1;
+
+  for (int i = 0; i < 2; i++) {
+    if (line->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 = line->endpoints[i]->lines.equal_range(Numbers[i]);
+        for (LineMap::iterator Runner = erasor.first; Runner != erasor.second; Runner++)
+          if ((*Runner).second == line) {
+            DoLog(0) && (Log() << Verbose(0) << "Removing Line Nr. " << line->Nr << " in boundary point " << *line->endpoints[i] << "." << endl);
+            line->endpoints[i]->lines.erase(Runner);
+            break;
+          }
+      } else { // there's just a single line left
+        if (line->endpoints[i]->lines.erase(line->Nr))
+          DoLog(0) && (Log() << Verbose(0) << "Removing Line Nr. " << line->Nr << " in boundary point " << *line->endpoints[i] << "." << endl);
+      }
+      if (line->endpoints[i]->lines.empty()) {
+        DoLog(0) && (Log() << Verbose(0) << *line->endpoints[i] << " has no more lines it's attached to, erasing." << endl);
+        RemoveTesselationPoint(line->endpoints[i]);
+      } else {
+        DoLog(0) && (Log() << Verbose(0) << *line->endpoints[i] << " has still lines it's attached to: ");
+        for (LineMap::iterator LineRunner = line->endpoints[i]->lines.begin(); LineRunner != line->endpoints[i]->lines.end(); LineRunner++)
+          DoLog(0) && (Log() << Verbose(0) << "[" << *(LineRunner->second) << "] \t");
+        DoLog(0) && (Log() << Verbose(0) << endl);
+      }
+      line->endpoints[i] = NULL; // free'd or not: disconnect
+    } else
+      DoeLog(1) && (eLog() << Verbose(1) << "Endpoint " << i << " has already been free'd." << endl);
+  }
+  if (!line->triangles.empty())
+    DoeLog(2) && (eLog() << Verbose(2) << "Memory Leak! I " << *line << " am still connected to some triangles." << endl);
+
+  if (LinesOnBoundary.erase(line->Nr))
+    DoLog(0) && (Log() << Verbose(0) << "Removing line Nr. " << line->Nr << "." << endl);
+  delete (line);
+}
+;
+
+/** Removes a point from the tesselation.
+ * Checks whether there are still lines connected, removes from global PointsOnBoundary list, then free's the point.
+ * \note If a point should be removed, while keep the tesselated surface intact (i.e. closed), use RemovePointFromTesselatedSurface()
+ * \param *point point to remove
+ */
+void Tesselation::RemoveTesselationPoint(class BoundaryPointSet *point)
+{
+  Info FunctionInfo(__func__);
+  if (point == NULL)
+    return;
+  if (PointsOnBoundary.erase(point->Nr))
+    DoLog(0) && (Log() << Verbose(0) << "Removing point Nr. " << point->Nr << "." << endl);
+  delete (point);
+}
+;
+
+/** Checks validity of a given sphere of a candidate line.
+ * \sa CandidateForTesselation::CheckValidity(), which is more evolved.
+ * We check CandidateForTesselation::OtherOptCenter
+ * \param &CandidateLine contains other degenerated candidates which we have to subtract as well
+ * \param RADIUS radius of sphere
+ * \param *LC LinkedCell structure with other atoms
+ * \return true - candidate triangle is degenerated, false - candidate triangle is not degenerated
+ */
+bool Tesselation::CheckDegeneracy(CandidateForTesselation &CandidateLine, const double RADIUS, const LinkedCell *LC) const
+{
+  Info FunctionInfo(__func__);
+
+  DoLog(1) && (Log() << Verbose(1) << "INFO: Checking whether sphere contains no others points ..." << endl);
+  bool flag = true;
+
+  DoLog(1) && (Log() << Verbose(1) << "Check by: draw sphere {" << CandidateLine.OtherOptCenter[0] << " " << CandidateLine.OtherOptCenter[1] << " " << CandidateLine.OtherOptCenter[2] << "} radius " << RADIUS << " resolution 30" << endl);
+  // get all points inside the sphere
+  TesselPointList *ListofPoints = LC->GetPointsInsideSphere(RADIUS, &CandidateLine.OtherOptCenter);
+
+  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);
+
+  // remove triangles's endpoints
+  for (int i = 0; i < 2; i++)
+    ListofPoints->remove(CandidateLine.BaseLine->endpoints[i]->node);
+
+  // remove other candidates
+  for (TesselPointList::const_iterator Runner = CandidateLine.pointlist.begin(); Runner != CandidateLine.pointlist.end(); ++Runner)
+    ListofPoints->remove(*Runner);
+
+  // check for other points
+  if (!ListofPoints->empty()) {
+    DoLog(1) && (Log() << Verbose(1) << "CheckDegeneracy: There are still " << ListofPoints->size() << " points inside the sphere." << endl);
+    flag = false;
+    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);
+  }
+  delete (ListofPoints);
+
+  return flag;
+}
+;
+
+/** Checks whether the triangle consisting of the three points is already present.
+ * Searches for the points in Tesselation::PointsOnBoundary and checks their
+ * lines. If any of the three edges already has two triangles attached, false is
+ * returned.
+ * \param *out output stream for debugging
+ * \param *Candidates endpoints of the triangle candidate
+ * \return integer 0 if no triangle exists, 1 if one triangle exists, 2 if two
+ *                 triangles exist which is the maximum for three points
+ */
+int Tesselation::CheckPresenceOfTriangle(TesselPoint *Candidates[3]) const
+{
+  Info FunctionInfo(__func__);
+  int adjacentTriangleCount = 0;
+  class BoundaryPointSet *Points[3];
+
+  // builds a triangle point set (Points) of the end points
+  for (int i = 0; i < 3; i++) {
+    PointMap::const_iterator FindPoint = PointsOnBoundary.find(Candidates[i]->nr);
+    if (FindPoint != PointsOnBoundary.end()) {
+      Points[i] = FindPoint->second;
+    } else {
+      Points[i] = NULL;
+    }
+  }
+
+  // checks lines between the points in the Points for their adjacent triangles
+  for (int i = 0; i < 3; i++) {
+    if (Points[i] != NULL) {
+      for (int j = i; j < 3; j++) {
+        if (Points[j] != NULL) {
+          LineMap::const_iterator FindLine = Points[i]->lines.find(Points[j]->node->nr);
+          for (; (FindLine != Points[i]->lines.end()) && (FindLine->first == Points[j]->node->nr); FindLine++) {
+            TriangleMap *triangles = &FindLine->second->triangles;
+            DoLog(1) && (Log() << Verbose(1) << "Current line is " << FindLine->first << ": " << *(FindLine->second) << " with triangles " << triangles << "." << endl);
+            for (TriangleMap::const_iterator FindTriangle = triangles->begin(); FindTriangle != triangles->end(); FindTriangle++) {
+              if (FindTriangle->second->IsPresentTupel(Points)) {
+                adjacentTriangleCount++;
+              }
+            }
+            DoLog(1) && (Log() << Verbose(1) << "end." << endl);
+          }
+          // Only one of the triangle lines must be considered for the triangle count.
+          //Log() << Verbose(0) << "Found " << adjacentTriangleCount << " adjacent triangles for the point set." << endl;
+          //return adjacentTriangleCount;
+        }
+      }
+    }
+  }
+
+  DoLog(0) && (Log() << Verbose(0) << "Found " << adjacentTriangleCount << " adjacent triangles for the point set." << endl);
+  return adjacentTriangleCount;
+}
+;
+
+/** Checks whether the triangle consisting of the three points is already present.
+ * Searches for the points in Tesselation::PointsOnBoundary and checks their
+ * lines. If any of the three edges already has two triangles attached, false is
+ * returned.
+ * \param *out output stream for debugging
+ * \param *Candidates endpoints of the triangle candidate
+ * \return NULL - none found or pointer to triangle
+ */
+class BoundaryTriangleSet * Tesselation::GetPresentTriangle(TesselPoint *Candidates[3])
+{
+  Info FunctionInfo(__func__);
+  class BoundaryTriangleSet *triangle = NULL;
+  class BoundaryPointSet *Points[3];
+
+  // builds a triangle point set (Points) of the end points
+  for (int i = 0; i < 3; i++) {
+    PointMap::iterator FindPoint = PointsOnBoundary.find(Candidates[i]->nr);
+    if (FindPoint != PointsOnBoundary.end()) {
+      Points[i] = FindPoint->second;
+    } else {
+      Points[i] = NULL;
+    }
+  }
+
+  // checks lines between the points in the Points for their adjacent triangles
+  for (int i = 0; i < 3; i++) {
+    if (Points[i] != NULL) {
+      for (int j = i; j < 3; j++) {
+        if (Points[j] != NULL) {
+          LineMap::iterator FindLine = Points[i]->lines.find(Points[j]->node->nr);
+          for (; (FindLine != Points[i]->lines.end()) && (FindLine->first == Points[j]->node->nr); FindLine++) {
+            TriangleMap *triangles = &FindLine->second->triangles;
+            for (TriangleMap::iterator FindTriangle = triangles->begin(); FindTriangle != triangles->end(); FindTriangle++) {
+              if (FindTriangle->second->IsPresentTupel(Points)) {
+                if ((triangle == NULL) || (triangle->Nr > FindTriangle->second->Nr))
+                  triangle = FindTriangle->second;
+              }
+            }
+          }
+          // Only one of the triangle lines must be considered for the triangle count.
+          //Log() << Verbose(0) << "Found " << adjacentTriangleCount << " adjacent triangles for the point set." << endl;
+          //return adjacentTriangleCount;
+        }
+      }
+    }
+  }
+
+  return triangle;
+}
+;
+
+/** Finds the starting triangle for FindNonConvexBorder().
+ * Looks at the outermost point per axis, then FindSecondPointForTesselation()
+ * for the second and FindNextSuitablePointViaAngleOfSphere() for the third
+ * point are called.
+ * \param *out output stream for debugging
+ * \param RADIUS radius of virtual rolling sphere
+ * \param *LC LinkedCell structure with neighbouring TesselPoint's
+ * \return true - a starting triangle has been created, false - no valid triple of points found
+ */
+bool Tesselation::FindStartingTriangle(const double RADIUS, const LinkedCell *LC)
+{
+  Info FunctionInfo(__func__);
+  int i = 0;
+  TesselPoint* MaxPoint[NDIM];
+  TesselPoint* Temporary;
+  double maxCoordinate[NDIM];
+  BoundaryLineSet *BaseLine = NULL;
+  Vector helper;
+  Vector Chord;
+  Vector SearchDirection;
+  Vector CircleCenter; // center of the circle, i.e. of the band of sphere's centers
+  Vector CirclePlaneNormal; // normal vector defining the plane this circle lives in
+  Vector SphereCenter;
+  Vector NormalVector;
+
+  NormalVector.Zero();
+
+  for (i = 0; i < 3; i++) {
+    MaxPoint[i] = NULL;
+    maxCoordinate[i] = -1;
+  }
+
+  // 1. searching topmost point with respect to each axis
+  for (int i = 0; i < NDIM; i++) { // each axis
+    LC->n[i] = LC->N[i] - 1; // current axis is topmost cell
+    const int map[NDIM] = {i, (i + 1) % NDIM, (i + 2) % NDIM};
+    for (LC->n[map[1]] = 0; LC->n[map[1]] < LC->N[map[1]]; LC->n[map[1]]++)
+      for (LC->n[map[2]] = 0; LC->n[map[2]] < LC->N[map[2]]; LC->n[map[2]]++) {
+        const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
+        //Log() << Verbose(1) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl;
+        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]);
+              MaxPoint[map[0]] = (*Runner);
+            }
+          }
+        } else {
+          DoeLog(1) && (eLog() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << " is invalid!" << endl);
+        }
+      }
+  }
+
+  DoLog(1) && (Log() << Verbose(1) << "Found maximum coordinates: ");
+  for (int i = 0; i < NDIM; i++)
+    DoLog(0) && (Log() << Verbose(0) << i << ": " << *MaxPoint[i] << "\t");
+  DoLog(0) && (Log() << Verbose(0) << endl);
+
+  BTS = NULL;
+  for (int k = 0; k < NDIM; k++) {
+    NormalVector.Zero();
+    NormalVector[k] = 1.;
+    BaseLine = new BoundaryLineSet();
+    BaseLine->endpoints[0] = new BoundaryPointSet(MaxPoint[k]);
+    DoLog(0) && (Log() << Verbose(0) << "Coordinates of start node at " << *BaseLine->endpoints[0]->node << "." << endl);
+
+    double ShortestAngle;
+    ShortestAngle = 999999.; // This will contain the angle, which will be always positive (when looking for second point), when looking for third point this will be the quadrant.
+
+    Temporary = NULL;
+    FindSecondPointForTesselation(BaseLine->endpoints[0]->node, NormalVector, Temporary, &ShortestAngle, RADIUS, LC); // we give same point as next candidate as its bonds are looked into in find_second_...
+    if (Temporary == NULL) {
+      // have we found a second point?
+      delete BaseLine;
+      continue;
+    }
+    BaseLine->endpoints[1] = new BoundaryPointSet(Temporary);
+
+    // construct center of circle
+    CircleCenter = 0.5 * ((*BaseLine->endpoints[0]->node->node) + (*BaseLine->endpoints[1]->node->node));
+
+    // construct normal vector of circle
+    CirclePlaneNormal = (*BaseLine->endpoints[0]->node->node) - (*BaseLine->endpoints[1]->node->node);
+
+    double radius = CirclePlaneNormal.NormSquared();
+    double CircleRadius = sqrt(RADIUS * RADIUS - radius / 4.);
+
+    NormalVector.ProjectOntoPlane(CirclePlaneNormal);
+    NormalVector.Normalize();
+    ShortestAngle = 2. * M_PI; // This will indicate the quadrant.
+
+    SphereCenter = (CircleRadius * NormalVector) +  CircleCenter;
+    // Now, NormalVector and SphereCenter are two orthonormalized vectors in the plane defined by CirclePlaneNormal (not normalized)
+
+    // look in one direction of baseline for initial candidate
+    SearchDirection = Plane(CirclePlaneNormal, NormalVector,0).getNormal();  // whether we look "left" first or "right" first is not important ...
+
+    // adding point 1 and point 2 and add the line between them
+    DoLog(0) && (Log() << Verbose(0) << "Coordinates of start node at " << *BaseLine->endpoints[0]->node << "." << endl);
+    DoLog(0) && (Log() << Verbose(0) << "Found second point is at " << *BaseLine->endpoints[1]->node << ".\n");
+
+    //Log() << Verbose(1) << "INFO: OldSphereCenter is at " << helper << ".\n";
+    CandidateForTesselation OptCandidates(BaseLine);
+    FindThirdPointForTesselation(NormalVector, SearchDirection, SphereCenter, OptCandidates, NULL, RADIUS, LC);
+    DoLog(0) && (Log() << Verbose(0) << "List of third Points is:" << endl);
+    for (TesselPointList::iterator it = OptCandidates.pointlist.begin(); it != OptCandidates.pointlist.end(); it++) {
+      DoLog(0) && (Log() << Verbose(0) << " " << *(*it) << endl);
+    }
+    if (!OptCandidates.pointlist.empty()) {
+      BTS = NULL;
+      AddCandidatePolygon(OptCandidates, RADIUS, LC);
+    } else {
+      delete BaseLine;
+      continue;
+    }
+
+    if (BTS != NULL) { // we have created one starting triangle
+      delete BaseLine;
+      break;
+    } else {
+      // remove all candidates from the list and then the list itself
+      OptCandidates.pointlist.clear();
+    }
+    delete BaseLine;
+  }
+
+  return (BTS != NULL);
+}
+;
+
+/** Checks for a given baseline and a third point candidate whether baselines of the found triangle don't have even better candidates.
+ * This is supposed to prevent early closing of the tesselation.
+ * \param CandidateLine CandidateForTesselation with baseline and shortestangle , i.e. not \a *OptCandidate
+ * \param *ThirdNode third point in triangle, not in BoundaryLineSet::endpoints
+ * \param RADIUS radius of sphere
+ * \param *LC LinkedCell structure
+ * \return true - there is a better candidate (smaller angle than \a ShortestAngle), false - no better TesselPoint candidate found
+ */
+//bool Tesselation::HasOtherBaselineBetterCandidate(CandidateForTesselation &CandidateLine, const TesselPoint * const ThirdNode, double RADIUS, const LinkedCell * const LC) const
+//{
+//	Info FunctionInfo(__func__);
+//  bool result = false;
+//  Vector CircleCenter;
+//  Vector CirclePlaneNormal;
+//  Vector OldSphereCenter;
+//  Vector SearchDirection;
+//  Vector helper;
+//  TesselPoint *OtherOptCandidate = NULL;
+//  double OtherShortestAngle = 2.*M_PI; // This will indicate the quadrant.
+//  double radius, CircleRadius;
+//  BoundaryLineSet *Line = NULL;
+//  BoundaryTriangleSet *T = NULL;
+//
+//  // check both other lines
+//  PointMap::const_iterator FindPoint = PointsOnBoundary.find(ThirdNode->nr);
+//  if (FindPoint != PointsOnBoundary.end()) {
+//    for (int i=0;i<2;i++) {
+//      LineMap::const_iterator FindLine = (FindPoint->second)->lines.find(BaseRay->endpoints[0]->node->nr);
+//      if (FindLine != (FindPoint->second)->lines.end()) {
+//        Line = FindLine->second;
+//        Log() << Verbose(0) << "Found line " << *Line << "." << endl;
+//        if (Line->triangles.size() == 1) {
+//          T = Line->triangles.begin()->second;
+//          // construct center of circle
+//          CircleCenter.CopyVector(Line->endpoints[0]->node->node);
+//          CircleCenter.AddVector(Line->endpoints[1]->node->node);
+//          CircleCenter.Scale(0.5);
+//
+//          // construct normal vector of circle
+//          CirclePlaneNormal.CopyVector(Line->endpoints[0]->node->node);
+//          CirclePlaneNormal.SubtractVector(Line->endpoints[1]->node->node);
+//
+//          // calculate squared radius of circle
+//          radius = CirclePlaneNormal.ScalarProduct(&CirclePlaneNormal);
+//          if (radius/4. < RADIUS*RADIUS) {
+//            CircleRadius = RADIUS*RADIUS - radius/4.;
+//            CirclePlaneNormal.Normalize();
+//            //Log() << Verbose(1) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl;
+//
+//            // construct old center
+//            GetCenterofCircumcircle(&OldSphereCenter, *T->endpoints[0]->node->node, *T->endpoints[1]->node->node, *T->endpoints[2]->node->node);
+//            helper.CopyVector(&T->NormalVector);  // normal vector ensures that this is correct center of the two possible ones
+//            radius = Line->endpoints[0]->node->node->DistanceSquared(&OldSphereCenter);
+//            helper.Scale(sqrt(RADIUS*RADIUS - radius));
+//            OldSphereCenter.AddVector(&helper);
+//            OldSphereCenter.SubtractVector(&CircleCenter);
+//            //Log() << Verbose(1) << "INFO: OldSphereCenter is at " << OldSphereCenter << "." << endl;
+//
+//            // construct SearchDirection
+//            SearchDirection.MakeNormalVector(&T->NormalVector, &CirclePlaneNormal);
+//            helper.CopyVector(Line->endpoints[0]->node->node);
+//            helper.SubtractVector(ThirdNode->node);
+//            if (helper.ScalarProduct(&SearchDirection) < -HULLEPSILON)// ohoh, SearchDirection points inwards!
+//              SearchDirection.Scale(-1.);
+//            SearchDirection.ProjectOntoPlane(&OldSphereCenter);
+//            SearchDirection.Normalize();
+//            Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl;
+//            if (fabs(OldSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) {
+//              // rotated the wrong way!
+//              DoeLog(1) && (eLog()<< Verbose(1) << "SearchDirection and RelativeOldSphereCenter are still not orthogonal!" << endl);
+//            }
+//
+//            // add third point
+//            FindThirdPointForTesselation(T->NormalVector, SearchDirection, OldSphereCenter, OptCandidates, ThirdNode, RADIUS, LC);
+//            for (TesselPointList::iterator it = OptCandidates.pointlist.begin(); it != OptCandidates.pointlist.end(); ++it) {
+//              if (((*it) == BaseRay->endpoints[0]->node) || ((*it) == BaseRay->endpoints[1]->node)) // skip if it's the same triangle than suggested
+//                continue;
+//              Log() << Verbose(0) << " Third point candidate is " << (*it)
+//              << " with circumsphere's center at " << (*it)->OptCenter << "." << endl;
+//              Log() << Verbose(0) << " Baseline is " << *BaseRay << endl;
+//
+//              // check whether all edges of the new triangle still have space for one more triangle (i.e. TriangleCount <2)
+//              TesselPoint *PointCandidates[3];
+//              PointCandidates[0] = (*it);
+//              PointCandidates[1] = BaseRay->endpoints[0]->node;
+//              PointCandidates[2] = BaseRay->endpoints[1]->node;
+//              bool check=false;
+//              int existentTrianglesCount = CheckPresenceOfTriangle(PointCandidates);
+//              // If there is no triangle, add it regularly.
+//              if (existentTrianglesCount == 0) {
+//                SetTesselationPoint((*it), 0);
+//                SetTesselationPoint(BaseRay->endpoints[0]->node, 1);
+//                SetTesselationPoint(BaseRay->endpoints[1]->node, 2);
+//
+//                if (CheckLineCriteriaForDegeneratedTriangle((const BoundaryPointSet ** const )TPS)) {
+//                  OtherOptCandidate = (*it);
+//                  check = true;
+//                }
+//              } else if ((existentTrianglesCount >= 1) && (existentTrianglesCount <= 3)) { // If there is a planar region within the structure, we need this triangle a second time.
+//                SetTesselationPoint((*it), 0);
+//                SetTesselationPoint(BaseRay->endpoints[0]->node, 1);
+//                SetTesselationPoint(BaseRay->endpoints[1]->node, 2);
+//
+//                // We demand that at most one new degenerate line is created and that this line also already exists (which has to be the case due to existentTrianglesCount == 1)
+//                // i.e. at least one of the three lines must be present with TriangleCount <= 1
+//                if (CheckLineCriteriaForDegeneratedTriangle((const BoundaryPointSet ** const)TPS)) {
+//                  OtherOptCandidate = (*it);
+//                  check = true;
+//                }
+//              }
+//
+//              if (check) {
+//                if (ShortestAngle > OtherShortestAngle) {
+//                  Log() << Verbose(0) << "There is a better candidate than " << *ThirdNode << " with " << ShortestAngle << " from baseline " << *Line << ": " << *OtherOptCandidate << " with " << OtherShortestAngle << "." << endl;
+//                  result = true;
+//                  break;
+//                }
+//              }
+//            }
+//            delete(OptCandidates);
+//            if (result)
+//              break;
+//          } else {
+//            Log() << Verbose(0) << "Circumcircle for base line " << *Line << " and base triangle " << T << " is too big!" << endl;
+//          }
+//        } else {
+//          DoeLog(2) && (eLog()<< Verbose(2) << "Baseline is connected to two triangles already?" << endl);
+//        }
+//      } else {
+//        Log() << Verbose(1) << "No present baseline between " << BaseRay->endpoints[0] << " and candidate " << *ThirdNode << "." << endl;
+//      }
+//    }
+//  } else {
+//    DoeLog(1) && (eLog()<< Verbose(1) << "Could not find the TesselPoint " << *ThirdNode << "." << endl);
+//  }
+//
+//  return result;
+//};
+
+/** This function finds a triangle to a line, adjacent to an existing one.
+ * @param out output stream for debugging
+ * @param CandidateLine current cadndiate baseline to search from
+ * @param T current triangle which \a Line is edge of
+ * @param RADIUS radius of the rolling ball
+ * @param N number of found triangles
+ * @param *LC LinkedCell structure with neighbouring points
+ */
+bool Tesselation::FindNextSuitableTriangle(CandidateForTesselation &CandidateLine, const BoundaryTriangleSet &T, const double& RADIUS, const LinkedCell *LC)
+{
+  Info FunctionInfo(__func__);
+  Vector CircleCenter;
+  Vector CirclePlaneNormal;
+  Vector RelativeSphereCenter;
+  Vector SearchDirection;
+  Vector helper;
+  BoundaryPointSet *ThirdPoint = NULL;
+  LineMap::iterator testline;
+  double radius, CircleRadius;
+
+  for (int i = 0; i < 3; i++)
+    if ((T.endpoints[i] != CandidateLine.BaseLine->endpoints[0]) && (T.endpoints[i] != CandidateLine.BaseLine->endpoints[1])) {
+      ThirdPoint = T.endpoints[i];
+      break;
+    }
+  DoLog(0) && (Log() << Verbose(0) << "Current baseline is " << *CandidateLine.BaseLine << " with ThirdPoint " << *ThirdPoint << " of triangle " << T << "." << endl);
+
+  CandidateLine.T = &T;
+
+  // construct center of circle
+  CircleCenter = 0.5 * ((*CandidateLine.BaseLine->endpoints[0]->node->node) +
+                        (*CandidateLine.BaseLine->endpoints[1]->node->node));
+
+  // construct normal vector of circle
+  CirclePlaneNormal = (*CandidateLine.BaseLine->endpoints[0]->node->node) -
+                      (*CandidateLine.BaseLine->endpoints[1]->node->node);
+
+  // calculate squared radius of circle
+  radius = CirclePlaneNormal.ScalarProduct(CirclePlaneNormal);
+  if (radius / 4. < RADIUS * RADIUS) {
+    // construct relative sphere center with now known CircleCenter
+    RelativeSphereCenter = T.SphereCenter - CircleCenter;
+
+    CircleRadius = RADIUS * RADIUS - radius / 4.;
+    CirclePlaneNormal.Normalize();
+    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: OldSphereCenter is at " << T.SphereCenter << "." << endl);
+
+    // construct SearchDirection and an "outward pointer"
+    SearchDirection = Plane(RelativeSphereCenter, CirclePlaneNormal,0).getNormal();
+    helper = CircleCenter - (*ThirdPoint->node->node);
+    if (helper.ScalarProduct(SearchDirection) < -HULLEPSILON)// ohoh, SearchDirection points inwards!
+      SearchDirection.Scale(-1.);
+    DoLog(1) && (Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl);
+    if (fabs(RelativeSphereCenter.ScalarProduct(SearchDirection)) > HULLEPSILON) {
+      // rotated the wrong way!
+      DoeLog(1) && (eLog() << Verbose(1) << "SearchDirection and RelativeOldSphereCenter are still not orthogonal!" << endl);
+    }
+
+    // add third point
+    FindThirdPointForTesselation(T.NormalVector, SearchDirection, T.SphereCenter, CandidateLine, ThirdPoint, RADIUS, LC);
+
+  } else {
+    DoLog(0) && (Log() << Verbose(0) << "Circumcircle for base line " << *CandidateLine.BaseLine << " and base triangle " << T << " is too big!" << endl);
+  }
+
+  if (CandidateLine.pointlist.empty()) {
+    DoeLog(2) && (eLog() << Verbose(2) << "Could not find a suitable candidate." << endl);
+    return false;
+  }
+  DoLog(0) && (Log() << Verbose(0) << "Third Points are: " << endl);
+  for (TesselPointList::iterator it = CandidateLine.pointlist.begin(); it != CandidateLine.pointlist.end(); ++it) {
+    DoLog(0) && (Log() << Verbose(0) << " " << *(*it) << endl);
+  }
+
+  return true;
+}
+;
+
+/** Walks through Tesselation::OpenLines() and finds candidates for newly created ones.
+ * \param *&LCList atoms in LinkedCell list
+ * \param RADIUS radius of the virtual sphere
+ * \return true - for all open lines without candidates so far, a candidate has been found,
+ *         false - at least one open line without candidate still
+ */
+bool Tesselation::FindCandidatesforOpenLines(const double RADIUS, const LinkedCell *&LCList)
+{
+  bool TesselationFailFlag = true;
+  CandidateForTesselation *baseline = NULL;
+  BoundaryTriangleSet *T = NULL;
+
+  for (CandidateMap::iterator Runner = OpenLines.begin(); Runner != OpenLines.end(); Runner++) {
+    baseline = Runner->second;
+    if (baseline->pointlist.empty()) {
+      ASSERT((baseline->BaseLine->triangles.size() == 1),"Open line without exactly one attached triangle");
+      T = (((baseline->BaseLine->triangles.begin()))->second);
+      DoLog(1) && (Log() << Verbose(1) << "Finding best candidate for open line " << *baseline->BaseLine << " of triangle " << *T << endl);
+      TesselationFailFlag = TesselationFailFlag && FindNextSuitableTriangle(*baseline, *T, RADIUS, LCList); //the line is there, so there is a triangle, but only one.
+    }
+  }
+  return TesselationFailFlag;
+}
+;
+
+/** Adds the present line and candidate point from \a &CandidateLine to the Tesselation.
+ * \param CandidateLine triangle to add
+ * \param RADIUS Radius of sphere
+ * \param *LC LinkedCell structure
+ * \NOTE we need the copy operator here as the original CandidateForTesselation is removed in
+ * AddTesselationLine() in AddCandidateTriangle()
+ */
+void Tesselation::AddCandidatePolygon(CandidateForTesselation CandidateLine, const double RADIUS, const LinkedCell *LC)
+{
+  Info FunctionInfo(__func__);
+  Vector Center;
+  TesselPoint * const TurningPoint = CandidateLine.BaseLine->endpoints[0]->node;
+  TesselPointList::iterator Runner;
+  TesselPointList::iterator Sprinter;
+
+  // fill the set of neighbours
+  TesselPointSet SetOfNeighbours;
+
+  SetOfNeighbours.insert(CandidateLine.BaseLine->endpoints[1]->node);
+  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);
+
+  DoLog(0) && (Log() << Verbose(0) << "List of Candidates for Turning Point " << *TurningPoint << ":" << endl);
+  for (TesselPointList::iterator TesselRunner = connectedClosestPoints->begin(); TesselRunner != connectedClosestPoints->end(); ++TesselRunner)
+    DoLog(0) && (Log() << Verbose(0) << " " << **TesselRunner << endl);
+
+  // go through all angle-sorted candidates (in degenerate n-nodes case we may have to add multiple triangles)
+  Runner = connectedClosestPoints->begin();
+  Sprinter = Runner;
+  Sprinter++;
+  while (Sprinter != connectedClosestPoints->end()) {
+    DoLog(0) && (Log() << Verbose(0) << "Current Runner is " << *(*Runner) << " and sprinter is " << *(*Sprinter) << "." << endl);
+
+    AddTesselationPoint(TurningPoint, 0);
+    AddTesselationPoint(*Runner, 1);
+    AddTesselationPoint(*Sprinter, 2);
+
+    AddCandidateTriangle(CandidateLine, Opt);
+
+    Runner = Sprinter;
+    Sprinter++;
+    if (Sprinter != connectedClosestPoints->end()) {
+      // fill the internal open lines with its respective candidate (otherwise lines in degenerate case are not picked)
+      FindDegeneratedCandidatesforOpenLines(*Sprinter, &CandidateLine.OptCenter); // Assume BTS contains last triangle
+      DoLog(0) && (Log() << Verbose(0) << " There are still more triangles to add." << endl);
+    }
+    // pick candidates for other open lines as well
+    FindCandidatesforOpenLines(RADIUS, LC);
+
+    // check whether we add a degenerate or a normal triangle
+    if (CheckDegeneracy(CandidateLine, RADIUS, LC)) {
+      // add normal and degenerate triangles
+      DoLog(1) && (Log() << Verbose(1) << "Triangle of endpoints " << *TPS[0] << "," << *TPS[1] << " and " << *TPS[2] << " is degenerated, adding both sides." << endl);
+      AddCandidateTriangle(CandidateLine, OtherOpt);
+
+      if (Sprinter != connectedClosestPoints->end()) {
+        // fill the internal open lines with its respective candidate (otherwise lines in degenerate case are not picked)
+        FindDegeneratedCandidatesforOpenLines(*Sprinter, &CandidateLine.OtherOptCenter);
+      }
+      // pick candidates for other open lines as well
+      FindCandidatesforOpenLines(RADIUS, LC);
+    }
+  }
+  delete (connectedClosestPoints);
+};
+
+/** for polygons (multiple candidates for a baseline) sets internal edges to the correct next candidate.
+ * \param *Sprinter next candidate to which internal open lines are set
+ * \param *OptCenter OptCenter for this candidate
+ */
+void Tesselation::FindDegeneratedCandidatesforOpenLines(TesselPoint * const Sprinter, const Vector * const OptCenter)
+{
+  Info FunctionInfo(__func__);
+
+  pair<LineMap::iterator, LineMap::iterator> FindPair = TPS[0]->lines.equal_range(TPS[2]->node->nr);
+  for (LineMap::const_iterator FindLine = FindPair.first; FindLine != FindPair.second; FindLine++) {
+    DoLog(1) && (Log() << Verbose(1) << "INFO: Checking line " << *(FindLine->second) << " ..." << endl);
+    // If there is a line with less than two attached triangles, we don't need a new line.
+    if (FindLine->second->triangles.size() == 1) {
+      CandidateMap::iterator Finder = OpenLines.find(FindLine->second);
+      if (!Finder->second->pointlist.empty())
+        DoLog(1) && (Log() << Verbose(1) << "INFO: line " << *(FindLine->second) << " is open with candidate " << **(Finder->second->pointlist.begin()) << "." << endl);
+      else {
+        DoLog(1) && (Log() << Verbose(1) << "INFO: line " << *(FindLine->second) << " is open with no candidate, setting to next Sprinter" << (*Sprinter) << endl);
+        Finder->second->T = BTS;  // is last triangle
+        Finder->second->pointlist.push_back(Sprinter);
+        Finder->second->ShortestAngle = 0.;
+        Finder->second->OptCenter = *OptCenter;
+      }
+    }
+  }
+};
+
+/** If a given \a *triangle is degenerated, this adds both sides.
+ * i.e. the triangle with same BoundaryPointSet's but NormalVector in opposite direction.
+ * Note that endpoints are stored in Tesselation::TPS
+ * \param CandidateLine CanddiateForTesselation structure for the desired BoundaryLine
+ * \param RADIUS radius of sphere
+ * \param *LC pointer to LinkedCell structure
+ */
+void Tesselation::AddDegeneratedTriangle(CandidateForTesselation &CandidateLine, const double RADIUS, const LinkedCell *LC)
+{
+  Info FunctionInfo(__func__);
+  Vector Center;
+  CandidateMap::const_iterator CandidateCheck = OpenLines.end();
+  BoundaryTriangleSet *triangle = NULL;
+
+  /// 1. Create or pick the lines for the first triangle
+  DoLog(0) && (Log() << Verbose(0) << "INFO: Creating/Picking lines for first triangle ..." << endl);
+  for (int i = 0; i < 3; i++) {
+    BLS[i] = NULL;
+    DoLog(0) && (Log() << Verbose(0) << "Current line is between " << *TPS[(i + 0) % 3] << " and " << *TPS[(i + 1) % 3] << ":" << endl);
+    AddTesselationLine(&CandidateLine.OptCenter, TPS[(i + 2) % 3], TPS[(i + 0) % 3], TPS[(i + 1) % 3], i);
+  }
+
+  /// 2. create the first triangle and NormalVector and so on
+  DoLog(0) && (Log() << Verbose(0) << "INFO: Adding first triangle with center at " << CandidateLine.OptCenter << " ..." << endl);
+  BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
+  AddTesselationTriangle();
+
+  // create normal vector
+  BTS->GetCenter(&Center);
+  Center -= CandidateLine.OptCenter;
+  BTS->SphereCenter = CandidateLine.OptCenter;
+  BTS->GetNormalVector(Center);
+  // give some verbose output about the whole procedure
+  if (CandidateLine.T != NULL)
+    DoLog(0) && (Log() << Verbose(0) << "--> New triangle with " << *BTS << " and normal vector " << BTS->NormalVector << ", from " << *CandidateLine.T << " and angle " << CandidateLine.ShortestAngle << "." << endl);
+  else
+    DoLog(0) && (Log() << Verbose(0) << "--> New starting triangle with " << *BTS << " and normal vector " << BTS->NormalVector << " and no top triangle." << endl);
+  triangle = BTS;
+
+  /// 3. Gather candidates for each new line
+  DoLog(0) && (Log() << Verbose(0) << "INFO: Adding candidates to new lines ..." << endl);
+  for (int i = 0; i < 3; i++) {
+    DoLog(0) && (Log() << Verbose(0) << "Current line is between " << *TPS[(i + 0) % 3] << " and " << *TPS[(i + 1) % 3] << ":" << endl);
+    CandidateCheck = OpenLines.find(BLS[i]);
+    if ((CandidateCheck != OpenLines.end()) && (CandidateCheck->second->pointlist.empty())) {
+      if (CandidateCheck->second->T == NULL)
+        CandidateCheck->second->T = triangle;
+      FindNextSuitableTriangle(*(CandidateCheck->second), *CandidateCheck->second->T, RADIUS, LC);
+    }
+  }
+
+  /// 4. Create or pick the lines for the second triangle
+  DoLog(0) && (Log() << Verbose(0) << "INFO: Creating/Picking lines for second triangle ..." << endl);
+  for (int i = 0; i < 3; i++) {
+    DoLog(0) && (Log() << Verbose(0) << "Current line is between " << *TPS[(i + 0) % 3] << " and " << *TPS[(i + 1) % 3] << ":" << endl);
+    AddTesselationLine(&CandidateLine.OtherOptCenter, TPS[(i + 2) % 3], TPS[(i + 0) % 3], TPS[(i + 1) % 3], i);
+  }
+
+  /// 5. create the second triangle and NormalVector and so on
+  DoLog(0) && (Log() << Verbose(0) << "INFO: Adding second triangle with center at " << CandidateLine.OtherOptCenter << " ..." << endl);
+  BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
+  AddTesselationTriangle();
+
+  BTS->SphereCenter = CandidateLine.OtherOptCenter;
+  // create normal vector in other direction
+  BTS->GetNormalVector(triangle->NormalVector);
+  BTS->NormalVector.Scale(-1.);
+  // give some verbose output about the whole procedure
+  if (CandidateLine.T != NULL)
+    DoLog(0) && (Log() << Verbose(0) << "--> New degenerate triangle with " << *BTS << " and normal vector " << BTS->NormalVector << ", from " << *CandidateLine.T << " and angle " << CandidateLine.ShortestAngle << "." << endl);
+  else
+    DoLog(0) && (Log() << Verbose(0) << "--> New degenerate starting triangle with " << *BTS << " and normal vector " << BTS->NormalVector << " and no top triangle." << endl);
+
+  /// 6. Adding triangle to new lines
+  DoLog(0) && (Log() << Verbose(0) << "INFO: Adding second triangles to new lines ..." << endl);
+  for (int i = 0; i < 3; i++) {
+    DoLog(0) && (Log() << Verbose(0) << "Current line is between " << *TPS[(i + 0) % 3] << " and " << *TPS[(i + 1) % 3] << ":" << endl);
+    CandidateCheck = OpenLines.find(BLS[i]);
+    if ((CandidateCheck != OpenLines.end()) && (CandidateCheck->second->pointlist.empty())) {
+      if (CandidateCheck->second->T == NULL)
+        CandidateCheck->second->T = BTS;
+    }
+  }
+}
+;
+
+/** Adds a triangle to the Tesselation structure from three given TesselPoint's.
+ * Note that endpoints are in Tesselation::TPS.
+ * \param CandidateLine CandidateForTesselation structure contains other information
+ * \param type which opt center to add (i.e. which side) and thus which NormalVector to take
+ */
+void Tesselation::AddCandidateTriangle(CandidateForTesselation &CandidateLine, enum centers type)
+{
+  Info FunctionInfo(__func__);
+  Vector Center;
+  Vector *OptCenter = (type == Opt) ? &CandidateLine.OptCenter : &CandidateLine.OtherOptCenter;
+
+  // add the lines
+  AddTesselationLine(OptCenter, TPS[2], TPS[0], TPS[1], 0);
+  AddTesselationLine(OptCenter, TPS[1], TPS[0], TPS[2], 1);
+  AddTesselationLine(OptCenter, TPS[0], TPS[1], TPS[2], 2);
+
+  // add the triangles
+  BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
+  AddTesselationTriangle();
+
+  // create normal vector
+  BTS->GetCenter(&Center);
+  Center.SubtractVector(*OptCenter);
+  BTS->SphereCenter = *OptCenter;
+  BTS->GetNormalVector(Center);
+
+  // give some verbose output about the whole procedure
+  if (CandidateLine.T != NULL)
+    DoLog(0) && (Log() << Verbose(0) << "--> New" << ((type == OtherOpt) ? " degenerate " : " ") << "triangle with " << *BTS << " and normal vector " << BTS->NormalVector << ", from " << *CandidateLine.T << " and angle " << CandidateLine.ShortestAngle << "." << endl);
+  else
+    DoLog(0) && (Log() << Verbose(0) << "--> New" << ((type == OtherOpt) ? " degenerate " : " ") << "starting triangle with " << *BTS << " and normal vector " << BTS->NormalVector << " and no top triangle." << endl);
+}
+;
+
+/** Checks whether the quadragon of the two triangles connect to \a *Base is convex.
+ * We look whether the closest point on \a *Base with respect to the other baseline is outside
+ * of the segment formed by both endpoints (concave) or not (convex).
+ * \param *out output stream for debugging
+ * \param *Base line to be flipped
+ * \return NULL - convex, otherwise endpoint that makes it concave
+ */
+class BoundaryPointSet *Tesselation::IsConvexRectangle(class BoundaryLineSet *Base)
+{
+  Info FunctionInfo(__func__);
+  class BoundaryPointSet *Spot = NULL;
+  class BoundaryLineSet *OtherBase;
+  Vector *ClosestPoint;
+
+  int m = 0;
+  for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++)
+    for (int j = 0; j < 3; j++) // all of their endpoints and baselines
+      if (!Base->ContainsBoundaryPoint(runner->second->endpoints[j])) // and neither of its endpoints
+        BPS[m++] = runner->second->endpoints[j];
+  OtherBase = new class BoundaryLineSet(BPS, -1);
+
+  DoLog(1) && (Log() << Verbose(1) << "INFO: Current base line is " << *Base << "." << endl);
+  DoLog(1) && (Log() << Verbose(1) << "INFO: Other base line is " << *OtherBase << "." << endl);
+
+  // get the closest point on each line to the other line
+  ClosestPoint = GetClosestPointBetweenLine(Base, OtherBase);
+
+  // delete the temporary other base line
+  delete (OtherBase);
+
+  // get the distance vector from Base line to OtherBase line
+  Vector DistanceToIntersection[2], BaseLine;
+  double distance[2];
+  BaseLine = (*Base->endpoints[1]->node->node) - (*Base->endpoints[0]->node->node);
+  for (int i = 0; i < 2; i++) {
+    DistanceToIntersection[i] = (*ClosestPoint) - (*Base->endpoints[i]->node->node);
+    distance[i] = BaseLine.ScalarProduct(DistanceToIntersection[i]);
+  }
+  delete (ClosestPoint);
+  if ((distance[0] * distance[1]) > 0) { // have same sign?
+    DoLog(1) && (Log() << Verbose(1) << "REJECT: Both SKPs have same sign: " << distance[0] << " and " << distance[1] << ". " << *Base << "' rectangle is concave." << endl);
+    if (distance[0] < distance[1]) {
+      Spot = Base->endpoints[0];
+    } else {
+      Spot = Base->endpoints[1];
+    }
+    return Spot;
+  } else { // different sign, i.e. we are in between
+    DoLog(0) && (Log() << Verbose(0) << "ACCEPT: Rectangle of triangles of base line " << *Base << " is convex." << endl);
+    return NULL;
+  }
+
+}
+;
+
+void Tesselation::PrintAllBoundaryPoints(ofstream *out) const
+{
+  Info FunctionInfo(__func__);
+  // print all lines
+  DoLog(0) && (Log() << Verbose(0) << "Printing all boundary points for debugging:" << endl);
+  for (PointMap::const_iterator PointRunner = PointsOnBoundary.begin(); PointRunner != PointsOnBoundary.end(); PointRunner++)
+    DoLog(0) && (Log() << Verbose(0) << *(PointRunner->second) << endl);
+}
+;
+
+void Tesselation::PrintAllBoundaryLines(ofstream *out) const
+{
+  Info FunctionInfo(__func__);
+  // print all lines
+  DoLog(0) && (Log() << Verbose(0) << "Printing all boundary lines for debugging:" << endl);
+  for (LineMap::const_iterator LineRunner = LinesOnBoundary.begin(); LineRunner != LinesOnBoundary.end(); LineRunner++)
+    DoLog(0) && (Log() << Verbose(0) << *(LineRunner->second) << endl);
+}
+;
+
+void Tesselation::PrintAllBoundaryTriangles(ofstream *out) const
+{
+  Info FunctionInfo(__func__);
+  // print all triangles
+  DoLog(0) && (Log() << Verbose(0) << "Printing all boundary triangles for debugging:" << endl);
+  for (TriangleMap::const_iterator TriangleRunner = TrianglesOnBoundary.begin(); TriangleRunner != TrianglesOnBoundary.end(); TriangleRunner++)
+    DoLog(0) && (Log() << Verbose(0) << *(TriangleRunner->second) << endl);
+}
+;
+
+/** For a given boundary line \a *Base and its two triangles, picks the central baseline that is "higher".
+ * \param *out output stream for debugging
+ * \param *Base line to be flipped
+ * \return volume change due to flipping (0 - then no flipped occured)
+ */
+double Tesselation::PickFarthestofTwoBaselines(class BoundaryLineSet *Base)
+{
+  Info FunctionInfo(__func__);
+  class BoundaryLineSet *OtherBase;
+  Vector *ClosestPoint[2];
+  double volume;
+
+  int m = 0;
+  for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++)
+    for (int j = 0; j < 3; j++) // all of their endpoints and baselines
+      if (!Base->ContainsBoundaryPoint(runner->second->endpoints[j])) // and neither of its endpoints
+        BPS[m++] = runner->second->endpoints[j];
+  OtherBase = new class BoundaryLineSet(BPS, -1);
+
+  DoLog(0) && (Log() << Verbose(0) << "INFO: Current base line is " << *Base << "." << endl);
+  DoLog(0) && (Log() << Verbose(0) << "INFO: Other base line is " << *OtherBase << "." << endl);
+
+  // get the closest point on each line to the other line
+  ClosestPoint[0] = GetClosestPointBetweenLine(Base, OtherBase);
+  ClosestPoint[1] = GetClosestPointBetweenLine(OtherBase, Base);
+
+  // get the distance vector from Base line to OtherBase line
+  Vector Distance = (*ClosestPoint[1]) - (*ClosestPoint[0]);
+
+  // calculate volume
+  volume = CalculateVolumeofGeneralTetraeder(*Base->endpoints[1]->node->node, *OtherBase->endpoints[0]->node->node, *OtherBase->endpoints[1]->node->node, *Base->endpoints[0]->node->node);
+
+  // delete the temporary other base line and the closest points
+  delete (ClosestPoint[0]);
+  delete (ClosestPoint[1]);
+  delete (OtherBase);
+
+  if (Distance.NormSquared() < MYEPSILON) { // check for intersection
+    DoLog(0) && (Log() << Verbose(0) << "REJECT: Both lines have an intersection: Nothing to do." << endl);
+    return false;
+  } else { // check for sign against BaseLineNormal
+    Vector BaseLineNormal;
+    BaseLineNormal.Zero();
+    if (Base->triangles.size() < 2) {
+      DoeLog(1) && (eLog() << Verbose(1) << "Less than two triangles are attached to this baseline!" << endl);
+      return 0.;
+    }
+    for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) {
+    DoLog(1) && (Log() << Verbose(1) << "INFO: Adding NormalVector " << runner->second->NormalVector << " of triangle " << *(runner->second) << "." << endl);
+      BaseLineNormal += (runner->second->NormalVector);
+    }
+    BaseLineNormal.Scale(1. / 2.);
+
+    if (Distance.ScalarProduct(BaseLineNormal) > MYEPSILON) { // Distance points outwards, hence OtherBase higher than Base -> flip
+      DoLog(0) && (Log() << Verbose(0) << "ACCEPT: Other base line would be higher: Flipping baseline." << endl);
+      // calculate volume summand as a general tetraeder
+      return volume;
+    } else { // Base higher than OtherBase -> do nothing
+      DoLog(0) && (Log() << Verbose(0) << "REJECT: Base line is higher: Nothing to do." << endl);
+      return 0.;
+    }
+  }
+}
+;
+
+/** For a given baseline and its two connected triangles, flips the baseline.
+ * I.e. we create the new baseline between the other two endpoints of these four
+ * endpoints and reconstruct the two triangles accordingly.
+ * \param *out output stream for debugging
+ * \param *Base line to be flipped
+ * \return pointer to allocated new baseline - flipping successful, NULL - something went awry
+ */
+class BoundaryLineSet * Tesselation::FlipBaseline(class BoundaryLineSet *Base)
+{
+  Info FunctionInfo(__func__);
+  class BoundaryLineSet *OldLines[4], *NewLine;
+  class BoundaryPointSet *OldPoints[2];
+  Vector BaseLineNormal;
+  int OldTriangleNrs[2], OldBaseLineNr;
+  int i, m;
+
+  // calculate NormalVector for later use
+  BaseLineNormal.Zero();
+  if (Base->triangles.size() < 2) {
+    DoeLog(1) && (eLog() << Verbose(1) << "Less than two triangles are attached to this baseline!" << endl);
+    return NULL;
+  }
+  for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) {
+    DoLog(1) && (Log() << Verbose(1) << "INFO: Adding NormalVector " << runner->second->NormalVector << " of triangle " << *(runner->second) << "." << endl);
+    BaseLineNormal += (runner->second->NormalVector);
+  }
+  BaseLineNormal.Scale(-1. / 2.); // has to point inside for BoundaryTriangleSet::GetNormalVector()
+
+  // get the two triangles
+  // gather four endpoints and four lines
+  for (int j = 0; j < 4; j++)
+    OldLines[j] = NULL;
+  for (int j = 0; j < 2; j++)
+    OldPoints[j] = NULL;
+  i = 0;
+  m = 0;
+  DoLog(0) && (Log() << Verbose(0) << "The four old lines are: ");
+  for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++)
+    for (int j = 0; j < 3; j++) // all of their endpoints and baselines
+      if (runner->second->lines[j] != Base) { // pick not the central baseline
+        OldLines[i++] = runner->second->lines[j];
+        DoLog(0) && (Log() << Verbose(0) << *runner->second->lines[j] << "\t");
+      }
+  DoLog(0) && (Log() << Verbose(0) << endl);
+  DoLog(0) && (Log() << Verbose(0) << "The two old points are: ");
+  for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++)
+    for (int j = 0; j < 3; j++) // all of their endpoints and baselines
+      if (!Base->ContainsBoundaryPoint(runner->second->endpoints[j])) { // and neither of its endpoints
+        OldPoints[m++] = runner->second->endpoints[j];
+        DoLog(0) && (Log() << Verbose(0) << *runner->second->endpoints[j] << "\t");
+      }
+  DoLog(0) && (Log() << Verbose(0) << endl);
+
+  // check whether everything is in place to create new lines and triangles
+  if (i < 4) {
+    DoeLog(1) && (eLog() << Verbose(1) << "We have not gathered enough baselines!" << endl);
+    return NULL;
+  }
+  for (int j = 0; j < 4; j++)
+    if (OldLines[j] == NULL) {
+      DoeLog(1) && (eLog() << Verbose(1) << "We have not gathered enough baselines!" << endl);
+      return NULL;
+    }
+  for (int j = 0; j < 2; j++)
+    if (OldPoints[j] == NULL) {
+      DoeLog(1) && (eLog() << Verbose(1) << "We have not gathered enough endpoints!" << endl);
+      return NULL;
+    }
+
+  // remove triangles and baseline removes itself
+  DoLog(0) && (Log() << Verbose(0) << "INFO: Deleting baseline " << *Base << " from global list." << endl);
+  OldBaseLineNr = Base->Nr;
+  m = 0;
+  // first obtain all triangle to delete ... (otherwise we pull the carpet (Base) from under the for-loop's feet)
+  list <BoundaryTriangleSet *> TrianglesOfBase;
+  for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); ++runner)
+    TrianglesOfBase.push_back(runner->second);
+  // .. then delete each triangle (which deletes the line as well)
+  for (list <BoundaryTriangleSet *>::iterator runner = TrianglesOfBase.begin(); !TrianglesOfBase.empty(); runner = TrianglesOfBase.begin()) {
+    DoLog(0) && (Log() << Verbose(0) << "INFO: Deleting triangle " << *(*runner) << "." << endl);
+    OldTriangleNrs[m++] = (*runner)->Nr;
+    RemoveTesselationTriangle((*runner));
+    TrianglesOfBase.erase(runner);
+  }
+
+  // construct new baseline (with same number as old one)
+  BPS[0] = OldPoints[0];
+  BPS[1] = OldPoints[1];
+  NewLine = new class BoundaryLineSet(BPS, OldBaseLineNr);
+  LinesOnBoundary.insert(LinePair(OldBaseLineNr, NewLine)); // no need for check for unique insertion as NewLine is definitely a new one
+  DoLog(0) && (Log() << Verbose(0) << "INFO: Created new baseline " << *NewLine << "." << endl);
+
+  // construct new triangles with flipped baseline
+  i = -1;
+  if (OldLines[0]->IsConnectedTo(OldLines[2]))
+    i = 2;
+  if (OldLines[0]->IsConnectedTo(OldLines[3]))
+    i = 3;
+  if (i != -1) {
+    BLS[0] = OldLines[0];
+    BLS[1] = OldLines[i];
+    BLS[2] = NewLine;
+    BTS = new class BoundaryTriangleSet(BLS, OldTriangleNrs[0]);
+    BTS->GetNormalVector(BaseLineNormal);
+    AddTesselationTriangle(OldTriangleNrs[0]);
+    DoLog(0) && (Log() << Verbose(0) << "INFO: Created new triangle " << *BTS << "." << endl);
+
+    BLS[0] = (i == 2 ? OldLines[3] : OldLines[2]);
+    BLS[1] = OldLines[1];
+    BLS[2] = NewLine;
+    BTS = new class BoundaryTriangleSet(BLS, OldTriangleNrs[1]);
+    BTS->GetNormalVector(BaseLineNormal);
+    AddTesselationTriangle(OldTriangleNrs[1]);
+    DoLog(0) && (Log() << Verbose(0) << "INFO: Created new triangle " << *BTS << "." << endl);
+  } else {
+    DoeLog(0) && (eLog() << Verbose(0) << "The four old lines do not connect, something's utterly wrong here!" << endl);
+    return NULL;
+  }
+
+  return NewLine;
+}
+;
+
+/** Finds the second point of starting triangle.
+ * \param *a first node
+ * \param Oben vector indicating the outside
+ * \param OptCandidate reference to recommended candidate on return
+ * \param Storage[3] array storing angles and other candidate information
+ * \param RADIUS radius of virtual sphere
+ * \param *LC LinkedCell structure with neighbouring points
+ */
+void Tesselation::FindSecondPointForTesselation(TesselPoint* a, Vector Oben, TesselPoint*& OptCandidate, double Storage[3], double RADIUS, const LinkedCell *LC)
+{
+  Info FunctionInfo(__func__);
+  Vector AngleCheck;
+  class TesselPoint* Candidate = NULL;
+  double norm = -1.;
+  double angle = 0.;
+  int N[NDIM];
+  int Nlower[NDIM];
+  int Nupper[NDIM];
+
+  if (LC->SetIndexToNode(a)) { // get cell for the starting point
+    for (int i = 0; i < NDIM; i++) // store indices of this cell
+      N[i] = LC->n[i];
+  } else {
+    DoeLog(1) && (eLog() << Verbose(1) << "Point " << *a << " is not found in cell " << LC->index << "." << endl);
+    return;
+  }
+  // then go through the current and all neighbouring cells and check the contained points for possible candidates
+  for (int i = 0; i < NDIM; i++) {
+    Nlower[i] = ((N[i] - 1) >= 0) ? N[i] - 1 : 0;
+    Nupper[i] = ((N[i] + 1) < LC->N[i]) ? N[i] + 1 : LC->N[i] - 1;
+  }
+  DoLog(0) && (Log() << Verbose(0) << "LC Intervals from [" << N[0] << "<->" << LC->N[0] << ", " << N[1] << "<->" << LC->N[1] << ", " << N[2] << "<->" << LC->N[2] << "] :" << " [" << Nlower[0] << "," << Nupper[0] << "], " << " [" << Nlower[1] << "," << Nupper[1] << "], " << " [" << Nlower[2] << "," << Nupper[2] << "], " << endl);
+
+  for (LC->n[0] = Nlower[0]; LC->n[0] <= Nupper[0]; LC->n[0]++)
+    for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
+      for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
+        const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
+        //Log() << Verbose(1) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl;
+        if (List != NULL) {
+          for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
+            Candidate = (*Runner);
+            // check if we only have one unique point yet ...
+            if (a != Candidate) {
+              // Calculate center of the circle with radius RADIUS through points a and Candidate
+              Vector OrthogonalizedOben, aCandidate, Center;
+              double distance, scaleFactor;
+
+              OrthogonalizedOben = Oben;
+              aCandidate = (*a->node) - (*Candidate->node);
+              OrthogonalizedOben.ProjectOntoPlane(aCandidate);
+              OrthogonalizedOben.Normalize();
+              distance = 0.5 * aCandidate.Norm();
+              scaleFactor = sqrt(((RADIUS * RADIUS) - (distance * distance)));
+              OrthogonalizedOben.Scale(scaleFactor);
+
+              Center = 0.5 * ((*Candidate->node) + (*a->node));
+              Center += OrthogonalizedOben;
+
+              AngleCheck = Center - (*a->node);
+              norm = aCandidate.Norm();
+              // second point shall have smallest angle with respect to Oben vector
+              if (norm < RADIUS * 2.) {
+                angle = AngleCheck.Angle(Oben);
+                if (angle < Storage[0]) {
+                  //Log() << Verbose(1) << "Old values of Storage: %lf %lf \n", Storage[0], Storage[1]);
+                  DoLog(1) && (Log() << Verbose(1) << "Current candidate is " << *Candidate << ": Is a better candidate with distance " << norm << " and angle " << angle << " to oben " << Oben << ".\n");
+                  OptCandidate = Candidate;
+                  Storage[0] = angle;
+                  //Log() << Verbose(1) << "Changing something in Storage: %lf %lf. \n", Storage[0], Storage[2]);
+                } else {
+                  //Log() << Verbose(1) << "Current candidate is " << *Candidate << ": Looses with angle " << angle << " to a better candidate " << *OptCandidate << endl;
+                }
+              } else {
+                //Log() << Verbose(1) << "Current candidate is " << *Candidate << ": Refused due to Radius " << norm << endl;
+              }
+            } else {
+              //Log() << Verbose(1) << "Current candidate is " << *Candidate << ": Candidate is equal to first endpoint." << *a << "." << endl;
+            }
+          }
+        } else {
+          DoLog(0) && (Log() << Verbose(0) << "Linked cell list is empty." << endl);
+        }
+      }
+}
+;
+
+/** This recursive function finds a third point, to form a triangle with two given ones.
+ * Note that this function is for the starting triangle.
+ * The idea is as follows: A sphere with fixed radius is (almost) uniquely defined in space by three points
+ * that sit on its boundary. Hence, when two points are given and we look for the (next) third point, then
+ * the center of the sphere is still fixed up to a single parameter. The band of possible values
+ * describes a circle in 3D-space. The old center of the sphere for the current base triangle gives
+ * us the "null" on this circle, the new center of the candidate point will be some way along this
+ * circle. The shorter the way the better is the candidate. Note that the direction is clearly given
+ * by the normal vector of the base triangle that always points outwards by construction.
+ * Hence, we construct a Center of this circle which sits right in the middle of the current base line.
+ * We construct the normal vector that defines the plane this circle lies in, it is just in the
+ * direction of the baseline. And finally, we need the radius of the circle, which is given by the rest
+ * with respect to the length of the baseline and the sphere's fixed \a RADIUS.
+ * Note that there is one difficulty: The circumcircle is uniquely defined, but for the circumsphere's center
+ * there are two possibilities which becomes clear from the construction as seen below. Hence, we must check
+ * both.
+ * Note also that the acos() function is not unique on [0, 2.*M_PI). Hence, we need an additional check
+ * to decide for one of the two possible angles. Therefore we need a SearchDirection and to make this check
+ * sensible we need OldSphereCenter to be orthogonal to it. Either we construct SearchDirection orthogonal
+ * right away, or -- what we do here -- we rotate the relative sphere centers such that this orthogonality
+ * holds. Then, the normalized projection onto the SearchDirection is either +1 or -1 and thus states whether
+ * the angle is uniquely in either (0,M_PI] or [M_PI, 2.*M_PI).
+ * @param NormalVector normal direction of the base triangle (here the unit axis vector, \sa FindStartingTriangle())
+ * @param SearchDirection general direction where to search for the next point, relative to center of BaseLine
+ * @param OldSphereCenter center of sphere for base triangle, relative to center of BaseLine, giving null angle for the parameter circle
+ * @param CandidateLine CandidateForTesselation with the current base line and list of candidates and ShortestAngle
+ * @param ThirdPoint third point to avoid in search
+ * @param RADIUS radius of sphere
+ * @param *LC LinkedCell structure with neighbouring points
+ */
+void Tesselation::FindThirdPointForTesselation(const Vector &NormalVector, const Vector &SearchDirection, const Vector &OldSphereCenter, CandidateForTesselation &CandidateLine, const class BoundaryPointSet * const ThirdPoint, const double RADIUS, const LinkedCell *LC) const
+{
+  Info FunctionInfo(__func__);
+  Vector CircleCenter; // center of the circle, i.e. of the band of sphere's centers
+  Vector CirclePlaneNormal; // normal vector defining the plane this circle lives in
+  Vector SphereCenter;
+  Vector NewSphereCenter; // center of the sphere defined by the two points of BaseLine and the one of Candidate, first possibility
+  Vector OtherNewSphereCenter; // center of the sphere defined by the two points of BaseLine and the one of Candidate, second possibility
+  Vector NewNormalVector; // normal vector of the Candidate's triangle
+  Vector helper, OptCandidateCenter, OtherOptCandidateCenter;
+  Vector RelativeOldSphereCenter;
+  Vector NewPlaneCenter;
+  double CircleRadius; // radius of this circle
+  double radius;
+  double otherradius;
+  double alpha, Otheralpha; // angles (i.e. parameter for the circle).
+  int N[NDIM], Nlower[NDIM], Nupper[NDIM];
+  TesselPoint *Candidate = NULL;
+
+  DoLog(1) && (Log() << Verbose(1) << "INFO: NormalVector of BaseTriangle is " << NormalVector << "." << endl);
+
+  // copy old center
+  CandidateLine.OldCenter = OldSphereCenter;
+  CandidateLine.ThirdPoint = ThirdPoint;
+  CandidateLine.pointlist.clear();
+
+  // construct center of circle
+  CircleCenter = 0.5 * ((*CandidateLine.BaseLine->endpoints[0]->node->node) +
+                        (*CandidateLine.BaseLine->endpoints[1]->node->node));
+
+  // construct normal vector of circle
+  CirclePlaneNormal = (*CandidateLine.BaseLine->endpoints[0]->node->node) -
+                      (*CandidateLine.BaseLine->endpoints[1]->node->node);
+
+  RelativeOldSphereCenter = OldSphereCenter - CircleCenter;
+
+  // calculate squared radius TesselPoint *ThirdPoint,f circle
+  radius = CirclePlaneNormal.NormSquared() / 4.;
+  if (radius < RADIUS * RADIUS) {
+    CircleRadius = RADIUS * RADIUS - radius;
+    CirclePlaneNormal.Normalize();
+    DoLog(1) && (Log() << Verbose(1) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl);
+
+    // test whether old center is on the band's plane
+    if (fabs(RelativeOldSphereCenter.ScalarProduct(CirclePlaneNormal)) > HULLEPSILON) {
+      DoeLog(1) && (eLog() << Verbose(1) << "Something's very wrong here: RelativeOldSphereCenter is not on the band's plane as desired by " << fabs(RelativeOldSphereCenter.ScalarProduct(CirclePlaneNormal)) << "!" << endl);
+      RelativeOldSphereCenter.ProjectOntoPlane(CirclePlaneNormal);
+    }
+    radius = RelativeOldSphereCenter.NormSquared();
+    if (fabs(radius - CircleRadius) < HULLEPSILON) {
+      DoLog(1) && (Log() << Verbose(1) << "INFO: RelativeOldSphereCenter is at " << RelativeOldSphereCenter << "." << endl);
+
+      // check SearchDirection
+      DoLog(1) && (Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl);
+      if (fabs(RelativeOldSphereCenter.ScalarProduct(SearchDirection)) > HULLEPSILON) { // rotated the wrong way!
+        DoeLog(1) && (eLog() << Verbose(1) << "SearchDirection and RelativeOldSphereCenter are not orthogonal!" << endl);
+      }
+
+      // get cell for the starting point
+      if (LC->SetIndexToVector(&CircleCenter)) {
+        for (int i = 0; i < NDIM; i++) // store indices of this cell
+          N[i] = LC->n[i];
+        //Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl;
+      } else {
+        DoeLog(1) && (eLog() << Verbose(1) << "Vector " << CircleCenter << " is outside of LinkedCell's bounding box." << endl);
+        return;
+      }
+      // then go through the current and all neighbouring cells and check the contained points for possible candidates
+      //Log() << Verbose(1) << "LC Intervals:";
+      for (int i = 0; i < NDIM; i++) {
+        Nlower[i] = ((N[i] - 1) >= 0) ? N[i] - 1 : 0;
+        Nupper[i] = ((N[i] + 1) < LC->N[i]) ? N[i] + 1 : LC->N[i] - 1;
+        //Log() << Verbose(0) << " [" << Nlower[i] << "," << Nupper[i] << "] ";
+      }
+      //Log() << Verbose(0) << endl;
+      for (LC->n[0] = Nlower[0]; LC->n[0] <= Nupper[0]; LC->n[0]++)
+        for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
+          for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
+            const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
+            //Log() << Verbose(1) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl;
+            if (List != NULL) {
+              for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
+                Candidate = (*Runner);
+
+                // check for three unique points
+                DoLog(2) && (Log() << Verbose(2) << "INFO: Current Candidate is " << *Candidate << " for BaseLine " << *CandidateLine.BaseLine << " with OldSphereCenter " << OldSphereCenter << "." << endl);
+                if ((Candidate != CandidateLine.BaseLine->endpoints[0]->node) && (Candidate != CandidateLine.BaseLine->endpoints[1]->node)) {
+
+                  // find center on the plane
+                  GetCenterofCircumcircle(&NewPlaneCenter, *CandidateLine.BaseLine->endpoints[0]->node->node, *CandidateLine.BaseLine->endpoints[1]->node->node, *Candidate->node);
+                  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();
+                    DoLog(1) && (Log() << Verbose(1) << "INFO: NewNormalVector is " << NewNormalVector << "." << endl);
+                    radius = CandidateLine.BaseLine->endpoints[0]->node->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);
+                      if (fabs(radius - otherradius) < HULLEPSILON) {
+                        // construct both new centers
+                        NewSphereCenter = NewPlaneCenter;
+                        OtherNewSphereCenter= NewPlaneCenter;
+                        helper = NewNormalVector;
+                        helper.Scale(sqrt(RADIUS * RADIUS - radius));
+                        DoLog(2) && (Log() << Verbose(2) << "INFO: Distance of NewPlaneCenter " << NewPlaneCenter << " to either NewSphereCenter is " << helper.Norm() << " of vector " << helper << " with sphere radius " << RADIUS << "." << endl);
+                        NewSphereCenter += helper;
+                        DoLog(2) && (Log() << Verbose(2) << "INFO: NewSphereCenter is at " << NewSphereCenter << "." << endl);
+                        // OtherNewSphereCenter is created by the same vector just in the other direction
+                        helper.Scale(-1.);
+                        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);
+                        if ((ThirdPoint != NULL) && (Candidate == ThirdPoint->node)) { // in that case only the other circlecenter is valid
+                          if (OldSphereCenter.DistanceSquared(NewSphereCenter) < OldSphereCenter.DistanceSquared(OtherNewSphereCenter))
+                            alpha = Otheralpha;
+                        } else
+                          alpha = min(alpha, Otheralpha);
+                        // if there is a better candidate, drop the current list and add the new candidate
+                        // otherwise ignore the new candidate and keep the list
+                        if (CandidateLine.ShortestAngle > (alpha - HULLEPSILON)) {
+                          if (fabs(alpha - Otheralpha) > MYEPSILON) {
+                            CandidateLine.OptCenter = NewSphereCenter;
+                            CandidateLine.OtherOptCenter = OtherNewSphereCenter;
+                          } else {
+                            CandidateLine.OptCenter = OtherNewSphereCenter;
+                            CandidateLine.OtherOptCenter = NewSphereCenter;
+                          }
+                          // if there is an equal candidate, add it to the list without clearing the list
+                          if ((CandidateLine.ShortestAngle - HULLEPSILON) < alpha) {
+                            CandidateLine.pointlist.push_back(Candidate);
+                            DoLog(0) && (Log() << Verbose(0) << "ACCEPT: We have found an equally good candidate: " << *(Candidate) << " with " << alpha << " and circumsphere's center at " << CandidateLine.OptCenter << "." << endl);
+                          } else {
+                            // remove all candidates from the list and then the list itself
+                            CandidateLine.pointlist.clear();
+                            CandidateLine.pointlist.push_back(Candidate);
+                            DoLog(0) && (Log() << Verbose(0) << "ACCEPT: We have found a better candidate: " << *(Candidate) << " with " << alpha << " and circumsphere's center at " << CandidateLine.OptCenter << "." << endl);
+                          }
+                          CandidateLine.ShortestAngle = alpha;
+                          DoLog(0) && (Log() << Verbose(0) << "INFO: There are " << CandidateLine.pointlist.size() << " candidates in the list now." << endl);
+                        } else {
+                          if ((Candidate != NULL) && (CandidateLine.pointlist.begin() != CandidateLine.pointlist.end())) {
+                            DoLog(1) && (Log() << Verbose(1) << "REJECT: Old candidate " << *(*CandidateLine.pointlist.begin()) << " with " << CandidateLine.ShortestAngle << " is better than new one " << *Candidate << " with " << alpha << " ." << endl);
+                          } else {
+                            DoLog(1) && (Log() << Verbose(1) << "REJECT: Candidate " << *Candidate << " with " << alpha << " was rejected." << endl);
+                          }
+                        }
+                      } else {
+                        DoeLog(0) && (eLog() << Verbose(1) << "REJECT: Distance to center of circumcircle is not the same from each corner of the triangle: " << fabs(radius - otherradius) << endl);
+                      }
+                    } else {
+                      DoLog(1) && (Log() << Verbose(1) << "REJECT: NewSphereCenter " << NewSphereCenter << " for " << *Candidate << " is too far away: " << radius << "." << endl);
+                    }
+                  }
+                  catch (LinearDependenceException &excp){
+                    Log() << Verbose(1) << excp;
+                    Log() << Verbose(1) << "REJECT: Three points from " << *CandidateLine.BaseLine << " and Candidate " << *Candidate << " are linear-dependent." << endl;
+                  }
+                } else {
+                  if (ThirdPoint != NULL) {
+                    DoLog(1) && (Log() << Verbose(1) << "REJECT: Base triangle " << *CandidateLine.BaseLine << " and " << *ThirdPoint << " contains Candidate " << *Candidate << "." << endl);
+                  } else {
+                    DoLog(1) && (Log() << Verbose(1) << "REJECT: Base triangle " << *CandidateLine.BaseLine << " contains Candidate " << *Candidate << "." << endl);
+                  }
+                }
+              }
+            }
+          }
+    } else {
+      DoeLog(1) && (eLog() << Verbose(1) << "The projected center of the old sphere has radius " << radius << " instead of " << CircleRadius << "." << endl);
+    }
+  } else {
+    if (ThirdPoint != NULL)
+      DoLog(1) && (Log() << Verbose(1) << "Circumcircle for base line " << *CandidateLine.BaseLine << " and third node " << *ThirdPoint << " is too big!" << endl);
+    else
+      DoLog(1) && (Log() << Verbose(1) << "Circumcircle for base line " << *CandidateLine.BaseLine << " is too big!" << endl);
+  }
+
+  DoLog(1) && (Log() << Verbose(1) << "INFO: Sorting candidate list ..." << endl);
+  if (CandidateLine.pointlist.size() > 1) {
+    CandidateLine.pointlist.unique();
+    CandidateLine.pointlist.sort(); //SortCandidates);
+  }
+
+  if ((!CandidateLine.pointlist.empty()) && (!CandidateLine.CheckValidity(RADIUS, LC))) {
+    DoeLog(0) && (eLog() << Verbose(0) << "There were other points contained in the rolling sphere as well!" << endl);
+    performCriticalExit();
+  }
+}
+;
+
+/** Finds the endpoint two lines are sharing.
+ * \param *line1 first line
+ * \param *line2 second line
+ * \return point which is shared or NULL if none
+ */
+class BoundaryPointSet *Tesselation::GetCommonEndpoint(const BoundaryLineSet * line1, const BoundaryLineSet * line2) const
+{
+  Info FunctionInfo(__func__);
+  const BoundaryLineSet * lines[2] = { line1, line2 };
+  class BoundaryPointSet *node = NULL;
+  PointMap OrderMap;
+  PointTestPair OrderTest;
+  for (int i = 0; i < 2; i++)
+    // for both lines
+    for (int j = 0; j < 2; j++) { // for both endpoints
+      OrderTest = OrderMap.insert(pair<int, class BoundaryPointSet *> (lines[i]->endpoints[j]->Nr, lines[i]->endpoints[j]));
+      if (!OrderTest.second) { // if insertion fails, we have common endpoint
+        node = OrderTest.first->second;
+        DoLog(1) && (Log() << Verbose(1) << "Common endpoint of lines " << *line1 << " and " << *line2 << " is: " << *node << "." << endl);
+        j = 2;
+        i = 2;
+        break;
+      }
+    }
+  return node;
+}
+;
+
+/** Finds the boundary points that are closest to a given Vector \a *x.
+ * \param *out output stream for debugging
+ * \param *x Vector to look from
+ * \return map of BoundaryPointSet of closest points sorted by squared distance or NULL.
+ */
+DistanceToPointMap * Tesselation::FindClosestBoundaryPointsToVector(const Vector *x, const LinkedCell* LC) const
+{
+  Info FunctionInfo(__func__);
+  PointMap::const_iterator FindPoint;
+  int N[NDIM], Nlower[NDIM], Nupper[NDIM];
+
+  if (LinesOnBoundary.empty()) {
+    DoeLog(1) && (eLog() << Verbose(1) << "There is no tesselation structure to compare the point with, please create one first." << endl);
+    return NULL;
+  }
+
+  // gather all points close to the desired one
+  LC->SetIndexToVector(x); // ignore status as we calculate bounds below sensibly
+  for (int i = 0; i < NDIM; i++) // store indices of this cell
+    N[i] = LC->n[i];
+  DoLog(1) && (Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl);
+  DistanceToPointMap * points = new DistanceToPointMap;
+  LC->GetNeighbourBounds(Nlower, Nupper);
+  //Log() << Verbose(1) << endl;
+  for (LC->n[0] = Nlower[0]; LC->n[0] <= Nupper[0]; LC->n[0]++)
+    for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
+      for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
+        const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
+        //Log() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << endl;
+        if (List != NULL) {
+          for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
+            FindPoint = PointsOnBoundary.find((*Runner)->nr);
+            if (FindPoint != PointsOnBoundary.end()) {
+              points->insert(DistanceToPointPair(FindPoint->second->node->node->DistanceSquared(*x), FindPoint->second));
+              DoLog(1) && (Log() << Verbose(1) << "INFO: Putting " << *FindPoint->second << " into the list." << endl);
+            }
+          }
+        } else {
+          DoeLog(1) && (eLog() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << " is invalid!" << endl);
+        }
+      }
+
+  // check whether we found some points
+  if (points->empty()) {
+    DoeLog(1) && (eLog() << Verbose(1) << "There is no nearest point: too far away from the surface." << endl);
+    delete (points);
+    return NULL;
+  }
+  return points;
+}
+;
+
+/** Finds the boundary line that is closest to a given Vector \a *x.
+ * \param *out output stream for debugging
+ * \param *x Vector to look from
+ * \return closest BoundaryLineSet or NULL in degenerate case.
+ */
+BoundaryLineSet * Tesselation::FindClosestBoundaryLineToVector(const Vector *x, const LinkedCell* LC) const
+{
+  Info FunctionInfo(__func__);
+  // get closest points
+  DistanceToPointMap * points = FindClosestBoundaryPointsToVector(x, LC);
+  if (points == NULL) {
+    DoeLog(1) && (eLog() << Verbose(1) << "There is no nearest point: too far away from the surface." << endl);
+    return NULL;
+  }
+
+  // for each point, check its lines, remember closest
+  DoLog(1) && (Log() << Verbose(1) << "Finding closest BoundaryLine to " << *x << " ... " << endl);
+  BoundaryLineSet *ClosestLine = NULL;
+  double MinDistance = -1.;
+  Vector helper;
+  Vector Center;
+  Vector BaseLine;
+  for (DistanceToPointMap::iterator Runner = points->begin(); Runner != points->end(); Runner++) {
+    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);
+      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;
+        const double lengthA = helper.ScalarProduct(BaseLine);
+        helper = (*x) - (*(LineRunner->second)->endpoints[1]->node->node) - Center;
+        const double lengthB = helper.ScalarProduct(BaseLine);
+        if (lengthB * lengthA < 0) { // if have different sign
+          ClosestLine = LineRunner->second;
+          MinDistance = distance;
+          DoLog(1) && (Log() << Verbose(1) << "ACCEPT: New closest line is " << *ClosestLine << " with projected distance " << MinDistance << "." << endl);
+        } else {
+          DoLog(1) && (Log() << Verbose(1) << "REJECT: Intersection is outside of the line section: " << lengthA << " and " << lengthB << "." << endl);
+        }
+      } else {
+        DoLog(1) && (Log() << Verbose(1) << "REJECT: Point is too further away than present line: " << distance << " >> " << MinDistance << "." << endl);
+      }
+    }
+  }
+  delete (points);
+  // check whether closest line is "too close" :), then it's inside
+  if (ClosestLine == NULL) {
+    DoLog(0) && (Log() << Verbose(0) << "Is the only point, no one else is closeby." << endl);
+    return NULL;
+  }
+  return ClosestLine;
+}
+;
+
+/** Finds the triangle that is closest to a given Vector \a *x.
+ * \param *out output stream for debugging
+ * \param *x Vector to look from
+ * \return BoundaryTriangleSet of nearest triangle or NULL.
+ */
+TriangleList * Tesselation::FindClosestTrianglesToVector(const Vector *x, const LinkedCell* LC) const
+{
+  Info FunctionInfo(__func__);
+  // get closest points
+  DistanceToPointMap * points = FindClosestBoundaryPointsToVector(x, LC);
+  if (points == NULL) {
+    DoeLog(1) && (eLog() << Verbose(1) << "There is no nearest point: too far away from the surface." << endl);
+    return NULL;
+  }
+
+  // for each point, check its lines, remember closest
+  DoLog(1) && (Log() << Verbose(1) << "Finding closest BoundaryTriangle to " << *x << " ... " << endl);
+  LineSet ClosestLines;
+  double MinDistance = 1e+16;
+  Vector BaseLineIntersection;
+  Vector Center;
+  Vector BaseLine;
+  Vector BaseLineCenter;
+  for (DistanceToPointMap::iterator Runner = points->begin(); Runner != points->end(); Runner++) {
+    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);
+      const double lengthBase = BaseLine.NormSquared();
+
+      BaseLineIntersection = (*x) - (*(LineRunner->second)->endpoints[0]->node->node);
+      const double lengthEndA = BaseLineIntersection.NormSquared();
+
+      BaseLineIntersection = (*x) - (*(LineRunner->second)->endpoints[1]->node->node);
+      const double lengthEndB = BaseLineIntersection.NormSquared();
+
+      if ((lengthEndA > lengthBase) || (lengthEndB > lengthBase) || ((lengthEndA < MYEPSILON) || (lengthEndB < MYEPSILON))) { // intersection would be outside, take closer endpoint
+        const double lengthEnd = Min(lengthEndA, lengthEndB);
+        if (lengthEnd - MinDistance < -MYEPSILON) { // new best line
+          ClosestLines.clear();
+          ClosestLines.insert(LineRunner->second);
+          MinDistance = lengthEnd;
+          DoLog(1) && (Log() << Verbose(1) << "ACCEPT: Line " << *LineRunner->second << " to endpoint " << *LineRunner->second->endpoints[0]->node << " is closer with " << lengthEnd << "." << endl);
+        } else if (fabs(lengthEnd - MinDistance) < MYEPSILON) { // additional best candidate
+          ClosestLines.insert(LineRunner->second);
+          DoLog(1) && (Log() << Verbose(1) << "ACCEPT: Line " << *LineRunner->second << " to endpoint " << *LineRunner->second->endpoints[1]->node << " is equally good with " << lengthEnd << "." << endl);
+        } else { // line is worse
+          DoLog(1) && (Log() << Verbose(1) << "REJECT: Line " << *LineRunner->second << " to either endpoints is further away than present closest line candidate: " << lengthEndA << ", " << lengthEndB << ", and distance is longer than baseline:" << lengthBase << "." << endl);
+        }
+      } else { // intersection is closer, calculate
+        // calculate closest point on line to desired point
+        BaseLineIntersection = (*x) - (*(LineRunner->second)->endpoints[1]->node->node);
+        Center = BaseLineIntersection;
+        Center.ProjectOntoPlane(BaseLine);
+        BaseLineIntersection -= Center;
+        const double distance = BaseLineIntersection.NormSquared();
+        if (Center.NormSquared() > BaseLine.NormSquared()) {
+          DoeLog(0) && (eLog() << Verbose(0) << "Algorithmic error: In second case we have intersection outside of baseline!" << endl);
+        }
+        if ((ClosestLines.empty()) || (distance < MinDistance)) {
+          ClosestLines.insert(LineRunner->second);
+          MinDistance = distance;
+          DoLog(1) && (Log() << Verbose(1) << "ACCEPT: Intersection in between endpoints, new closest line " << *LineRunner->second << " is " << *ClosestLines.begin() << " with projected distance " << MinDistance << "." << endl);
+        } else {
+          DoLog(2) && (Log() << Verbose(2) << "REJECT: Point is further away from line " << *LineRunner->second << " than present closest line: " << distance << " >> " << MinDistance << "." << endl);
+        }
+      }
+    }
+  }
+  delete (points);
+
+  // check whether closest line is "too close" :), then it's inside
+  if (ClosestLines.empty()) {
+    DoLog(0) && (Log() << Verbose(0) << "Is the only point, no one else is closeby." << endl);
+    return NULL;
+  }
+  TriangleList * candidates = new TriangleList;
+  for (LineSet::iterator LineRunner = ClosestLines.begin(); LineRunner != ClosestLines.end(); LineRunner++)
+    for (TriangleMap::iterator Runner = (*LineRunner)->triangles.begin(); Runner != (*LineRunner)->triangles.end(); Runner++) {
+      candidates->push_back(Runner->second);
+    }
+  return candidates;
+}
+;
+
+/** Finds closest triangle to a point.
+ * This basically just takes care of the degenerate case, which is not handled in FindClosestTrianglesToPoint().
+ * \param *out output stream for debugging
+ * \param *x Vector to look from
+ * \param &distance contains found distance on return
+ * \return list of BoundaryTriangleSet of nearest triangles or NULL.
+ */
+class BoundaryTriangleSet * Tesselation::FindClosestTriangleToVector(const Vector *x, const LinkedCell* LC) const
+{
+  Info FunctionInfo(__func__);
+  class BoundaryTriangleSet *result = NULL;
+  TriangleList *triangles = FindClosestTrianglesToVector(x, LC);
+  TriangleList candidates;
+  Vector Center;
+  Vector helper;
+
+  if ((triangles == NULL) || (triangles->empty()))
+    return NULL;
+
+  // go through all and pick the one with the best alignment to x
+  double MinAlignment = 2. * M_PI;
+  for (TriangleList::iterator Runner = triangles->begin(); Runner != triangles->end(); Runner++) {
+    (*Runner)->GetCenter(&Center);
+    helper = (*x) - Center;
+    const double Alignment = helper.Angle((*Runner)->NormalVector);
+    if (Alignment < MinAlignment) {
+      result = *Runner;
+      MinAlignment = Alignment;
+      DoLog(1) && (Log() << Verbose(1) << "ACCEPT: Triangle " << *result << " is better aligned with " << MinAlignment << "." << endl);
+    } else {
+      DoLog(1) && (Log() << Verbose(1) << "REJECT: Triangle " << *result << " is worse aligned with " << MinAlignment << "." << endl);
+    }
+  }
+  delete (triangles);
+
+  return result;
+}
+;
+
+/** Checks whether the provided Vector is within the Tesselation structure.
+ * Basically calls Tesselation::GetDistanceToSurface() and checks the sign of the return value.
+ * @param point of which to check the position
+ * @param *LC LinkedCell structure
+ *
+ * @return true if the point is inside the Tesselation structure, false otherwise
+ */
+bool Tesselation::IsInnerPoint(const Vector &Point, const LinkedCell* const LC) const
+{
+  Info FunctionInfo(__func__);
+  TriangleIntersectionList Intersections(&Point, this, LC);
+
+  return Intersections.IsInside();
+}
+;
+
+/** Returns the distance to the surface given by the tesselation.
+ * Calls FindClosestTriangleToVector() and checks whether the resulting triangle's BoundaryTriangleSet#NormalVector points
+ * towards or away from the given \a &Point. Additionally, we check whether it's normal to the normal vector, i.e. on the
+ * closest triangle's plane. Then, we have to check whether \a Point is inside the triangle or not to determine whether it's
+ * an inside or outside point. This is done by calling BoundaryTriangleSet::GetIntersectionInsideTriangle().
+ * In the end we additionally find the point on the triangle who was smallest distance to \a Point:
+ *  -# Separate distance from point to center in vector in NormalDirection and on the triangle plane.
+ *  -# Check whether vector on triangle plane points inside the triangle or crosses triangle bounds.
+ *  -# If inside, take it to calculate closest distance
+ *  -# If not, take intersection with BoundaryLine as distance
+ *
+ * @note distance is squared despite it still contains a sign to determine in-/outside!
+ *
+ * @param point of which to check the position
+ * @param *LC LinkedCell structure
+ *
+ * @return >0 if outside, ==0 if on surface, <0 if inside
+ */
+double Tesselation::GetDistanceSquaredToTriangle(const Vector &Point, const BoundaryTriangleSet* const triangle) const
+{
+  Info FunctionInfo(__func__);
+  Vector Center;
+  Vector helper;
+  Vector DistanceToCenter;
+  Vector Intersection;
+  double distance = 0.;
+
+  if (triangle == NULL) {// is boundary point or only point in point cloud?
+    DoLog(1) && (Log() << Verbose(1) << "No triangle given!" << endl);
+    return -1.;
+  } else {
+    DoLog(1) && (Log() << Verbose(1) << "INFO: Closest triangle found is " << *triangle << " with normal vector " << triangle->NormalVector << "." << endl);
+  }
+
+  triangle->GetCenter(&Center);
+  DoLog(2) && (Log() << Verbose(2) << "INFO: Central point of the triangle is " << Center << "." << endl);
+  DistanceToCenter = Center - Point;
+  DoLog(2) && (Log() << Verbose(2) << "INFO: Vector from point to test to center is " << DistanceToCenter << "." << endl);
+
+  // check whether we are on boundary
+  if (fabs(DistanceToCenter.ScalarProduct(triangle->NormalVector)) < MYEPSILON) {
+    // calculate whether inside of triangle
+    DistanceToCenter = Point + triangle->NormalVector; // points outside
+    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)) {
+      DoLog(1) && (Log() << Verbose(1) << Point << " is inner point: sufficiently close to boundary, " << Intersection << "." << endl);
+      return 0.;
+    } else {
+      DoLog(1) && (Log() << Verbose(1) << Point << " is NOT an inner point: on triangle plane but outside of triangle bounds." << endl);
+      return false;
+    }
+  } else {
+    // calculate smallest distance
+    distance = triangle->GetClosestPointInsideTriangle(&Point, &Intersection);
+    DoLog(1) && (Log() << Verbose(1) << "Closest point on triangle is " << Intersection << "." << endl);
+
+    // then check direction to boundary
+    if (DistanceToCenter.ScalarProduct(triangle->NormalVector) > MYEPSILON) {
+      DoLog(1) && (Log() << Verbose(1) << Point << " is an inner point, " << distance << " below surface." << endl);
+      return -distance;
+    } else {
+      DoLog(1) && (Log() << Verbose(1) << Point << " is NOT an inner point, " << distance << " above surface." << endl);
+      return +distance;
+    }
+  }
+}
+;
+
+/** Calculates minimum distance from \a&Point to a tesselated surface.
+ * Combines \sa FindClosestTrianglesToVector() and \sa GetDistanceSquaredToTriangle().
+ * \param &Point point to calculate distance from
+ * \param *LC needed for finding closest points fast
+ * \return distance squared to closest point on surface
+ */
+double Tesselation::GetDistanceToSurface(const Vector &Point, const LinkedCell* const LC) const
+{
+  Info FunctionInfo(__func__);
+  TriangleIntersectionList Intersections(&Point, this, LC);
+
+  return Intersections.GetSmallestDistance();
+}
+;
+
+/** Calculates minimum distance from \a&Point to a tesselated surface.
+ * Combines \sa FindClosestTrianglesToVector() and \sa GetDistanceSquaredToTriangle().
+ * \param &Point point to calculate distance from
+ * \param *LC needed for finding closest points fast
+ * \return distance squared to closest point on surface
+ */
+BoundaryTriangleSet * Tesselation::GetClosestTriangleOnSurface(const Vector &Point, const LinkedCell* const LC) const
+{
+  Info FunctionInfo(__func__);
+  TriangleIntersectionList Intersections(&Point, this, LC);
+
+  return Intersections.GetClosestTriangle();
+}
+;
+
+/** Gets all points connected to the provided point by triangulation lines.
+ *
+ * @param *Point of which get all connected points
+ *
+ * @return set of the all points linked to the provided one
+ */
+TesselPointSet * Tesselation::GetAllConnectedPoints(const TesselPoint* const Point) const
+{
+  Info FunctionInfo(__func__);
+  TesselPointSet *connectedPoints = new TesselPointSet;
+  class BoundaryPointSet *ReferencePoint = NULL;
+  TesselPoint* current;
+  bool takePoint = false;
+  // find the respective boundary point
+  PointMap::const_iterator PointRunner = PointsOnBoundary.find(Point->nr);
+  if (PointRunner != PointsOnBoundary.end()) {
+    ReferencePoint = PointRunner->second;
+  } else {
+    DoeLog(2) && (eLog() << Verbose(2) << "GetAllConnectedPoints() could not find the BoundaryPoint belonging to " << *Point << "." << endl);
+    ReferencePoint = NULL;
+  }
+
+  // little trick so that we look just through lines connect to the BoundaryPoint
+  // OR fall-back to look through all lines if there is no such BoundaryPoint
+  const LineMap *Lines;
+  ;
+  if (ReferencePoint != NULL)
+    Lines = &(ReferencePoint->lines);
+  else
+    Lines = &LinesOnBoundary;
+  LineMap::const_iterator findLines = Lines->begin();
+  while (findLines != Lines->end()) {
+    takePoint = false;
+
+    if (findLines->second->endpoints[0]->Nr == Point->nr) {
+      takePoint = true;
+      current = findLines->second->endpoints[1]->node;
+    } else if (findLines->second->endpoints[1]->Nr == Point->nr) {
+      takePoint = true;
+      current = findLines->second->endpoints[0]->node;
+    }
+
+    if (takePoint) {
+      DoLog(1) && (Log() << Verbose(1) << "INFO: Endpoint " << *current << " of line " << *(findLines->second) << " is enlisted." << endl);
+      connectedPoints->insert(current);
+    }
+
+    findLines++;
+  }
+
+  if (connectedPoints->empty()) { // if have not found any points
+    DoeLog(1) && (eLog() << Verbose(1) << "We have not found any connected points to " << *Point << "." << endl);
+    return NULL;
+  }
+
+  return connectedPoints;
+}
+;
+
+/** Gets all points connected to the provided point by triangulation lines, ordered such that we have the circle round the point.
+ * Maps them down onto the plane designated by the axis \a *Point and \a *Reference. The center of all points
+ * connected in the tesselation to \a *Point is mapped to spherical coordinates with the zero angle being given
+ * by the mapped down \a *Reference. Hence, the biggest and the smallest angles are those of the two shanks of the
+ * triangle we are looking for.
+ *
+ * @param *out output stream for debugging
+ * @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
+ * @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
+{
+  Info FunctionInfo(__func__);
+  map<double, TesselPoint*> anglesOfPoints;
+  TesselPointList *connectedCircle = new TesselPointList;
+  Vector PlaneNormal;
+  Vector AngleZero;
+  Vector OrthogonalVector;
+  Vector helper;
+  const TesselPoint * const TrianglePoints[3] = { Point, NULL, NULL };
+  TriangleList *triangles = NULL;
+
+  if (SetOfNeighbours == NULL) {
+    DoeLog(2) && (eLog() << Verbose(2) << "Could not find any connected points!" << endl);
+    delete (connectedCircle);
+    return NULL;
+  }
+
+  // calculate central point
+  triangles = FindTriangles(TrianglePoints);
+  if ((triangles != NULL) && (!triangles->empty())) {
+    for (TriangleList::iterator Runner = triangles->begin(); Runner != triangles->end(); Runner++)
+      PlaneNormal += (*Runner)->NormalVector;
+  } else {
+    DoeLog(0) && (eLog() << Verbose(0) << "Could not find any triangles for point " << *Point << "." << endl);
+    performCriticalExit();
+  }
+  PlaneNormal.Scale(1.0 / triangles->size());
+  DoLog(1) && (Log() << Verbose(1) << "INFO: Calculated PlaneNormal of all circle points is " << PlaneNormal << "." << endl);
+  PlaneNormal.Normalize();
+
+  // 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.ProjectOntoPlane(PlaneNormal);
+    if (AngleZero.NormSquared() < MYEPSILON) {
+      DoeLog(0) && (eLog() << Verbose(0) << "CRITIAL: AngleZero is 0 even with alternative reference. The algorithm has to be changed here!" << endl);
+      performCriticalExit();
+    }
+  }
+  DoLog(1) && (Log() << Verbose(1) << "INFO: Reference vector on this plane representing angle 0 is " << AngleZero << "." << endl);
+  if (AngleZero.NormSquared() > MYEPSILON)
+    OrthogonalVector = Plane(PlaneNormal, AngleZero,0).getNormal();
+  else
+    OrthogonalVector.MakeNormalTo(PlaneNormal);
+  DoLog(1) && (Log() << Verbose(1) << "INFO: OrthogonalVector on plane is " << OrthogonalVector << "." << endl);
+
+  // go through all connected points and calculate angle
+  for (TesselPointSet::iterator listRunner = SetOfNeighbours->begin(); listRunner != SetOfNeighbours->end(); listRunner++) {
+    helper = (*(*listRunner)->node) - (*Point->node);
+    helper.ProjectOntoPlane(PlaneNormal);
+    double angle = GetAngle(helper, AngleZero, OrthogonalVector);
+    DoLog(0) && (Log() << Verbose(0) << "INFO: Calculated angle is " << angle << " for point " << **listRunner << "." << endl);
+    anglesOfPoints.insert(pair<double, TesselPoint*> (angle, (*listRunner)));
+  }
+
+  for (map<double, TesselPoint*>::iterator AngleRunner = anglesOfPoints.begin(); AngleRunner != anglesOfPoints.end(); AngleRunner++) {
+    connectedCircle->push_back(AngleRunner->second);
+  }
+
+  return connectedCircle;
+}
+
+/** Gets all points connected to the provided point by triangulation lines, ordered such that we have the circle round the point.
+ * Maps them down onto the plane designated by the axis \a *Point and \a *Reference. The center of all points
+ * connected in the tesselation to \a *Point is mapped to spherical coordinates with the zero angle being given
+ * by the mapped down \a *Reference. Hence, the biggest and the smallest angles are those of the two shanks of the
+ * triangle we are looking for.
+ *
+ * @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
+ * @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
+{
+  Info FunctionInfo(__func__);
+  map<double, TesselPoint*> anglesOfPoints;
+  TesselPointList *connectedCircle = new TesselPointList;
+  Vector center;
+  Vector PlaneNormal;
+  Vector AngleZero;
+  Vector OrthogonalVector;
+  Vector helper;
+
+  if (SetOfNeighbours == NULL) {
+    DoeLog(2) && (eLog() << Verbose(2) << "Could not find any connected points!" << endl);
+    delete (connectedCircle);
+    return NULL;
+  }
+
+  // check whether there's something to do
+  if (SetOfNeighbours->size() < 3) {
+    for (TesselPointSet::iterator TesselRunner = SetOfNeighbours->begin(); TesselRunner != SetOfNeighbours->end(); TesselRunner++)
+      connectedCircle->push_back(*TesselRunner);
+    return connectedCircle;
+  }
+
+  DoLog(1) && (Log() << Verbose(1) << "INFO: Point is " << *Point << " and Reference is " << *Reference << "." << endl);
+  // calculate central point
+  TesselPointSet::const_iterator TesselA = SetOfNeighbours->begin();
+  TesselPointSet::const_iterator TesselB = SetOfNeighbours->begin();
+  TesselPointSet::const_iterator TesselC = SetOfNeighbours->begin();
+  TesselB++;
+  TesselC++;
+  TesselC++;
+  int counter = 0;
+  while (TesselC != SetOfNeighbours->end()) {
+    helper = Plane(*((*TesselA)->node),
+                   *((*TesselB)->node),
+                   *((*TesselC)->node)).getNormal();
+    DoLog(0) && (Log() << Verbose(0) << "Making normal vector out of " << *(*TesselA) << ", " << *(*TesselB) << " and " << *(*TesselC) << ":" << helper << endl);
+    counter++;
+    TesselA++;
+    TesselB++;
+    TesselC++;
+    PlaneNormal += helper;
+  }
+  //Log() << Verbose(0) << "Summed vectors " << center << "; number of points " << connectedPoints.size()
+  //  << "; scale factor " << counter;
+  PlaneNormal.Scale(1.0 / (double) counter);
+  //  Log() << Verbose(1) << "INFO: Calculated center of all circle points is " << center << "." << endl;
+  //
+  //  // projection plane of the circle is at the closes Point and normal is pointing away from center of all circle points
+  //  PlaneNormal.CopyVector(Point->node);
+  //  PlaneNormal.SubtractVector(&center);
+  //  PlaneNormal.Normalize();
+  DoLog(1) && (Log() << Verbose(1) << "INFO: Calculated plane normal of circle is " << PlaneNormal << "." << endl);
+
+  // 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.ProjectOntoPlane(PlaneNormal);
+    if (AngleZero.NormSquared() < MYEPSILON) {
+      DoeLog(0) && (eLog() << Verbose(0) << "CRITIAL: AngleZero is 0 even with alternative reference. The algorithm has to be changed here!" << endl);
+      performCriticalExit();
+    }
+  }
+  DoLog(1) && (Log() << Verbose(1) << "INFO: Reference vector on this plane representing angle 0 is " << AngleZero << "." << endl);
+  if (AngleZero.NormSquared() > MYEPSILON)
+    OrthogonalVector = Plane(PlaneNormal, AngleZero,0).getNormal();
+  else
+    OrthogonalVector.MakeNormalTo(PlaneNormal);
+  DoLog(1) && (Log() << Verbose(1) << "INFO: OrthogonalVector on plane is " << OrthogonalVector << "." << endl);
+
+  // go through all connected points and calculate angle
+  pair<map<double, TesselPoint*>::iterator, bool> InserterTest;
+  for (TesselPointSet::iterator listRunner = SetOfNeighbours->begin(); listRunner != SetOfNeighbours->end(); listRunner++) {
+    helper = (*(*listRunner)->node) - (*Point->node);
+    helper.ProjectOntoPlane(PlaneNormal);
+    double angle = GetAngle(helper, AngleZero, OrthogonalVector);
+    if (angle > M_PI) // the correction is of no use here (and not desired)
+      angle = 2. * M_PI - angle;
+    DoLog(0) && (Log() << Verbose(0) << "INFO: Calculated angle between " << helper << " and " << AngleZero << " is " << angle << " for point " << **listRunner << "." << endl);
+    InserterTest = anglesOfPoints.insert(pair<double, TesselPoint*> (angle, (*listRunner)));
+    if (!InserterTest.second) {
+      DoeLog(0) && (eLog() << Verbose(0) << "GetCircleOfSetOfPoints() got two atoms with same angle: " << *((InserterTest.first)->second) << " and " << (*listRunner) << endl);
+      performCriticalExit();
+    }
+  }
+
+  for (map<double, TesselPoint*>::iterator AngleRunner = anglesOfPoints.begin(); AngleRunner != anglesOfPoints.end(); AngleRunner++) {
+    connectedCircle->push_back(AngleRunner->second);
+  }
+
+  return connectedCircle;
+}
+
+/** Gets all points connected to the provided point by triangulation lines, ordered such that we walk along a closed path.
+ *
+ * @param *out output stream for debugging
+ * @param *Point of which get all connected points
+ * @return list of the all points linked to the provided one
+ */
+ListOfTesselPointList * Tesselation::GetPathsOfConnectedPoints(const TesselPoint* const Point) const
+{
+  Info FunctionInfo(__func__);
+  map<double, TesselPoint*> anglesOfPoints;
+  list<TesselPointList *> *ListOfPaths = new list<TesselPointList *> ;
+  TesselPointList *connectedPath = NULL;
+  Vector center;
+  Vector PlaneNormal;
+  Vector AngleZero;
+  Vector OrthogonalVector;
+  Vector helper;
+  class BoundaryPointSet *ReferencePoint = NULL;
+  class BoundaryPointSet *CurrentPoint = NULL;
+  class BoundaryTriangleSet *triangle = NULL;
+  class BoundaryLineSet *CurrentLine = NULL;
+  class BoundaryLineSet *StartLine = NULL;
+  // find the respective boundary point
+  PointMap::const_iterator PointRunner = PointsOnBoundary.find(Point->nr);
+  if (PointRunner != PointsOnBoundary.end()) {
+    ReferencePoint = PointRunner->second;
+  } else {
+    DoeLog(1) && (eLog() << Verbose(1) << "GetPathOfConnectedPoints() could not find the BoundaryPoint belonging to " << *Point << "." << endl);
+    return NULL;
+  }
+
+  map<class BoundaryLineSet *, bool> TouchedLine;
+  map<class BoundaryTriangleSet *, bool> TouchedTriangle;
+  map<class BoundaryLineSet *, bool>::iterator LineRunner;
+  map<class BoundaryTriangleSet *, bool>::iterator TriangleRunner;
+  for (LineMap::iterator Runner = ReferencePoint->lines.begin(); Runner != ReferencePoint->lines.end(); Runner++) {
+    TouchedLine.insert(pair<class BoundaryLineSet *, bool> (Runner->second, false));
+    for (TriangleMap::iterator Sprinter = Runner->second->triangles.begin(); Sprinter != Runner->second->triangles.end(); Sprinter++)
+      TouchedTriangle.insert(pair<class BoundaryTriangleSet *, bool> (Sprinter->second, false));
+  }
+  if (!ReferencePoint->lines.empty()) {
+    for (LineMap::iterator runner = ReferencePoint->lines.begin(); runner != ReferencePoint->lines.end(); runner++) {
+      LineRunner = TouchedLine.find(runner->second);
+      if (LineRunner == TouchedLine.end()) {
+        DoeLog(1) && (eLog() << Verbose(1) << "I could not find " << *runner->second << " in the touched list." << endl);
+      } else if (!LineRunner->second) {
+        LineRunner->second = true;
+        connectedPath = new TesselPointList;
+        triangle = NULL;
+        CurrentLine = runner->second;
+        StartLine = CurrentLine;
+        CurrentPoint = CurrentLine->GetOtherEndpoint(ReferencePoint);
+        DoLog(1) && (Log() << Verbose(1) << "INFO: Beginning path retrieval at " << *CurrentPoint << " of line " << *CurrentLine << "." << endl);
+        do {
+          // push current one
+          DoLog(1) && (Log() << Verbose(1) << "INFO: Putting " << *CurrentPoint << " at end of path." << endl);
+          connectedPath->push_back(CurrentPoint->node);
+
+          // find next triangle
+          for (TriangleMap::iterator Runner = CurrentLine->triangles.begin(); Runner != CurrentLine->triangles.end(); Runner++) {
+            DoLog(1) && (Log() << Verbose(1) << "INFO: Inspecting triangle " << *Runner->second << "." << endl);
+            if ((Runner->second != triangle)) { // look for first triangle not equal to old one
+              triangle = Runner->second;
+              TriangleRunner = TouchedTriangle.find(triangle);
+              if (TriangleRunner != TouchedTriangle.end()) {
+                if (!TriangleRunner->second) {
+                  TriangleRunner->second = true;
+                  DoLog(1) && (Log() << Verbose(1) << "INFO: Connecting triangle is " << *triangle << "." << endl);
+                  break;
+                } else {
+                  DoLog(1) && (Log() << Verbose(1) << "INFO: Skipping " << *triangle << ", as we have already visited it." << endl);
+                  triangle = NULL;
+                }
+              } else {
+                DoeLog(1) && (eLog() << Verbose(1) << "I could not find " << *triangle << " in the touched list." << endl);
+                triangle = NULL;
+              }
+            }
+          }
+          if (triangle == NULL)
+            break;
+          // find next line
+          for (int i = 0; i < 3; i++) {
+            if ((triangle->lines[i] != CurrentLine) && (triangle->lines[i]->ContainsBoundaryPoint(ReferencePoint))) { // not the current line and still containing Point
+              CurrentLine = triangle->lines[i];
+              DoLog(1) && (Log() << Verbose(1) << "INFO: Connecting line is " << *CurrentLine << "." << endl);
+              break;
+            }
+          }
+          LineRunner = TouchedLine.find(CurrentLine);
+          if (LineRunner == TouchedLine.end())
+            DoeLog(1) && (eLog() << Verbose(1) << "I could not find " << *CurrentLine << " in the touched list." << endl);
+          else
+            LineRunner->second = true;
+          // find next point
+          CurrentPoint = CurrentLine->GetOtherEndpoint(ReferencePoint);
+
+        } while (CurrentLine != StartLine);
+        // last point is missing, as it's on start line
+        DoLog(1) && (Log() << Verbose(1) << "INFO: Putting " << *CurrentPoint << " at end of path." << endl);
+        if (StartLine->GetOtherEndpoint(ReferencePoint)->node != connectedPath->back())
+          connectedPath->push_back(StartLine->GetOtherEndpoint(ReferencePoint)->node);
+
+        ListOfPaths->push_back(connectedPath);
+      } else {
+        DoLog(1) && (Log() << Verbose(1) << "INFO: Skipping " << *runner->second << ", as we have already visited it." << endl);
+      }
+    }
+  } else {
+    DoeLog(1) && (eLog() << Verbose(1) << "There are no lines attached to " << *ReferencePoint << "." << endl);
+  }
+
+  return ListOfPaths;
+}
+
+/** Gets all closed paths on the circle of points connected to the provided point by triangulation lines, if this very point is removed.
+ * From GetPathsOfConnectedPoints() extracts all single loops of intracrossing paths in the list of closed paths.
+ * @param *out output stream for debugging
+ * @param *Point of which get all connected points
+ * @return list of the closed paths
+ */
+ListOfTesselPointList * Tesselation::GetClosedPathsOfConnectedPoints(const TesselPoint* const Point) const
+{
+  Info FunctionInfo(__func__);
+  list<TesselPointList *> *ListofPaths = GetPathsOfConnectedPoints(Point);
+  list<TesselPointList *> *ListofClosedPaths = new list<TesselPointList *> ;
+  TesselPointList *connectedPath = NULL;
+  TesselPointList *newPath = NULL;
+  int count = 0;
+  TesselPointList::iterator CircleRunner;
+  TesselPointList::iterator CircleStart;
+
+  for (list<TesselPointList *>::iterator ListRunner = ListofPaths->begin(); ListRunner != ListofPaths->end(); ListRunner++) {
+    connectedPath = *ListRunner;
+
+    DoLog(1) && (Log() << Verbose(1) << "INFO: Current path is " << connectedPath << "." << endl);
+
+    // go through list, look for reappearance of starting Point and count
+    CircleStart = connectedPath->begin();
+    // go through list, look for reappearance of starting Point and create list
+    TesselPointList::iterator Marker = CircleStart;
+    for (CircleRunner = CircleStart; CircleRunner != connectedPath->end(); CircleRunner++) {
+      if ((*CircleRunner == *CircleStart) && (CircleRunner != CircleStart)) { // is not the very first point
+        // we have a closed circle from Marker to new Marker
+        DoLog(1) && (Log() << Verbose(1) << count + 1 << ". closed path consists of: ");
+        newPath = new TesselPointList;
+        TesselPointList::iterator CircleSprinter = Marker;
+        for (; CircleSprinter != CircleRunner; CircleSprinter++) {
+          newPath->push_back(*CircleSprinter);
+          DoLog(0) && (Log() << Verbose(0) << (**CircleSprinter) << " <-> ");
+        }
+        DoLog(0) && (Log() << Verbose(0) << ".." << endl);
+        count++;
+        Marker = CircleRunner;
+
+        // add to list
+        ListofClosedPaths->push_back(newPath);
+      }
+    }
+  }
+  DoLog(1) && (Log() << Verbose(1) << "INFO: " << count << " closed additional path(s) have been created." << endl);
+
+  // delete list of paths
+  while (!ListofPaths->empty()) {
+    connectedPath = *(ListofPaths->begin());
+    ListofPaths->remove(connectedPath);
+    delete (connectedPath);
+  }
+  delete (ListofPaths);
+
+  // exit
+  return ListofClosedPaths;
+}
+;
+
+/** Gets all belonging triangles for a given BoundaryPointSet.
+ * \param *out output stream for debugging
+ * \param *Point BoundaryPoint
+ * \return pointer to allocated list of triangles
+ */
+TriangleSet *Tesselation::GetAllTriangles(const BoundaryPointSet * const Point) const
+{
+  Info FunctionInfo(__func__);
+  TriangleSet *connectedTriangles = new TriangleSet;
+
+  if (Point == NULL) {
+    DoeLog(1) && (eLog() << Verbose(1) << "Point given is NULL." << endl);
+  } else {
+    // go through its lines and insert all triangles
+    for (LineMap::const_iterator LineRunner = Point->lines.begin(); LineRunner != Point->lines.end(); LineRunner++)
+      for (TriangleMap::iterator TriangleRunner = (LineRunner->second)->triangles.begin(); TriangleRunner != (LineRunner->second)->triangles.end(); TriangleRunner++) {
+        connectedTriangles->insert(TriangleRunner->second);
+      }
+  }
+
+  return connectedTriangles;
+}
+;
+
+/** Removes a boundary point from the envelope while keeping it closed.
+ * We remove the old triangles connected to the point and re-create new triangles to close the surface following this ansatz:
+ *  -# a closed path(s) of boundary points surrounding the point to be removed is constructed
+ *  -# on each closed path, we pick three adjacent points, create a triangle with them and subtract the middle point from the path
+ *  -# we advance two points (i.e. the next triangle will start at the ending point of the last triangle) and continue as before
+ *  -# the surface is closed, when the path is empty
+ * Thereby, we (hopefully) make sure that the removed points remains beneath the surface (this is checked via IsInnerPoint eventually).
+ * \param *out output stream for debugging
+ * \param *point point to be removed
+ * \return volume added to the volume inside the tesselated surface by the removal
+ */
+double Tesselation::RemovePointFromTesselatedSurface(class BoundaryPointSet *point)
+{
+  class BoundaryLineSet *line = NULL;
+  class BoundaryTriangleSet *triangle = NULL;
+  Vector OldPoint, NormalVector;
+  double volume = 0;
+  int count = 0;
+
+  if (point == NULL) {
+    DoeLog(1) && (eLog() << Verbose(1) << "Cannot remove the point " << point << ", it's NULL!" << endl);
+    return 0.;
+  } else
+    DoLog(0) && (Log() << Verbose(0) << "Removing point " << *point << " from tesselated boundary ..." << endl);
+
+  // copy old location for the volume
+  OldPoint = (*point->node->node);
+
+  // get list of connected points
+  if (point->lines.empty()) {
+    DoeLog(1) && (eLog() << Verbose(1) << "Cannot remove the point " << *point << ", it's connected to no lines!" << endl);
+    return 0.;
+  }
+
+  list<TesselPointList *> *ListOfClosedPaths = GetClosedPathsOfConnectedPoints(point->node);
+  TesselPointList *connectedPath = NULL;
+
+  // gather all triangles
+  for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++)
+    count += LineRunner->second->triangles.size();
+  TriangleMap Candidates;
+  for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++) {
+    line = LineRunner->second;
+    for (TriangleMap::iterator TriangleRunner = line->triangles.begin(); TriangleRunner != line->triangles.end(); TriangleRunner++) {
+      triangle = TriangleRunner->second;
+      Candidates.insert(TrianglePair(triangle->Nr, triangle));
+    }
+  }
+
+  // remove all triangles
+  count = 0;
+  NormalVector.Zero();
+  for (TriangleMap::iterator Runner = Candidates.begin(); Runner != Candidates.end(); Runner++) {
+    DoLog(1) && (Log() << Verbose(1) << "INFO: Removing triangle " << *(Runner->second) << "." << endl);
+    NormalVector -= Runner->second->NormalVector; // has to point inward
+    RemoveTesselationTriangle(Runner->second);
+    count++;
+  }
+  DoLog(1) && (Log() << Verbose(1) << count << " triangles were removed." << endl);
+
+  list<TesselPointList *>::iterator ListAdvance = ListOfClosedPaths->begin();
+  list<TesselPointList *>::iterator ListRunner = ListAdvance;
+  TriangleMap::iterator NumberRunner = Candidates.begin();
+  TesselPointList::iterator StartNode, MiddleNode, EndNode;
+  double angle;
+  double smallestangle;
+  Vector Point, Reference, OrthogonalVector;
+  if (count > 2) { // less than three triangles, then nothing will be created
+    class TesselPoint *TriangleCandidates[3];
+    count = 0;
+    for (; ListRunner != ListOfClosedPaths->end(); ListRunner = ListAdvance) { // go through all closed paths
+      if (ListAdvance != ListOfClosedPaths->end())
+        ListAdvance++;
+
+      connectedPath = *ListRunner;
+      // re-create all triangles by going through connected points list
+      LineList NewLines;
+      for (; !connectedPath->empty();) {
+        // search middle node with widest angle to next neighbours
+        EndNode = connectedPath->end();
+        smallestangle = 0.;
+        for (MiddleNode = connectedPath->begin(); MiddleNode != connectedPath->end(); MiddleNode++) {
+          DoLog(1) && (Log() << Verbose(1) << "INFO: MiddleNode is " << **MiddleNode << "." << endl);
+          // construct vectors to next and previous neighbour
+          StartNode = MiddleNode;
+          if (StartNode == connectedPath->begin())
+            StartNode = connectedPath->end();
+          StartNode--;
+          //Log() << Verbose(3) << "INFO: StartNode is " << **StartNode << "." << endl;
+          Point = (*(*StartNode)->node) - (*(*MiddleNode)->node);
+          StartNode = MiddleNode;
+          StartNode++;
+          if (StartNode == connectedPath->end())
+            StartNode = connectedPath->begin();
+          //Log() << Verbose(3) << "INFO: EndNode is " << **StartNode << "." << endl;
+          Reference = (*(*StartNode)->node) - (*(*MiddleNode)->node);
+          OrthogonalVector = (*(*MiddleNode)->node) - OldPoint;
+          OrthogonalVector.MakeNormalTo(Reference);
+          angle = GetAngle(Point, Reference, OrthogonalVector);
+          //if (angle < M_PI)  // no wrong-sided triangles, please?
+          if (fabs(angle - M_PI) < fabs(smallestangle - M_PI)) { // get straightest angle (i.e. construct those triangles with smallest area first)
+            smallestangle = angle;
+            EndNode = MiddleNode;
+          }
+        }
+        MiddleNode = EndNode;
+        if (MiddleNode == connectedPath->end()) {
+          DoeLog(0) && (eLog() << Verbose(0) << "CRITICAL: Could not find a smallest angle!" << endl);
+          performCriticalExit();
+        }
+        StartNode = MiddleNode;
+        if (StartNode == connectedPath->begin())
+          StartNode = connectedPath->end();
+        StartNode--;
+        EndNode++;
+        if (EndNode == connectedPath->end())
+          EndNode = connectedPath->begin();
+        DoLog(2) && (Log() << Verbose(2) << "INFO: StartNode is " << **StartNode << "." << endl);
+        DoLog(2) && (Log() << Verbose(2) << "INFO: MiddleNode is " << **MiddleNode << "." << endl);
+        DoLog(2) && (Log() << Verbose(2) << "INFO: EndNode is " << **EndNode << "." << endl);
+        DoLog(1) && (Log() << Verbose(1) << "INFO: Attempting to create triangle " << (*StartNode)->getName() << ", " << (*MiddleNode)->getName() << " and " << (*EndNode)->getName() << "." << endl);
+        TriangleCandidates[0] = *StartNode;
+        TriangleCandidates[1] = *MiddleNode;
+        TriangleCandidates[2] = *EndNode;
+        triangle = GetPresentTriangle(TriangleCandidates);
+        if (triangle != NULL) {
+          DoeLog(0) && (eLog() << Verbose(0) << "New triangle already present, skipping!" << endl);
+          StartNode++;
+          MiddleNode++;
+          EndNode++;
+          if (StartNode == connectedPath->end())
+            StartNode = connectedPath->begin();
+          if (MiddleNode == connectedPath->end())
+            MiddleNode = connectedPath->begin();
+          if (EndNode == connectedPath->end())
+            EndNode = connectedPath->begin();
+          continue;
+        }
+        DoLog(3) && (Log() << Verbose(3) << "Adding new triangle points." << endl);
+        AddTesselationPoint(*StartNode, 0);
+        AddTesselationPoint(*MiddleNode, 1);
+        AddTesselationPoint(*EndNode, 2);
+        DoLog(3) && (Log() << Verbose(3) << "Adding new triangle lines." << endl);
+        AddTesselationLine(NULL, NULL, TPS[0], TPS[1], 0);
+        AddTesselationLine(NULL, NULL, TPS[0], TPS[2], 1);
+        NewLines.push_back(BLS[1]);
+        AddTesselationLine(NULL, NULL, TPS[1], TPS[2], 2);
+        BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
+        BTS->GetNormalVector(NormalVector);
+        AddTesselationTriangle();
+        // calculate volume summand as a general tetraeder
+        volume += CalculateVolumeofGeneralTetraeder(*TPS[0]->node->node, *TPS[1]->node->node, *TPS[2]->node->node, OldPoint);
+        // advance number
+        count++;
+
+        // prepare nodes for next triangle
+        StartNode = EndNode;
+        DoLog(2) && (Log() << Verbose(2) << "Removing " << **MiddleNode << " from closed path, remaining points: " << connectedPath->size() << "." << endl);
+        connectedPath->remove(*MiddleNode); // remove the middle node (it is surrounded by triangles)
+        if (connectedPath->size() == 2) { // we are done
+          connectedPath->remove(*StartNode); // remove the start node
+          connectedPath->remove(*EndNode); // remove the end node
+          break;
+        } else if (connectedPath->size() < 2) { // something's gone wrong!
+          DoeLog(0) && (eLog() << Verbose(0) << "CRITICAL: There are only two endpoints left!" << endl);
+          performCriticalExit();
+        } else {
+          MiddleNode = StartNode;
+          MiddleNode++;
+          if (MiddleNode == connectedPath->end())
+            MiddleNode = connectedPath->begin();
+          EndNode = MiddleNode;
+          EndNode++;
+          if (EndNode == connectedPath->end())
+            EndNode = connectedPath->begin();
+        }
+      }
+      // maximize the inner lines (we preferentially created lines with a huge angle, which is for the tesselation not wanted though useful for the closing)
+      if (NewLines.size() > 1) {
+        LineList::iterator Candidate;
+        class BoundaryLineSet *OtherBase = NULL;
+        double tmp, maxgain;
+        do {
+          maxgain = 0;
+          for (LineList::iterator Runner = NewLines.begin(); Runner != NewLines.end(); Runner++) {
+            tmp = PickFarthestofTwoBaselines(*Runner);
+            if (maxgain < tmp) {
+              maxgain = tmp;
+              Candidate = Runner;
+            }
+          }
+          if (maxgain != 0) {
+            volume += maxgain;
+            DoLog(1) && (Log() << Verbose(1) << "Flipping baseline with highest volume" << **Candidate << "." << endl);
+            OtherBase = FlipBaseline(*Candidate);
+            NewLines.erase(Candidate);
+            NewLines.push_back(OtherBase);
+          }
+        } while (maxgain != 0.);
+      }
+
+      ListOfClosedPaths->remove(connectedPath);
+      delete (connectedPath);
+    }
+    DoLog(0) && (Log() << Verbose(0) << count << " triangles were created." << endl);
+  } else {
+    while (!ListOfClosedPaths->empty()) {
+      ListRunner = ListOfClosedPaths->begin();
+      connectedPath = *ListRunner;
+      ListOfClosedPaths->remove(connectedPath);
+      delete (connectedPath);
+    }
+    DoLog(0) && (Log() << Verbose(0) << "No need to create any triangles." << endl);
+  }
+  delete (ListOfClosedPaths);
+
+  DoLog(0) && (Log() << Verbose(0) << "Removed volume is " << volume << "." << endl);
+
+  return volume;
+}
+;
+
+/**
+ * Finds triangles belonging to the three provided points.
+ *
+ * @param *Points[3] list, is expected to contain three points (NULL means wildcard)
+ *
+ * @return triangles which belong to the provided points, will be empty if there are none,
+ *         will usually be one, in case of degeneration, there will be two
+ */
+TriangleList *Tesselation::FindTriangles(const TesselPoint* const Points[3]) const
+{
+  Info FunctionInfo(__func__);
+  TriangleList *result = new TriangleList;
+  LineMap::const_iterator FindLine;
+  TriangleMap::const_iterator FindTriangle;
+  class BoundaryPointSet *TrianglePoints[3];
+  size_t NoOfWildcards = 0;
+
+  for (int i = 0; i < 3; i++) {
+    if (Points[i] == NULL) {
+      NoOfWildcards++;
+      TrianglePoints[i] = NULL;
+    } else {
+      PointMap::const_iterator FindPoint = PointsOnBoundary.find(Points[i]->nr);
+      if (FindPoint != PointsOnBoundary.end()) {
+        TrianglePoints[i] = FindPoint->second;
+      } else {
+        TrianglePoints[i] = NULL;
+      }
+    }
+  }
+
+  switch (NoOfWildcards) {
+    case 0: // checks lines between the points in the Points for their adjacent triangles
+      for (int i = 0; i < 3; i++) {
+        if (TrianglePoints[i] != NULL) {
+          for (int j = i + 1; j < 3; j++) {
+            if (TrianglePoints[j] != NULL) {
+              for (FindLine = TrianglePoints[i]->lines.find(TrianglePoints[j]->node->nr); // is a multimap!
+              (FindLine != TrianglePoints[i]->lines.end()) && (FindLine->first == TrianglePoints[j]->node->nr); FindLine++) {
+                for (FindTriangle = FindLine->second->triangles.begin(); FindTriangle != FindLine->second->triangles.end(); FindTriangle++) {
+                  if (FindTriangle->second->IsPresentTupel(TrianglePoints)) {
+                    result->push_back(FindTriangle->second);
+                  }
+                }
+              }
+              // Is it sufficient to consider one of the triangle lines for this.
+              return result;
+            }
+          }
+        }
+      }
+      break;
+    case 1: // copy all triangles of the respective line
+    {
+      int i = 0;
+      for (; i < 3; i++)
+        if (TrianglePoints[i] == NULL)
+          break;
+      for (FindLine = TrianglePoints[(i + 1) % 3]->lines.find(TrianglePoints[(i + 2) % 3]->node->nr); // is a multimap!
+      (FindLine != TrianglePoints[(i + 1) % 3]->lines.end()) && (FindLine->first == TrianglePoints[(i + 2) % 3]->node->nr); FindLine++) {
+        for (FindTriangle = FindLine->second->triangles.begin(); FindTriangle != FindLine->second->triangles.end(); FindTriangle++) {
+          if (FindTriangle->second->IsPresentTupel(TrianglePoints)) {
+            result->push_back(FindTriangle->second);
+          }
+        }
+      }
+      break;
+    }
+    case 2: // copy all triangles of the respective point
+    {
+      int i = 0;
+      for (; i < 3; i++)
+        if (TrianglePoints[i] != NULL)
+          break;
+      for (LineMap::const_iterator line = TrianglePoints[i]->lines.begin(); line != TrianglePoints[i]->lines.end(); line++)
+        for (TriangleMap::const_iterator triangle = line->second->triangles.begin(); triangle != line->second->triangles.end(); triangle++)
+          result->push_back(triangle->second);
+      result->sort();
+      result->unique();
+      break;
+    }
+    case 3: // copy all triangles
+    {
+      for (TriangleMap::const_iterator triangle = TrianglesOnBoundary.begin(); triangle != TrianglesOnBoundary.end(); triangle++)
+        result->push_back(triangle->second);
+      break;
+    }
+    default:
+      DoeLog(0) && (eLog() << Verbose(0) << "Number of wildcards is greater than 3, cannot happen!" << endl);
+      performCriticalExit();
+      break;
+  }
+
+  return result;
+}
+
+struct BoundaryLineSetCompare
+{
+  bool operator()(const BoundaryLineSet * const a, const BoundaryLineSet * const b)
+  {
+    int lowerNra = -1;
+    int lowerNrb = -1;
+
+    if (a->endpoints[0] < a->endpoints[1])
+      lowerNra = 0;
+    else
+      lowerNra = 1;
+
+    if (b->endpoints[0] < b->endpoints[1])
+      lowerNrb = 0;
+    else
+      lowerNrb = 1;
+
+    if (a->endpoints[lowerNra] < b->endpoints[lowerNrb])
+      return true;
+    else if (a->endpoints[lowerNra] > b->endpoints[lowerNrb])
+      return false;
+    else { // both lower-numbered endpoints are the same ...
+      if (a->endpoints[(lowerNra + 1) % 2] < b->endpoints[(lowerNrb + 1) % 2])
+        return true;
+      else if (a->endpoints[(lowerNra + 1) % 2] > b->endpoints[(lowerNrb + 1) % 2])
+        return false;
+    }
+    return false;
+  }
+  ;
+};
+
+#define UniqueLines set < class BoundaryLineSet *, BoundaryLineSetCompare>
+
+/**
+ * Finds all degenerated lines within the tesselation structure.
+ *
+ * @return map of keys of degenerated line pairs, each line occurs twice
+ *         in the list, once as key and once as value
+ */
+IndexToIndex * Tesselation::FindAllDegeneratedLines()
+{
+  Info FunctionInfo(__func__);
+  UniqueLines AllLines;
+  IndexToIndex * DegeneratedLines = new IndexToIndex;
+
+  // sanity check
+  if (LinesOnBoundary.empty()) {
+    DoeLog(2) && (eLog() << Verbose(2) << "FindAllDegeneratedTriangles() was called without any tesselation structure.");
+    return DegeneratedLines;
+  }
+  LineMap::iterator LineRunner1;
+  pair<UniqueLines::iterator, bool> tester;
+  for (LineRunner1 = LinesOnBoundary.begin(); LineRunner1 != LinesOnBoundary.end(); ++LineRunner1) {
+    tester = AllLines.insert(LineRunner1->second);
+    if (!tester.second) { // found degenerated line
+      DegeneratedLines->insert(pair<int, int> (LineRunner1->second->Nr, (*tester.first)->Nr));
+      DegeneratedLines->insert(pair<int, int> ((*tester.first)->Nr, LineRunner1->second->Nr));
+    }
+  }
+
+  AllLines.clear();
+
+  DoLog(0) && (Log() << Verbose(0) << "FindAllDegeneratedLines() found " << DegeneratedLines->size() << " lines." << endl);
+  IndexToIndex::iterator it;
+  for (it = DegeneratedLines->begin(); it != DegeneratedLines->end(); it++) {
+    const LineMap::const_iterator Line1 = LinesOnBoundary.find((*it).first);
+    const LineMap::const_iterator Line2 = LinesOnBoundary.find((*it).second);
+    if (Line1 != LinesOnBoundary.end() && Line2 != LinesOnBoundary.end())
+      DoLog(0) && (Log() << Verbose(0) << *Line1->second << " => " << *Line2->second << endl);
+    else
+      DoeLog(1) && (eLog() << Verbose(1) << "Either " << (*it).first << " or " << (*it).second << " are not in LinesOnBoundary!" << endl);
+  }
+
+  return DegeneratedLines;
+}
+
+/**
+ * Finds all degenerated triangles within the tesselation structure.
+ *
+ * @return map of keys of degenerated triangle pairs, each triangle occurs twice
+ *         in the list, once as key and once as value
+ */
+IndexToIndex * Tesselation::FindAllDegeneratedTriangles()
+{
+  Info FunctionInfo(__func__);
+  IndexToIndex * DegeneratedLines = FindAllDegeneratedLines();
+  IndexToIndex * DegeneratedTriangles = new IndexToIndex;
+  TriangleMap::iterator TriangleRunner1, TriangleRunner2;
+  LineMap::iterator Liner;
+  class BoundaryLineSet *line1 = NULL, *line2 = NULL;
+
+  for (IndexToIndex::iterator LineRunner = DegeneratedLines->begin(); LineRunner != DegeneratedLines->end(); ++LineRunner) {
+    // run over both lines' triangles
+    Liner = LinesOnBoundary.find(LineRunner->first);
+    if (Liner != LinesOnBoundary.end())
+      line1 = Liner->second;
+    Liner = LinesOnBoundary.find(LineRunner->second);
+    if (Liner != LinesOnBoundary.end())
+      line2 = Liner->second;
+    for (TriangleRunner1 = line1->triangles.begin(); TriangleRunner1 != line1->triangles.end(); ++TriangleRunner1) {
+      for (TriangleRunner2 = line2->triangles.begin(); TriangleRunner2 != line2->triangles.end(); ++TriangleRunner2) {
+        if ((TriangleRunner1->second != TriangleRunner2->second) && (TriangleRunner1->second->IsPresentTupel(TriangleRunner2->second))) {
+          DegeneratedTriangles->insert(pair<int, int> (TriangleRunner1->second->Nr, TriangleRunner2->second->Nr));
+          DegeneratedTriangles->insert(pair<int, int> (TriangleRunner2->second->Nr, TriangleRunner1->second->Nr));
+        }
+      }
+    }
+  }
+  delete (DegeneratedLines);
+
+  DoLog(0) && (Log() << Verbose(0) << "FindAllDegeneratedTriangles() found " << DegeneratedTriangles->size() << " triangles:" << endl);
+  for (IndexToIndex::iterator it = DegeneratedTriangles->begin(); it != DegeneratedTriangles->end(); it++)
+    DoLog(0) && (Log() << Verbose(0) << (*it).first << " => " << (*it).second << endl);
+
+  return DegeneratedTriangles;
+}
+
+/**
+ * Purges degenerated triangles from the tesselation structure if they are not
+ * necessary to keep a single point within the structure.
+ */
+void Tesselation::RemoveDegeneratedTriangles()
+{
+  Info FunctionInfo(__func__);
+  IndexToIndex * DegeneratedTriangles = FindAllDegeneratedTriangles();
+  TriangleMap::iterator finder;
+  BoundaryTriangleSet *triangle = NULL, *partnerTriangle = NULL;
+  int count = 0;
+
+  // iterate over all degenerated triangles
+  for (IndexToIndex::iterator TriangleKeyRunner = DegeneratedTriangles->begin(); !DegeneratedTriangles->empty(); TriangleKeyRunner = DegeneratedTriangles->begin()) {
+    DoLog(0) && (Log() << Verbose(0) << "Checking presence of triangles " << TriangleKeyRunner->first << " and " << TriangleKeyRunner->second << "." << endl);
+    // both ways are stored in the map, only use one
+    if (TriangleKeyRunner->first > TriangleKeyRunner->second)
+      continue;
+
+    // determine from the keys in the map the two _present_ triangles
+    finder = TrianglesOnBoundary.find(TriangleKeyRunner->first);
+    if (finder != TrianglesOnBoundary.end())
+      triangle = finder->second;
+    else
+      continue;
+    finder = TrianglesOnBoundary.find(TriangleKeyRunner->second);
+    if (finder != TrianglesOnBoundary.end())
+      partnerTriangle = finder->second;
+    else
+      continue;
+
+    // determine which lines are shared by the two triangles
+    bool trianglesShareLine = false;
+    for (int i = 0; i < 3; ++i)
+      for (int j = 0; j < 3; ++j)
+        trianglesShareLine = trianglesShareLine || triangle->lines[i] == partnerTriangle->lines[j];
+
+    if (trianglesShareLine && (triangle->endpoints[1]->LinesCount > 2) && (triangle->endpoints[2]->LinesCount > 2) && (triangle->endpoints[0]->LinesCount > 2)) {
+      // check whether we have to fix lines
+      BoundaryTriangleSet *Othertriangle = NULL;
+      BoundaryTriangleSet *OtherpartnerTriangle = NULL;
+      TriangleMap::iterator TriangleRunner;
+      for (int i = 0; i < 3; ++i)
+        for (int j = 0; j < 3; ++j)
+          if (triangle->lines[i] != partnerTriangle->lines[j]) {
+            // get the other two triangles
+            for (TriangleRunner = triangle->lines[i]->triangles.begin(); TriangleRunner != triangle->lines[i]->triangles.end(); ++TriangleRunner)
+              if (TriangleRunner->second != triangle) {
+                Othertriangle = TriangleRunner->second;
+              }
+            for (TriangleRunner = partnerTriangle->lines[i]->triangles.begin(); TriangleRunner != partnerTriangle->lines[i]->triangles.end(); ++TriangleRunner)
+              if (TriangleRunner->second != partnerTriangle) {
+                OtherpartnerTriangle = TriangleRunner->second;
+              }
+            /// interchanges their lines so that triangle->lines[i] == partnerTriangle->lines[j]
+            // the line of triangle receives the degenerated ones
+            triangle->lines[i]->triangles.erase(Othertriangle->Nr);
+            triangle->lines[i]->triangles.insert(TrianglePair(partnerTriangle->Nr, partnerTriangle));
+            for (int k = 0; k < 3; k++)
+              if (triangle->lines[i] == Othertriangle->lines[k]) {
+                Othertriangle->lines[k] = partnerTriangle->lines[j];
+                break;
+              }
+            // the line of partnerTriangle receives the non-degenerated ones
+            partnerTriangle->lines[j]->triangles.erase(partnerTriangle->Nr);
+            partnerTriangle->lines[j]->triangles.insert(TrianglePair(Othertriangle->Nr, Othertriangle));
+            partnerTriangle->lines[j] = triangle->lines[i];
+          }
+
+      // erase the pair
+      count += (int) DegeneratedTriangles->erase(triangle->Nr);
+      DoLog(0) && (Log() << Verbose(0) << "RemoveDegeneratedTriangles() removes triangle " << *triangle << "." << endl);
+      RemoveTesselationTriangle(triangle);
+      count += (int) DegeneratedTriangles->erase(partnerTriangle->Nr);
+      DoLog(0) && (Log() << Verbose(0) << "RemoveDegeneratedTriangles() removes triangle " << *partnerTriangle << "." << endl);
+      RemoveTesselationTriangle(partnerTriangle);
+    } else {
+      DoLog(0) && (Log() << Verbose(0) << "RemoveDegeneratedTriangles() does not remove triangle " << *triangle << " and its partner " << *partnerTriangle << " because it is essential for at" << " least one of the endpoints to be kept in the tesselation structure." << endl);
+    }
+  }
+  delete (DegeneratedTriangles);
+  if (count > 0)
+    LastTriangle = NULL;
+
+  DoLog(0) && (Log() << Verbose(0) << "RemoveDegeneratedTriangles() removed " << count << " triangles:" << endl);
+}
+
+/** Adds an outside Tesselpoint to the envelope via (two) degenerated triangles.
+ * We look for the closest point on the boundary, we look through its connected boundary lines and
+ * seek the one with the minimum angle between its center point and the new point and this base line.
+ * We open up the line by adding a degenerated triangle, whose other side closes the base line again.
+ * \param *out output stream for debugging
+ * \param *point point to add
+ * \param *LC Linked Cell structure to find nearest point
+ */
+void Tesselation::AddBoundaryPointByDegeneratedTriangle(class TesselPoint *point, LinkedCell *LC)
+{
+  Info FunctionInfo(__func__);
+  // find nearest boundary point
+  class TesselPoint *BackupPoint = NULL;
+  class TesselPoint *NearestPoint = FindClosestTesselPoint(point->node, BackupPoint, LC);
+  class BoundaryPointSet *NearestBoundaryPoint = NULL;
+  PointMap::iterator PointRunner;
+
+  if (NearestPoint == point)
+    NearestPoint = BackupPoint;
+  PointRunner = PointsOnBoundary.find(NearestPoint->nr);
+  if (PointRunner != PointsOnBoundary.end()) {
+    NearestBoundaryPoint = PointRunner->second;
+  } else {
+    DoeLog(1) && (eLog() << Verbose(1) << "I cannot find the boundary point." << endl);
+    return;
+  }
+  DoLog(0) && (Log() << Verbose(0) << "Nearest point on boundary is " << NearestPoint->getName() << "." << endl);
+
+  // go through its lines and find the best one to split
+  Vector CenterToPoint;
+  Vector BaseLine;
+  double angle, BestAngle = 0.;
+  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);
+    angle = CenterToPoint.Angle(BaseLine);
+    if (fabs(angle - M_PI/2.) < fabs(BestAngle - M_PI/2.)) {
+      BestAngle = angle;
+      BestLine = Runner->second;
+    }
+  }
+
+  // remove one triangle from the chosen line
+  class BoundaryTriangleSet *TempTriangle = (BestLine->triangles.begin())->second;
+  BestLine->triangles.erase(TempTriangle->Nr);
+  int nr = -1;
+  for (int i = 0; i < 3; i++) {
+    if (TempTriangle->lines[i] == BestLine) {
+      nr = i;
+      break;
+    }
+  }
+
+  // create new triangle to connect point (connects automatically with the missing spot of the chosen line)
+  DoLog(2) && (Log() << Verbose(2) << "Adding new triangle points." << endl);
+  AddTesselationPoint((BestLine->endpoints[0]->node), 0);
+  AddTesselationPoint((BestLine->endpoints[1]->node), 1);
+  AddTesselationPoint(point, 2);
+  DoLog(2) && (Log() << Verbose(2) << "Adding new triangle lines." << endl);
+  AddTesselationLine(NULL, NULL, TPS[0], TPS[1], 0);
+  AddTesselationLine(NULL, NULL, TPS[0], TPS[2], 1);
+  AddTesselationLine(NULL, NULL, TPS[1], TPS[2], 2);
+  BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
+  BTS->GetNormalVector(TempTriangle->NormalVector);
+  BTS->NormalVector.Scale(-1.);
+  DoLog(1) && (Log() << Verbose(1) << "INFO: NormalVector of new triangle is " << BTS->NormalVector << "." << endl);
+  AddTesselationTriangle();
+
+  // create other side of this triangle and close both new sides of the first created triangle
+  DoLog(2) && (Log() << Verbose(2) << "Adding new triangle points." << endl);
+  AddTesselationPoint((BestLine->endpoints[0]->node), 0);
+  AddTesselationPoint((BestLine->endpoints[1]->node), 1);
+  AddTesselationPoint(point, 2);
+  DoLog(2) && (Log() << Verbose(2) << "Adding new triangle lines." << endl);
+  AddTesselationLine(NULL, NULL, TPS[0], TPS[1], 0);
+  AddTesselationLine(NULL, NULL, TPS[0], TPS[2], 1);
+  AddTesselationLine(NULL, NULL, TPS[1], TPS[2], 2);
+  BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
+  BTS->GetNormalVector(TempTriangle->NormalVector);
+  DoLog(1) && (Log() << Verbose(1) << "INFO: NormalVector of other new triangle is " << BTS->NormalVector << "." << endl);
+  AddTesselationTriangle();
+
+  // add removed triangle to the last open line of the second triangle
+  for (int i = 0; i < 3; i++) { // look for the same line as BestLine (only it's its degenerated companion)
+    if ((BTS->lines[i]->ContainsBoundaryPoint(BestLine->endpoints[0])) && (BTS->lines[i]->ContainsBoundaryPoint(BestLine->endpoints[1]))) {
+      if (BestLine == BTS->lines[i]) {
+        DoeLog(0) && (eLog() << Verbose(0) << "BestLine is same as found line, something's wrong here!" << endl);
+        performCriticalExit();
+      }
+      BTS->lines[i]->triangles.insert(pair<int, class BoundaryTriangleSet *> (TempTriangle->Nr, TempTriangle));
+      TempTriangle->lines[nr] = BTS->lines[i];
+      break;
+    }
+  }
+}
+;
+
+/** Writes the envelope to file.
+ * \param *out otuput stream for debugging
+ * \param *filename basename of output file
+ * \param *cloud PointCloud structure with all nodes
+ */
+void Tesselation::Output(const char *filename, const PointCloud * const cloud)
+{
+  Info FunctionInfo(__func__);
+  ofstream *tempstream = NULL;
+  string NameofTempFile;
+  string NumberName;
+
+  if (LastTriangle != NULL) {
+    stringstream sstr;
+    sstr << "-"<< TrianglesOnBoundary.size() << "-" << LastTriangle->getEndpointName(0) << "_" << LastTriangle->getEndpointName(1) << "_" << LastTriangle->getEndpointName(2);
+    NumberName = sstr.str();
+    if (DoTecplotOutput) {
+      string NameofTempFile(filename);
+      NameofTempFile.append(NumberName);
+      for (size_t npos = NameofTempFile.find_first_of(' '); npos != string::npos; npos = NameofTempFile.find(' ', npos))
+        NameofTempFile.erase(npos, 1);
+      NameofTempFile.append(TecplotSuffix);
+      DoLog(0) && (Log() << Verbose(0) << "Writing temporary non convex hull to file " << NameofTempFile << ".\n");
+      tempstream = new ofstream(NameofTempFile.c_str(), ios::trunc);
+      WriteTecplotFile(tempstream, this, cloud, TriangleFilesWritten);
+      tempstream->close();
+      tempstream->flush();
+      delete (tempstream);
+    }
+
+    if (DoRaster3DOutput) {
+      string NameofTempFile(filename);
+      NameofTempFile.append(NumberName);
+      for (size_t npos = NameofTempFile.find_first_of(' '); npos != string::npos; npos = NameofTempFile.find(' ', npos))
+        NameofTempFile.erase(npos, 1);
+      NameofTempFile.append(Raster3DSuffix);
+      DoLog(0) && (Log() << Verbose(0) << "Writing temporary non convex hull to file " << NameofTempFile << ".\n");
+      tempstream = new ofstream(NameofTempFile.c_str(), ios::trunc);
+      WriteRaster3dFile(tempstream, this, cloud);
+      IncludeSphereinRaster3D(tempstream, this, cloud);
+      tempstream->close();
+      tempstream->flush();
+      delete (tempstream);
+    }
+  }
+  if (DoTecplotOutput || DoRaster3DOutput)
+    TriangleFilesWritten++;
+}
+;
+
+struct BoundaryPolygonSetCompare
+{
+  bool operator()(const BoundaryPolygonSet * s1, const BoundaryPolygonSet * s2) const
+  {
+    if (s1->endpoints.size() < s2->endpoints.size())
+      return true;
+    else if (s1->endpoints.size() > s2->endpoints.size())
+      return false;
+    else { // equality of number of endpoints
+      PointSet::const_iterator Walker1 = s1->endpoints.begin();
+      PointSet::const_iterator Walker2 = s2->endpoints.begin();
+      while ((Walker1 != s1->endpoints.end()) || (Walker2 != s2->endpoints.end())) {
+        if ((*Walker1)->Nr < (*Walker2)->Nr)
+          return true;
+        else if ((*Walker1)->Nr > (*Walker2)->Nr)
+          return false;
+        Walker1++;
+        Walker2++;
+      }
+      return false;
+    }
+  }
+};
+
+#define UniquePolygonSet set < BoundaryPolygonSet *, BoundaryPolygonSetCompare>
+
+/** Finds all degenerated polygons and calls ReTesselateDegeneratedPolygon()/
+ * \return number of polygons found
+ */
+int Tesselation::CorrectAllDegeneratedPolygons()
+{
+  Info FunctionInfo(__func__);
+  /// 2. Go through all BoundaryPointSet's, check their triangles' NormalVector
+  IndexToIndex *DegeneratedTriangles = FindAllDegeneratedTriangles();
+  set<BoundaryPointSet *> EndpointCandidateList;
+  pair<set<BoundaryPointSet *>::iterator, bool> InsertionTester;
+  pair<map<int, Vector *>::iterator, bool> TriangleInsertionTester;
+  for (PointMap::const_iterator Runner = PointsOnBoundary.begin(); Runner != PointsOnBoundary.end(); Runner++) {
+    DoLog(0) && (Log() << Verbose(0) << "Current point is " << *Runner->second << "." << endl);
+    map<int, Vector *> TriangleVectors;
+    // gather all NormalVectors
+    DoLog(1) && (Log() << Verbose(1) << "Gathering triangles ..." << endl);
+    for (LineMap::const_iterator LineRunner = (Runner->second)->lines.begin(); LineRunner != (Runner->second)->lines.end(); LineRunner++)
+      for (TriangleMap::const_iterator TriangleRunner = (LineRunner->second)->triangles.begin(); TriangleRunner != (LineRunner->second)->triangles.end(); TriangleRunner++) {
+        if (DegeneratedTriangles->find(TriangleRunner->second->Nr) == DegeneratedTriangles->end()) {
+          TriangleInsertionTester = TriangleVectors.insert(pair<int, Vector *> ((TriangleRunner->second)->Nr, &((TriangleRunner->second)->NormalVector)));
+          if (TriangleInsertionTester.second)
+            DoLog(1) && (Log() << Verbose(1) << " Adding triangle " << *(TriangleRunner->second) << " to triangles to check-list." << endl);
+        } else {
+          DoLog(1) && (Log() << Verbose(1) << " NOT adding triangle " << *(TriangleRunner->second) << " as it's a simply degenerated one." << endl);
+        }
+      }
+    // check whether there are two that are parallel
+    DoLog(1) && (Log() << Verbose(1) << "Finding two parallel triangles ..." << endl);
+    for (map<int, Vector *>::iterator VectorWalker = TriangleVectors.begin(); VectorWalker != TriangleVectors.end(); VectorWalker++)
+      for (map<int, Vector *>::iterator VectorRunner = VectorWalker; VectorRunner != TriangleVectors.end(); VectorRunner++)
+        if (VectorWalker != VectorRunner) { // skip equals
+          const double SCP = VectorWalker->second->ScalarProduct(*VectorRunner->second); // ScalarProduct should result in -1. for degenerated triangles
+          DoLog(1) && (Log() << Verbose(1) << "Checking " << *VectorWalker->second << " against " << *VectorRunner->second << ": " << SCP << endl);
+          if (fabs(SCP + 1.) < ParallelEpsilon) {
+            InsertionTester = EndpointCandidateList.insert((Runner->second));
+            if (InsertionTester.second)
+              DoLog(0) && (Log() << Verbose(0) << " Adding " << *Runner->second << " to endpoint candidate list." << endl);
+            // and break out of both loops
+            VectorWalker = TriangleVectors.end();
+            VectorRunner = TriangleVectors.end();
+            break;
+          }
+        }
+  }
+  delete DegeneratedTriangles;
+
+  /// 3. Find connected endpoint candidates and put them into a polygon
+  UniquePolygonSet ListofDegeneratedPolygons;
+  BoundaryPointSet *Walker = NULL;
+  BoundaryPointSet *OtherWalker = NULL;
+  BoundaryPolygonSet *Current = NULL;
+  stack<BoundaryPointSet*> ToCheckConnecteds;
+  while (!EndpointCandidateList.empty()) {
+    Walker = *(EndpointCandidateList.begin());
+    if (Current == NULL) { // create a new polygon with current candidate
+      DoLog(0) && (Log() << Verbose(0) << "Starting new polygon set at point " << *Walker << endl);
+      Current = new BoundaryPolygonSet;
+      Current->endpoints.insert(Walker);
+      EndpointCandidateList.erase(Walker);
+      ToCheckConnecteds.push(Walker);
+    }
+
+    // go through to-check stack
+    while (!ToCheckConnecteds.empty()) {
+      Walker = ToCheckConnecteds.top(); // fetch ...
+      ToCheckConnecteds.pop(); // ... and remove
+      for (LineMap::const_iterator LineWalker = Walker->lines.begin(); LineWalker != Walker->lines.end(); LineWalker++) {
+        OtherWalker = (LineWalker->second)->GetOtherEndpoint(Walker);
+        DoLog(1) && (Log() << Verbose(1) << "Checking " << *OtherWalker << endl);
+        set<BoundaryPointSet *>::iterator Finder = EndpointCandidateList.find(OtherWalker);
+        if (Finder != EndpointCandidateList.end()) { // found a connected partner
+          DoLog(1) && (Log() << Verbose(1) << " Adding to polygon." << endl);
+          Current->endpoints.insert(OtherWalker);
+          EndpointCandidateList.erase(Finder); // remove from candidates
+          ToCheckConnecteds.push(OtherWalker); // but check its partners too
+        } else {
+          DoLog(1) && (Log() << Verbose(1) << " is not connected to " << *Walker << endl);
+        }
+      }
+    }
+
+    DoLog(0) && (Log() << Verbose(0) << "Final polygon is " << *Current << endl);
+    ListofDegeneratedPolygons.insert(Current);
+    Current = NULL;
+  }
+
+  const int counter = ListofDegeneratedPolygons.size();
+
+  DoLog(0) && (Log() << Verbose(0) << "The following " << counter << " degenerated polygons have been found: " << endl);
+  for (UniquePolygonSet::iterator PolygonRunner = ListofDegeneratedPolygons.begin(); PolygonRunner != ListofDegeneratedPolygons.end(); PolygonRunner++)
+    DoLog(0) && (Log() << Verbose(0) << " " << **PolygonRunner << endl);
+
+  /// 4. Go through all these degenerated polygons
+  for (UniquePolygonSet::iterator PolygonRunner = ListofDegeneratedPolygons.begin(); PolygonRunner != ListofDegeneratedPolygons.end(); PolygonRunner++) {
+    stack<int> TriangleNrs;
+    Vector NormalVector;
+    /// 4a. Gather all triangles of this polygon
+    TriangleSet *T = (*PolygonRunner)->GetAllContainedTrianglesFromEndpoints();
+
+    // check whether number is bigger than 2, otherwise it's just a simply degenerated one and nothing to do.
+    if (T->size() == 2) {
+      DoLog(1) && (Log() << Verbose(1) << " Skipping degenerated polygon, is just a (already simply degenerated) triangle." << endl);
+      delete (T);
+      continue;
+    }
+
+    // check whether number is even
+    // If this case occurs, we have to think about it!
+    // The Problem is probably due to two degenerated polygons being connected by a bridging, non-degenerated polygon, as somehow one node has
+    // connections to either polygon ...
+    if (T->size() % 2 != 0) {
+      DoeLog(0) && (eLog() << Verbose(0) << " degenerated polygon contains an odd number of triangles, probably contains bridging non-degenerated ones, too!" << endl);
+      performCriticalExit();
+    }
+    TriangleSet::iterator TriangleWalker = T->begin(); // is the inner iterator
+    /// 4a. Get NormalVector for one side (this is "front")
+    NormalVector = (*TriangleWalker)->NormalVector;
+    DoLog(1) && (Log() << Verbose(1) << "\"front\" defining triangle is " << **TriangleWalker << " and Normal vector of \"front\" side is " << NormalVector << endl);
+    TriangleWalker++;
+    TriangleSet::iterator TriangleSprinter = TriangleWalker; // is the inner advanced iterator
+    /// 4b. Remove all triangles whose NormalVector is in opposite direction (i.e. "back")
+    BoundaryTriangleSet *triangle = NULL;
+    while (TriangleSprinter != T->end()) {
+      TriangleWalker = TriangleSprinter;
+      triangle = *TriangleWalker;
+      TriangleSprinter++;
+      DoLog(1) && (Log() << Verbose(1) << "Current triangle to test for removal: " << *triangle << endl);
+      if (triangle->NormalVector.ScalarProduct(NormalVector) < 0) { // if from other side, then delete and remove from list
+        DoLog(1) && (Log() << Verbose(1) << " Removing ... " << endl);
+        TriangleNrs.push(triangle->Nr);
+        T->erase(TriangleWalker);
+        RemoveTesselationTriangle(triangle);
+      } else
+        DoLog(1) && (Log() << Verbose(1) << " Keeping ... " << endl);
+    }
+    /// 4c. Copy all "front" triangles but with inverse NormalVector
+    TriangleWalker = T->begin();
+    while (TriangleWalker != T->end()) { // go through all front triangles
+      DoLog(1) && (Log() << Verbose(1) << " Re-creating triangle " << **TriangleWalker << " with NormalVector " << (*TriangleWalker)->NormalVector << endl);
+      for (int i = 0; i < 3; i++)
+        AddTesselationPoint((*TriangleWalker)->endpoints[i]->node, i);
+      AddTesselationLine(NULL, NULL, TPS[0], TPS[1], 0);
+      AddTesselationLine(NULL, NULL, TPS[0], TPS[2], 1);
+      AddTesselationLine(NULL, NULL, TPS[1], TPS[2], 2);
+      if (TriangleNrs.empty())
+        DoeLog(0) && (eLog() << Verbose(0) << "No more free triangle numbers!" << endl);
+      BTS = new BoundaryTriangleSet(BLS, TriangleNrs.top()); // copy triangle ...
+      AddTesselationTriangle(); // ... and add
+      TriangleNrs.pop();
+      BTS->NormalVector = -1 * (*TriangleWalker)->NormalVector;
+      TriangleWalker++;
+    }
+    if (!TriangleNrs.empty()) {
+      DoeLog(0) && (eLog() << Verbose(0) << "There have been less triangles created than removed!" << endl);
+    }
+    delete (T); // remove the triangleset
+  }
+  IndexToIndex * SimplyDegeneratedTriangles = FindAllDegeneratedTriangles();
+  DoLog(0) && (Log() << Verbose(0) << "Final list of simply degenerated triangles found, containing " << SimplyDegeneratedTriangles->size() << " triangles:" << endl);
+  IndexToIndex::iterator it;
+  for (it = SimplyDegeneratedTriangles->begin(); it != SimplyDegeneratedTriangles->end(); it++)
+    DoLog(0) && (Log() << Verbose(0) << (*it).first << " => " << (*it).second << endl);
+  delete (SimplyDegeneratedTriangles);
+  /// 5. exit
+  UniquePolygonSet::iterator PolygonRunner;
+  while (!ListofDegeneratedPolygons.empty()) {
+    PolygonRunner = ListofDegeneratedPolygons.begin();
+    delete (*PolygonRunner);
+    ListofDegeneratedPolygons.erase(PolygonRunner);
+  }
+
+  return counter;
+}
+;
Index: src/tesselation.hpp
===================================================================
--- src/tesselation.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/tesselation.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,386 @@
+/*
+ * 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.
+ *
+ *  Created on: Aug 3, 2009
+ *      Author: heber
+ */
+
+#ifndef TESSELATION_HPP_
+#define TESSELATION_HPP_
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <map>
+#include <list>
+#include <set>
+#include <stack>
+
+#include "atom_particleinfo.hpp"
+#include "helpers.hpp"
+#include "vector.hpp"
+
+/****************************************** forward declarations *****************************/
+
+class BoundaryPointSet;
+class BoundaryLineSet;
+class BoundaryTriangleSet;
+class LinkedCell;
+class TesselPoint;
+class PointCloud;
+class Tesselation;
+class Plane;
+
+/********************************************** definitions *********************************/
+
+#define DoTecplotOutput 1
+#define DoRaster3DOutput 1
+#define DoVRMLOutput 0
+#define TecplotSuffix ".dat"
+#define Raster3DSuffix ".r3d"
+#define VRMLSUffix ".wrl"
+
+#define ParallelEpsilon 1e-3
+
+// ======================================================= 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 ===========================================
+
+/** Contains the envelope to a PointCloud.
+ */
+class Tesselation : public PointCloud {
+  public:
+
+    Tesselation();
+    virtual ~Tesselation();
+
+    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 AddNewTesselationTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, const int n);
+    void AddExistingTesselationTriangleLine(class BoundaryLineSet *FindLine, int n);
+    void AddTesselationTriangle();
+    void AddTesselationTriangle(const int nr);
+    void AddCandidateTriangle(CandidateForTesselation &CandidateLine, enum centers type);
+    void AddDegeneratedTriangle(CandidateForTesselation &CandidateLine, const double RADIUS, const LinkedCell *LC);
+    void AddCandidatePolygon(CandidateForTesselation CandidateLine, const double RADIUS, const LinkedCell *LC);
+    void RemoveTesselationTriangle(class BoundaryTriangleSet *triangle);
+    void RemoveTesselationLine(class BoundaryLineSet *line);
+    void RemoveTesselationPoint(class BoundaryPointSet *point);
+    bool CheckDegeneracy(CandidateForTesselation &CandidateLine, const double RADIUS, const LinkedCell *LC) const;
+
+
+    // concave envelope
+    bool FindStartingTriangle(const double RADIUS, const LinkedCell *LC);
+    void FindSecondPointForTesselation(class TesselPoint* a, Vector Oben, class TesselPoint*& OptCandidate, double Storage[3], double RADIUS, const LinkedCell *LC);
+    void FindThirdPointForTesselation(const Vector &NormalVector, const Vector &SearchDirection, const Vector &OldSphereCenter, CandidateForTesselation &CandidateLine, const class BoundaryPointSet  * const ThirdNode, const double RADIUS, const LinkedCell *LC) const;
+    bool FindNextSuitableTriangle(CandidateForTesselation &CandidateLine, const BoundaryTriangleSet &T, const double& RADIUS, const LinkedCell *LC);
+    bool FindCandidatesforOpenLines(const double RADIUS, const LinkedCell *&LCList);
+    int CheckPresenceOfTriangle(class TesselPoint *Candidates[3]) const;
+    class BoundaryTriangleSet * GetPresentTriangle(TesselPoint *Candidates[3]);
+
+    // convex envelope
+    void TesselateOnBoundary(const PointCloud * const cloud);
+    void GuessStartingTriangle();
+    bool InsertStraddlingPoints(const PointCloud *cloud, const LinkedCell *LC);
+    double RemovePointFromTesselatedSurface(class BoundaryPointSet *point);
+    class BoundaryLineSet * FlipBaseline(class BoundaryLineSet *Base);
+    double PickFarthestofTwoBaselines(class BoundaryLineSet *Base);
+    class BoundaryPointSet *IsConvexRectangle(class BoundaryLineSet *Base);
+    IndexToIndex * FindAllDegeneratedTriangles();
+    IndexToIndex * FindAllDegeneratedLines();
+    void RemoveDegeneratedTriangles();
+    void AddBoundaryPointByDegeneratedTriangle(class TesselPoint *point, LinkedCell *LC);
+    int CorrectAllDegeneratedPolygons();
+
+    TesselPointSet * GetAllConnectedPoints(const TesselPoint* const Point) const;
+    TriangleSet * GetAllTriangles(const BoundaryPointSet * const Point) const;
+    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;
+    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;
+    bool IsInnerPoint(const Vector &Point, const LinkedCell* const LC) const;
+    double GetDistanceSquaredToTriangle(const Vector &Point, const BoundaryTriangleSet* const triangle) const;
+    double GetDistanceToSurface(const Vector &Point, const LinkedCell* const LC) const;
+    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;
+
+    // print for debugging
+    void PrintAllBoundaryPoints(ofstream *out) const;
+    void PrintAllBoundaryLines(ofstream *out) const;
+    void PrintAllBoundaryTriangles(ofstream *out) const;
+
+    // store envelope in file
+    void Output(const char *filename, const PointCloud * const cloud);
+
+    PointMap PointsOnBoundary;
+    LineMap LinesOnBoundary;
+    CandidateMap OpenLines;
+    TriangleMap TrianglesOnBoundary;
+    int PointsOnBoundaryCount;
+    int LinesOnBoundaryCount;
+    int TrianglesOnBoundaryCount;
+
+    // PointCloud implementation for PointsOnBoundary
+    virtual Vector *GetCenter(ofstream *out) const;
+    virtual TesselPoint *GetPoint() const;
+    virtual void GoToNext() const;
+    virtual void GoToFirst() const;
+    virtual bool IsEmpty() const;
+    virtual bool IsEnd() const;
+
+    class BoundaryPointSet *BPS[2];
+    class BoundaryLineSet *BLS[3];
+    class BoundaryTriangleSet *BTS;
+    class BoundaryTriangleSet *LastTriangle;
+    int TriangleFilesWritten;
+
+  private:
+    mutable class BoundaryPointSet *TPS[3]; //this is a Storage for pointers to triangle points, this and BPS[2] needed due to AddLine restrictions
+
+    mutable PointMap::const_iterator InternalPointer;
+
+    //bool HasOtherBaselineBetterCandidate(const BoundaryLineSet * const BaseRay, const TesselPoint * const OptCandidate, double ShortestAngle, double RADIUS, const LinkedCell * const LC) const;
+    void FindDegeneratedCandidatesforOpenLines(TesselPoint * const Sprinter, const Vector * const OptCenter);
+};
+
+
+#endif /* TESSELATION_HPP_ */
Index: src/tesselationhelpers.cpp
===================================================================
--- src/tesselationhelpers.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/tesselationhelpers.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,1086 @@
+/*
+ * TesselationHelpers.cpp
+ *
+ *  Created on: Aug 3, 2009
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include <fstream>
+
+#include "info.hpp"
+#include "linkedcell.hpp"
+#include "linearsystemofequations.hpp"
+#include "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;
+};
+
+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);
+  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);
+
+  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);
+
+  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);
+
+  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);
+
+  if (fabs(m11) < MYEPSILON)
+    DoeLog(1) && (eLog()<< Verbose(1) << "three points are colinear." << endl);
+
+  center->at(0) =  0.5 * m12/ m11;
+  center->at(1) = -0.5 * m13/ m11;
+  center->at(2) =  0.5 * m14/ m11;
+
+  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);
+};
+
+
+
+/**
+ * Function returns center of sphere with RADIUS, which rests on points a, b, c
+ * @param Center this vector will be used for return
+ * @param a vector first point of triangle
+ * @param b vector second point of triangle
+ * @param c vector third point of triangle
+ * @param *Umkreismittelpunkt new center point of circumference
+ * @param Direction vector indicates up/down
+ * @param AlternativeDirection Vector, needed in case the triangles have 90 deg angle
+ * @param Halfplaneindicator double indicates whether Direction is up or down
+ * @param AlternativeIndicator double indicates in case of orthogonal triangles which direction of AlternativeDirection is suitable
+ * @param alpha double angle at a
+ * @param beta double, angle at b
+ * @param gamma, double, angle at c
+ * @param Radius, double
+ * @param Umkreisradius double radius of circumscribing circle
+ */
+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)
+{
+	Info FunctionInfo(__func__);
+  Vector TempNormal, helper;
+  double Restradius;
+  Vector OtherCenter;
+  Center->Zero();
+  helper = sin(2.*alpha) * a;
+  (*Center) += helper;
+  helper = sin(2.*beta) * b;
+  (*Center) += helper;
+  helper = sin(2.*gamma) * c;
+  (*Center) += helper;
+  //*Center = a * sin(2.*alpha) + b * sin(2.*beta) + c * sin(2.*gamma) ;
+  Center->Scale(1./(sin(2.*alpha) + sin(2.*beta) + sin(2.*gamma)));
+  (*NewUmkreismittelpunkt) = (*Center);
+  DoLog(1) && (Log() << Verbose(1) << "Center of new circumference is " << *NewUmkreismittelpunkt << ".\n");
+  // Here we calculated center of circumscribing circle, using barycentric coordinates
+  DoLog(1) && (Log() << Verbose(1) << "Center of circumference is " << *Center << " in direction " << *Direction << ".\n");
+
+  TempNormal = a - b;
+  helper = a - c;
+  TempNormal.VectorProduct(helper);
+  if (fabs(HalfplaneIndicator) < MYEPSILON)
+    {
+      if ((TempNormal.ScalarProduct(*AlternativeDirection) <0 && AlternativeIndicator >0) || (TempNormal.ScalarProduct(*AlternativeDirection) >0 && AlternativeIndicator <0))
+        {
+          TempNormal *= -1;
+        }
+    }
+  else
+    {
+      if (((TempNormal.ScalarProduct(*Direction)<0) && (HalfplaneIndicator >0)) || ((TempNormal.ScalarProduct(*Direction)>0) && (HalfplaneIndicator<0)))
+        {
+          TempNormal *= -1;
+        }
+    }
+
+  TempNormal.Normalize();
+  Restradius = sqrt(RADIUS*RADIUS - Umkreisradius*Umkreisradius);
+  DoLog(1) && (Log() << Verbose(1) << "Height of center of circumference to center of sphere is " << Restradius << ".\n");
+  TempNormal.Scale(Restradius);
+  DoLog(1) && (Log() << Verbose(1) << "Shift vector to sphere of circumference is " << TempNormal << ".\n");
+  (*Center) += TempNormal;
+  DoLog(1) && (Log() << Verbose(1) << "Center of sphere of circumference is " << *Center << ".\n");
+  GetSphere(&OtherCenter, a, b, c, RADIUS);
+  DoLog(1) && (Log() << Verbose(1) << "OtherCenter of sphere of circumference is " << OtherCenter << ".\n");
+};
+
+
+/** Constructs the center of the circumcircle defined by three points \a *a, \a *b and \a *c.
+ * \param *Center new center on return
+ * \param *a first point
+ * \param *b second point
+ * \param *c third point
+ */
+void GetCenterofCircumcircle(Vector * const Center, const Vector &a, const Vector &b, const Vector &c)
+{
+	Info FunctionInfo(__func__);
+  Vector helper;
+  Vector SideA = b - c;
+  Vector SideB = c - a;
+  Vector SideC = a - b;
+
+  helper[0] = SideA.NormSquared()*(SideB.NormSquared()+SideC.NormSquared() - SideA.NormSquared());
+  helper[1] = SideB.NormSquared()*(SideC.NormSquared()+SideA.NormSquared() - SideB.NormSquared());
+  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;
+};
+
+/** Returns the parameter "path length" for a given \a NewSphereCenter relative to \a OldSphereCenter on a circle on the plane \a CirclePlaneNormal with center \a CircleCenter and radius \a CircleRadius.
+ * Test whether the \a NewSphereCenter is really on the given plane and in distance \a CircleRadius from \a CircleCenter.
+ * It calculates the angle, making it unique on [0,2.*M_PI) by comparing to SearchDirection.
+ * Also the new center is invalid if it the same as the old one and does not lie right above (\a NormalVector) the base line (\a CircleCenter).
+ * \param CircleCenter Center of the parameter circle
+ * \param CirclePlaneNormal normal vector to plane of the parameter circle
+ * \param CircleRadius radius of the parameter circle
+ * \param NewSphereCenter new center of a circumcircle
+ * \param OldSphereCenter old center of a circumcircle, defining the zero "path length" on the parameter circle
+ * \param NormalVector normal vector
+ * \param SearchDirection search direction to make angle unique on return.
+ * \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)
+{
+	Info FunctionInfo(__func__);
+  Vector helper;
+  double radius, alpha;
+
+  Vector RelativeOldSphereCenter = OldSphereCenter - CircleCenter;
+  Vector RelativeNewSphereCenter = NewSphereCenter - CircleCenter;
+  helper = RelativeNewSphereCenter;
+  // test whether new center is on the parameter circle's plane
+  if (fabs(helper.ScalarProduct(CirclePlaneNormal)) > HULLEPSILON) {
+    DoeLog(1) && (eLog()<< Verbose(1) << "Something's very wrong here: NewSphereCenter is not on the band's plane as desired by " <<fabs(helper.ScalarProduct(CirclePlaneNormal))  << "!" << endl);
+    helper.ProjectOntoPlane(CirclePlaneNormal);
+  }
+  radius = helper.NormSquared();
+  // test whether the new center vector has length of CircleRadius
+  if (fabs(radius - CircleRadius) > HULLEPSILON)
+    DoeLog(1) && (eLog()<< Verbose(1) << "The projected center of the new sphere has radius " << radius << " instead of " << CircleRadius << "." << endl);
+  alpha = helper.Angle(RelativeOldSphereCenter);
+  // make the angle unique by checking the halfplanes/search direction
+  if (helper.ScalarProduct(SearchDirection) < -HULLEPSILON)  // acos is not unique on [0, 2.*M_PI), hence extra check to decide between two half intervals
+    alpha = 2.*M_PI - alpha;
+  DoLog(1) && (Log() << Verbose(1) << "INFO: RelativeNewSphereCenter is " << helper << ", RelativeOldSphereCenter is " << RelativeOldSphereCenter << " and resulting angle is " << alpha << "." << endl);
+  radius = helper.distance(RelativeOldSphereCenter);
+  helper.ProjectOntoPlane(NormalVector);
+  // check whether new center is somewhat away or at least right over the current baseline to prevent intersecting triangles
+  if ((radius > HULLEPSILON) || (helper.Norm() < HULLEPSILON)) {
+    DoLog(1) && (Log() << Verbose(1) << "INFO: Distance between old and new center is " << radius << " and between new center and baseline center is " << helper.Norm() << "." << endl);
+    return alpha;
+  } else {
+    DoLog(1) && (Log() << Verbose(1) << "INFO: NewSphereCenter " << RelativeNewSphereCenter << " is too close to RelativeOldSphereCenter" << RelativeOldSphereCenter << "." << endl);
+    return 2.*M_PI;
+  }
+};
+
+struct Intersection {
+  Vector x1;
+  Vector x2;
+  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;
+};
+
+/** Gets the angle between a point and a reference relative to the provided center.
+ * We have two shanks point and reference between which the angle is calculated
+ * and by scalar product with OrthogonalVector we decide the interval.
+ * @param point to calculate the angle for
+ * @param reference to which to calculate the angle
+ * @param OrthogonalVector points in direction of [pi,2pi] interval
+ *
+ * @return angle between point and reference
+ */
+double GetAngle(const Vector &point, const Vector &reference, const Vector &OrthogonalVector)
+{
+	Info FunctionInfo(__func__);
+  if (reference.IsZero())
+    return M_PI;
+
+  // calculate both angles and correct with in-plane vector
+  if (point.IsZero())
+    return M_PI;
+  double phi = point.Angle(reference);
+  if (OrthogonalVector.ScalarProduct(point) > 0) {
+    phi = 2.*M_PI - phi;
+  }
+
+  DoLog(1) && (Log() << Verbose(1) << "INFO: " << point << " has angle " << phi << " with respect to reference " << reference << "." << endl);
+
+  return phi;
+}
+
+
+/** Calculates the volume of a general tetraeder.
+ * \param *a first vector
+ * \param *b second vector
+ * \param *c third vector
+ * \param *d fourth vector
+ * \return \f$ \frac{1}{6} \cdot ((a-d) \times (a-c) \cdot  (a-b)) \f$
+ */
+double CalculateVolumeofGeneralTetraeder(const Vector &a, const Vector &b, const Vector &c, const Vector &d)
+{
+	Info FunctionInfo(__func__);
+  Vector Point, TetraederVector[3];
+  double volume;
+
+  TetraederVector[0] = a;
+  TetraederVector[1] = b;
+  TetraederVector[2] = c;
+  for (int j=0;j<3;j++)
+    TetraederVector[j].SubtractVector(d);
+  Point = TetraederVector[0];
+  Point.VectorProduct(TetraederVector[1]);
+  volume = 1./6. * fabs(Point.ScalarProduct(TetraederVector[2]));
+  return volume;
+};
+
+/** Calculates the area of a general triangle.
+ * We use the Heron's formula of area, [Bronstein, S. 138]
+ * \param &A first vector
+ * \param &B second vector
+ * \param &C third vector
+ * \return \f$ \frac{1}{6} \cdot ((a-d) \times (a-c) \cdot  (a-b)) \f$
+ */
+double CalculateAreaofGeneralTriangle(const Vector &A, const Vector &B, const Vector &C)
+{
+  Info FunctionInfo(__func__);
+
+  const double sidea = B.distance(C);
+  const double sideb = A.distance(C);
+  const double sidec = A.distance(B);
+  const double s = (sidea+sideb+sidec)/2.;
+
+  const double area = sqrt(s*(s-sidea)*(s-sideb)*(s-sidec));
+  return area;
+};
+
+
+/** Checks for a new special triangle whether one of its edges is already present with one one triangle connected.
+ * This enforces that special triangles (i.e. degenerated ones) should at last close the open-edge frontier and not
+ * make it bigger (i.e. closing one (the baseline) and opening two new ones).
+ * \param TPS[3] nodes of the triangle
+ * \return true - there is such a line (i.e. creation of degenerated triangle is valid), false - no such line (don't create)
+ */
+bool CheckLineCriteriaForDegeneratedTriangle(const BoundaryPointSet * const nodes[3])
+{
+	Info FunctionInfo(__func__);
+  bool result = false;
+  int counter = 0;
+
+  // check all three points
+  for (int i=0;i<3;i++)
+    for (int j=i+1; j<3; j++) {
+      if (nodes[i] == NULL) {
+        DoLog(1) && (Log() << Verbose(1) << "Node nr. " << i << " is not yet present." << endl);
+        result = true;
+      } else if (nodes[i]->lines.find(nodes[j]->node->nr) != nodes[i]->lines.end()) {  // there already is a line
+        LineMap::const_iterator FindLine;
+        pair<LineMap::const_iterator,LineMap::const_iterator> FindPair;
+        FindPair = nodes[i]->lines.equal_range(nodes[j]->node->nr);
+        for (FindLine = FindPair.first; FindLine != FindPair.second; ++FindLine) {
+          // If there is a line with less than two attached triangles, we don't need a new line.
+          if (FindLine->second->triangles.size() < 2) {
+            counter++;
+            break;  // increase counter only once per edge
+          }
+        }
+      } else { // no line
+        DoLog(1) && (Log() << Verbose(1) << "The line between " << *nodes[i] << " and " << *nodes[j] << " is not yet present, hence no need for a degenerate triangle." << endl);
+        result = true;
+      }
+    }
+  if ((!result) && (counter > 1)) {
+    DoLog(1) && (Log() << Verbose(1) << "INFO: Degenerate triangle is ok, at least two, here " << counter << ", existing lines are used." << endl);
+    result = true;
+  }
+  return result;
+};
+
+
+///** Sort function for the candidate list.
+// */
+//bool SortCandidates(const CandidateForTesselation* candidate1, const CandidateForTesselation* candidate2)
+//{
+//	Info FunctionInfo(__func__);
+//  Vector BaseLineVector, OrthogonalVector, helper;
+//  if (candidate1->BaseLine != candidate2->BaseLine) {  // sanity check
+//    DoeLog(1) && (eLog()<< Verbose(1) << "sortCandidates was called for two different baselines: " << candidate1->BaseLine << " and " << candidate2->BaseLine << "." << endl);
+//    //return false;
+//    exit(1);
+//  }
+//  // create baseline vector
+//  BaseLineVector.CopyVector(candidate1->BaseLine->endpoints[1]->node->node);
+//  BaseLineVector.SubtractVector(candidate1->BaseLine->endpoints[0]->node->node);
+//  BaseLineVector.Normalize();
+//
+//  // create normal in-plane vector to cope with acos() non-uniqueness on [0,2pi] (note that is pointing in the "right" direction already, hence ">0" test!)
+//  helper.CopyVector(candidate1->BaseLine->endpoints[0]->node->node);
+//  helper.SubtractVector(candidate1->point->node);
+//  OrthogonalVector.CopyVector(&helper);
+//  helper.VectorProduct(&BaseLineVector);
+//  OrthogonalVector.SubtractVector(&helper);
+//  OrthogonalVector.Normalize();
+//
+//  // calculate both angles and correct with in-plane vector
+//  helper.CopyVector(candidate1->point->node);
+//  helper.SubtractVector(candidate1->BaseLine->endpoints[0]->node->node);
+//  double phi = BaseLineVector.Angle(&helper);
+//  if (OrthogonalVector.ScalarProduct(&helper) > 0) {
+//    phi = 2.*M_PI - phi;
+//  }
+//  helper.CopyVector(candidate2->point->node);
+//  helper.SubtractVector(candidate1->BaseLine->endpoints[0]->node->node);
+//  double psi = BaseLineVector.Angle(&helper);
+//  if (OrthogonalVector.ScalarProduct(&helper) > 0) {
+//    psi = 2.*M_PI - psi;
+//  }
+//
+//  Log() << Verbose(1) << *candidate1->point << " has angle " << phi << endl;
+//  Log() << Verbose(1) << *candidate2->point << " has angle " << psi << endl;
+//
+//  // return comparison
+//  return phi < psi;
+//};
+
+/**
+ * Finds the point which is second closest to the provided one.
+ *
+ * @param Point to which to find the second closest other point
+ * @param linked cell structure
+ *
+ * @return point which is second closest to the provided one
+ */
+TesselPoint* FindSecondClosestTesselPoint(const Vector* Point, const LinkedCell* const LC)
+{
+	Info FunctionInfo(__func__);
+  TesselPoint* closestPoint = NULL;
+  TesselPoint* secondClosestPoint = NULL;
+  double distance = 1e16;
+  double secondDistance = 1e16;
+  Vector helper;
+  int N[NDIM], Nlower[NDIM], Nupper[NDIM];
+
+  LC->SetIndexToVector(Point); // ignore status as we calculate bounds below sensibly
+  for(int i=0;i<NDIM;i++) // store indices of this cell
+    N[i] = LC->n[i];
+  DoLog(1) && (Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl);
+
+  LC->GetNeighbourBounds(Nlower, Nupper);
+  //Log() << Verbose(1) << endl;
+  for (LC->n[0] = Nlower[0]; LC->n[0] <= Nupper[0]; LC->n[0]++)
+    for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
+      for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
+        const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
+        //Log() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << endl;
+        if (List != NULL) {
+          for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
+            helper = (*Point) - (*(*Runner)->node);
+            double currentNorm = helper. Norm();
+            if (currentNorm < distance) {
+              // remember second point
+              secondDistance = distance;
+              secondClosestPoint = closestPoint;
+              // mark down new closest point
+              distance = currentNorm;
+              closestPoint = (*Runner);
+              //Log() << Verbose(2) << "INFO: New Second Nearest Neighbour is " << *secondClosestPoint << "." << endl;
+            }
+          }
+        } else {
+          DoeLog(1) && (eLog() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << " is invalid!" << endl);
+        }
+      }
+
+  return secondClosestPoint;
+};
+
+/**
+ * Finds the point which is closest to the provided one.
+ *
+ * @param Point to which to find the closest other point
+ * @param SecondPoint the second closest other point on return, NULL if none found
+ * @param linked cell structure
+ *
+ * @return point which is closest to the provided one, NULL if none found
+ */
+TesselPoint* FindClosestTesselPoint(const Vector* Point, TesselPoint *&SecondPoint, const LinkedCell* const LC)
+{
+	Info FunctionInfo(__func__);
+  TesselPoint* closestPoint = NULL;
+  SecondPoint = NULL;
+  double distance = 1e16;
+  double secondDistance = 1e16;
+  Vector helper;
+  int N[NDIM], Nlower[NDIM], Nupper[NDIM];
+
+  LC->SetIndexToVector(Point); // ignore status as we calculate bounds below sensibly
+  for(int i=0;i<NDIM;i++) // store indices of this cell
+    N[i] = LC->n[i];
+  DoLog(1) && (Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl);
+
+  LC->GetNeighbourBounds(Nlower, Nupper);
+  //Log() << Verbose(1) << endl;
+  for (LC->n[0] = Nlower[0]; LC->n[0] <= Nupper[0]; LC->n[0]++)
+    for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
+      for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
+        const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
+        //Log() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << endl;
+        if (List != NULL) {
+          for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
+            helper = (*Point) - (*(*Runner)->node);
+            double currentNorm = helper.NormSquared();
+            if (currentNorm < distance) {
+              secondDistance = distance;
+              SecondPoint = closestPoint;
+              distance = currentNorm;
+              closestPoint = (*Runner);
+              //Log() << Verbose(1) << "INFO: New Nearest Neighbour is " << *closestPoint << "." << endl;
+            } else if (currentNorm < secondDistance) {
+              secondDistance = currentNorm;
+              SecondPoint = (*Runner);
+              //Log() << Verbose(1) << "INFO: New Second Nearest Neighbour is " << *SecondPoint << "." << endl;
+            }
+          }
+        } else {
+          DoeLog(1) && (eLog() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << " is invalid!" << endl);
+        }
+      }
+  // output
+  if (closestPoint != NULL) {
+    DoLog(1) && (Log() << Verbose(1) << "Closest point is " << *closestPoint);
+    if (SecondPoint != NULL)
+      DoLog(0) && (Log() << Verbose(0) << " and second closest is " << *SecondPoint);
+    DoLog(0) && (Log() << Verbose(0) << "." << endl);
+  }
+  return closestPoint;
+};
+
+/** Returns the closest point on \a *Base with respect to \a *OtherBase.
+ * \param *out output stream for debugging
+ * \param *Base reference line
+ * \param *OtherBase other base line
+ * \return Vector on reference line that has closest distance
+ */
+Vector * GetClosestPointBetweenLine(const BoundaryLineSet * const Base, const BoundaryLineSet * const OtherBase)
+{
+	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 Normal = Baseline;
+  Normal.VectorProduct(OtherBaseline);
+  Normal.Normalize();
+  DoLog(1) && (Log() << Verbose(1) << "First direction is " << Baseline << ", second direction is " << OtherBaseline << ", normal of intersection plane is " << Normal << "." << endl);
+
+  // 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);
+  NewOffset.ProjectOntoPlane(Normal);
+  NewOffset += (*Base->endpoints[0]->node->node);
+  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 line2 = makeLineThrough(NewOffset, NewDirection);
+  *Intersection = line1.getIntersection(line2);
+  Normal = (*Intersection) - (*Base->endpoints[0]->node->node);
+  DoLog(1) && (Log() << Verbose(1) << "Found closest point on " << *Base << " at " << *Intersection << ", factor in line is " << fabs(Normal.ScalarProduct(Baseline)/Baseline.NormSquared()) << "." << endl);
+
+  return Intersection;
+};
+
+/** Returns the distance to the plane defined by \a *triangle
+ * \param *out output stream for debugging
+ * \param *x Vector to calculate distance to
+ * \param *triangle triangle defining plane
+ * \return distance between \a *x and plane defined by \a *triangle, -1 - if something went wrong
+ */
+double DistanceToTrianglePlane(const Vector *x, const BoundaryTriangleSet * const triangle)
+{
+	Info FunctionInfo(__func__);
+  double distance = 0.;
+  if (x == NULL) {
+    return -1;
+  }
+  distance = x->DistanceToSpace(triangle->getPlane());
+  return distance;
+};
+
+/** Creates the objects in a VRML file.
+ * \param *out output stream for debugging
+ * \param *vrmlfile output stream for tecplot data
+ * \param *Tess Tesselation structure with constructed triangles
+ * \param *mol molecule structure with atom positions
+ */
+void WriteVrmlFile(ofstream * const vrmlfile, const Tesselation * const Tess, const PointCloud * const cloud)
+{
+	Info FunctionInfo(__func__);
+  TesselPoint *Walker = NULL;
+  int i;
+  Vector *center = cloud->GetCenter();
+  if (vrmlfile != NULL) {
+    //Log() << Verbose(1) << "Writing Raster3D file ... ";
+    *vrmlfile << "#VRML V2.0 utf8" << endl;
+    *vrmlfile << "#Created by molecuilder" << endl;
+    *vrmlfile << "#All atoms as spheres" << endl;
+    cloud->GoToFirst();
+    while (!cloud->IsEnd()) {
+      Walker = cloud->GetPoint();
+      *vrmlfile << "Sphere {" << endl << "  "; // 2 is sphere type
+      for (i=0;i<NDIM;i++)
+        *vrmlfile << Walker->node->at(i)-center->at(i) << " ";
+      *vrmlfile << "\t0.1\t1. 1. 1." << endl; // radius 0.05 and white as colour
+      cloud->GoToNext();
+    }
+
+    *vrmlfile << "# All tesselation triangles" << endl;
+    for (TriangleMap::const_iterator TriangleRunner = Tess->TrianglesOnBoundary.begin(); TriangleRunner != Tess->TrianglesOnBoundary.end(); TriangleRunner++) {
+      *vrmlfile << "1" << endl << "  "; // 1 is triangle type
+      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 << "\t";
+      }
+      *vrmlfile << "1. 0. 0." << endl;  // red as colour
+      *vrmlfile << "18" << endl << "  0.5 0.5 0.5" << endl; // 18 is transparency type for previous object
+    }
+  } else {
+    DoeLog(1) && (eLog()<< Verbose(1) << "Given vrmlfile is " << vrmlfile << "." << endl);
+  }
+  delete(center);
+};
+
+/** Writes additionally the current sphere (i.e. the last triangle to file).
+ * \param *out output stream for debugging
+ * \param *rasterfile output stream for tecplot data
+ * \param *Tess Tesselation structure with constructed triangles
+ * \param *mol molecule structure with atom positions
+ */
+void IncludeSphereinRaster3D(ofstream * const rasterfile, const Tesselation * const Tess, const PointCloud * const cloud)
+{
+	Info FunctionInfo(__func__);
+  Vector helper;
+
+  if (Tess->LastTriangle != NULL) {
+    // include the current position of the virtual sphere in the temporary raster3d file
+    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));
+    helper -= (*center);
+    // and add to file plus translucency object
+    *rasterfile << "# current virtual sphere\n";
+    *rasterfile << "8\n  25.0    0.6     -1.0 -1.0 -1.0     0.2        0 0 0 0\n";
+    *rasterfile << "2\n  " << helper[0] << " " << helper[1] << " " << helper[2] << "\t" << 5. << "\t1 0 0\n";
+    *rasterfile << "9\n  terminating special property\n";
+    delete(center);
+  }
+};
+
+/** Creates the objects in a raster3d file (renderable with a header.r3d).
+ * \param *out output stream for debugging
+ * \param *rasterfile output stream for tecplot data
+ * \param *Tess Tesselation structure with constructed triangles
+ * \param *mol molecule structure with atom positions
+ */
+void WriteRaster3dFile(ofstream * const rasterfile, const Tesselation * const Tess, const PointCloud * const cloud)
+{
+	Info FunctionInfo(__func__);
+  TesselPoint *Walker = NULL;
+  int i;
+  Vector *center = cloud->GetCenter();
+  if (rasterfile != NULL) {
+    //Log() << Verbose(1) << "Writing Raster3D file ... ";
+    *rasterfile << "# Raster3D object description, created by MoleCuilder" << endl;
+    *rasterfile << "@header.r3d" << endl;
+    *rasterfile << "# All atoms as spheres" << endl;
+    cloud->GoToFirst();
+    while (!cloud->IsEnd()) {
+      Walker = cloud->GetPoint();
+      *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);
+        *rasterfile << ((fabs(tmp) < MYEPSILON) ? 0 : tmp) << " ";
+      }
+      *rasterfile << "\t0.1\t1. 1. 1." << endl; // radius 0.05 and white as colour
+      cloud->GoToNext();
+    }
+
+    *rasterfile << "# All tesselation triangles" << endl;
+    *rasterfile << "8\n  25. -1.   1. 1. 1.   0.0    0 0 0 2\n  SOLID     1.0 0.0 0.0\n  BACKFACE  0.3 0.3 1.0   0 0\n";
+    for (TriangleMap::const_iterator TriangleRunner = Tess->TrianglesOnBoundary.begin(); TriangleRunner != Tess->TrianglesOnBoundary.end(); TriangleRunner++) {
+      *rasterfile << "1" << endl << "  ";  // 1 is triangle type
+      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);
+          *rasterfile << ((fabs(tmp) < MYEPSILON) ? 0 : tmp) << " ";
+        }
+        *rasterfile << "\t";
+      }
+      *rasterfile << "1. 0. 0." << endl;  // red as colour
+      //*rasterfile << "18" << endl << "  0.5 0.5 0.5" << endl;  // 18 is transparency type for previous object
+    }
+    *rasterfile << "9\n#  terminating special property\n";
+  } else {
+    DoeLog(1) && (eLog()<< Verbose(1) << "Given rasterfile is " << rasterfile << "." << endl);
+  }
+  IncludeSphereinRaster3D(rasterfile, Tess, cloud);
+  delete(center);
+};
+
+/** This function creates the tecplot file, displaying the tesselation of the hull.
+ * \param *out output stream for debugging
+ * \param *tecplot output stream for tecplot data
+ * \param N arbitrary number to differentiate various zones in the tecplot format
+ */
+void WriteTecplotFile(ofstream * const tecplot, const Tesselation * const TesselStruct, const PointCloud * const cloud, const int N)
+{
+	Info FunctionInfo(__func__);
+  if ((tecplot != NULL) && (TesselStruct != NULL)) {
+    // write header
+    *tecplot << "TITLE = \"3D CONVEX SHELL\"" << endl;
+    *tecplot << "VARIABLES = \"X\" \"Y\" \"Z\" \"U\"" << endl;
+    *tecplot << "ZONE T=\"";
+    if (N < 0) {
+      *tecplot << cloud->GetName();
+    } else {
+      *tecplot << N << "-";
+      if (TesselStruct->LastTriangle != NULL) {
+        for (int i=0;i<3;i++)
+          *tecplot << (i==0 ? "" : "_") << TesselStruct->LastTriangle->endpoints[i]->node->getName();
+      } else {
+        *tecplot << "none";
+      }
+    }
+    *tecplot << "\", N=" << TesselStruct->PointsOnBoundary.size() << ", E=" << TesselStruct->TrianglesOnBoundary.size() << ", DATAPACKING=POINT, ZONETYPE=FETRIANGLE" << endl;
+    const int MaxId=cloud->GetMaxId();
+    int *LookupList = new int[MaxId];
+    for (int i=0; i< MaxId ; i++){
+      LookupList[i] = -1;
+    }
+
+    // print atom coordinates
+    int Counter = 1;
+    TesselPoint *Walker = NULL;
+    for (PointMap::const_iterator target = TesselStruct->PointsOnBoundary.begin(); target != TesselStruct->PointsOnBoundary.end(); ++target) {
+      Walker = target->second->node;
+      LookupList[Walker->nr] = Counter++;
+      for (int i=0;i<NDIM;i++) {
+        const double tmp = Walker->node->at(i);
+        *tecplot << ((fabs(tmp) < MYEPSILON) ? 0 : tmp) << " ";
+      }
+      *tecplot << target->second->value << endl;
+    }
+    *tecplot << endl;
+    // print connectivity
+    DoLog(1) && (Log() << Verbose(1) << "The following triangles were created:" << endl);
+    for (TriangleMap::const_iterator runner = TesselStruct->TrianglesOnBoundary.begin(); runner != TesselStruct->TrianglesOnBoundary.end(); runner++) {
+      DoLog(1) && (Log() << Verbose(1) << " " << runner->second->endpoints[0]->node->getName() << "<->" << runner->second->endpoints[1]->node->getName() << "<->" << runner->second->endpoints[2]->node->getName() << endl);
+      *tecplot << LookupList[runner->second->endpoints[0]->node->nr] << " " << LookupList[runner->second->endpoints[1]->node->nr] << " " << LookupList[runner->second->endpoints[2]->node->nr] << endl;
+    }
+    delete[] (LookupList);
+  }
+};
+
+/** Calculates the concavity for each of the BoundaryPointSet's in a Tesselation.
+ * Sets BoundaryPointSet::value equal to the number of connected lines that are not convex.
+ * \param *out output stream for debugging
+ * \param *TesselStruct pointer to Tesselation structure
+ */
+void CalculateConcavityPerBoundaryPoint(const Tesselation * const TesselStruct)
+{
+	Info FunctionInfo(__func__);
+  class BoundaryPointSet *point = NULL;
+  class BoundaryLineSet *line = NULL;
+  class BoundaryTriangleSet *triangle = NULL;
+  double ConcavityPerLine = 0.;
+  double ConcavityPerTriangle = 0.;
+  double area = 0.;
+  double totalarea = 0.;
+
+  for (PointMap::const_iterator PointRunner = TesselStruct->PointsOnBoundary.begin(); PointRunner != TesselStruct->PointsOnBoundary.end(); PointRunner++) {
+    point = PointRunner->second;
+    DoLog(1) && (Log() << Verbose(1) << "INFO: Current point is " << *point << "." << endl);
+
+    // calculate mean concavity over all connected line
+    ConcavityPerLine = 0.;
+    for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++) {
+      line = LineRunner->second;
+      //Log() << Verbose(1) << "INFO: Current line of point " << *point << " is " << *line << "." << endl;
+      ConcavityPerLine -= line->CalculateConvexity();
+    }
+    ConcavityPerLine /= point->lines.size();
+
+    // weigh with total area of the surrounding triangles
+    totalarea  = 0.;
+    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);
+    }
+    ConcavityPerLine *= totalarea;
+
+    // calculate mean concavity over all attached triangles
+    ConcavityPerTriangle = 0.;
+    for (TriangleSet::const_iterator TriangleRunner = triangles->begin(); TriangleRunner != triangles->end(); ++TriangleRunner) {
+      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 *= -line->CalculateConvexity();
+      if (area > 0)
+        ConcavityPerTriangle += area;
+//      else
+//        ConcavityPerTriangle -= area;
+    }
+    ConcavityPerTriangle /= triangles->size()/totalarea;
+    delete(triangles);
+
+    // add up
+    point->value = ConcavityPerLine + ConcavityPerTriangle;
+  }
+};
+
+
+
+/** Calculates the concavity for each of the BoundaryPointSet's in a Tesselation.
+ * Sets BoundaryPointSet::value equal to the nearest distance to convex envelope.
+ * \param *out output stream for debugging
+ * \param *TesselStruct pointer to Tesselation structure
+ * \param *Convex pointer to convex Tesselation structure as reference
+ */
+void CalculateConstrictionPerBoundaryPoint(const Tesselation * const TesselStruct, const Tesselation * const Convex)
+{
+  Info FunctionInfo(__func__);
+  double distance = 0.;
+
+  for (PointMap::const_iterator PointRunner = TesselStruct->PointsOnBoundary.begin(); PointRunner != TesselStruct->PointsOnBoundary.end(); PointRunner++) {
+    DoeLog(1) && (eLog() << Verbose(1) << "INFO: Current point is " << * PointRunner->second << "." << endl);
+
+    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);
+      if (CurrentDistance < distance)
+        distance = CurrentDistance;
+    }
+
+    PointRunner->second->value = distance;
+  }
+};
+
+/** Checks whether each BoundaryLineSet in the Tesselation has two triangles.
+ * \param *out output stream for debugging
+ * \param *TesselStruct
+ * \return true - all have exactly two triangles, false - some not, list is printed to screen
+ */
+bool CheckListOfBaselines(const Tesselation * const TesselStruct)
+{
+	Info FunctionInfo(__func__);
+  LineMap::const_iterator testline;
+  bool result = false;
+  int counter = 0;
+
+  DoLog(1) && (Log() << Verbose(1) << "Check: List of Baselines with not two connected triangles:" << endl);
+  for (testline = TesselStruct->LinesOnBoundary.begin(); testline != TesselStruct->LinesOnBoundary.end(); testline++) {
+    if (testline->second->triangles.size() != 2) {
+      DoLog(2) && (Log() << Verbose(2) << *testline->second << "\t" << testline->second->triangles.size() << endl);
+      counter++;
+    }
+  }
+  if (counter == 0) {
+    DoLog(1) && (Log() << Verbose(1) << "None." << endl);
+    result = true;
+  }
+  return result;
+}
+
+/** Counts the number of triangle pairs that contain the given polygon.
+ * \param *P polygon with endpoints to look for
+ * \param *T set of triangles to create pairs from containing \a *P
+ */
+int CountTrianglePairContainingPolygon(const BoundaryPolygonSet * const P, const TriangleSet * const T)
+{
+  Info FunctionInfo(__func__);
+  // check number of endpoints in *P
+  if (P->endpoints.size() != 4) {
+    DoeLog(1) && (eLog()<< Verbose(1) << "CountTrianglePairContainingPolygon works only on polygons with 4 nodes!" << endl);
+    return 0;
+  }
+
+  // check number of triangles in *T
+  if (T->size() < 2) {
+    DoeLog(1) && (eLog()<< Verbose(1) << "Not enough triangles to have pairs!" << endl);
+    return 0;
+  }
+
+  DoLog(0) && (Log() << Verbose(0) << "Polygon is " << *P << endl);
+  // create each pair, get the endpoints and check whether *P is contained.
+  int counter = 0;
+  PointSet Trianglenodes;
+  class BoundaryPolygonSet PairTrianglenodes;
+  for(TriangleSet::iterator Walker = T->begin(); Walker != T->end(); Walker++) {
+    for (int i=0;i<3;i++)
+      Trianglenodes.insert((*Walker)->endpoints[i]);
+
+    for(TriangleSet::iterator PairWalker = Walker; PairWalker != T->end(); PairWalker++) {
+      if (Walker != PairWalker) { // skip first
+        PairTrianglenodes.endpoints = Trianglenodes;
+        for (int i=0;i<3;i++)
+          PairTrianglenodes.endpoints.insert((*PairWalker)->endpoints[i]);
+        const int size = PairTrianglenodes.endpoints.size();
+        if (size == 4) {
+          DoLog(0) && (Log() << Verbose(0) << " Current pair of triangles: " << **Walker << "," << **PairWalker << " with " << size << " distinct endpoints:" << PairTrianglenodes << endl);
+          // now check
+          if (PairTrianglenodes.ContainsPresentTupel(P)) {
+            counter++;
+            DoLog(0) && (Log() << Verbose(0) << "  ACCEPT: Matches with " << *P << endl);
+          } else {
+            DoLog(0) && (Log() << Verbose(0) << "  REJECT: No match with " << *P << endl);
+          }
+        } else {
+          DoLog(0) && (Log() << Verbose(0) << "  REJECT: Less than four endpoints." << endl);
+        }
+      }
+    }
+    Trianglenodes.clear();
+  }
+  return counter;
+};
+
+/** Checks whether two give polygons have two or more points in common.
+ * \param *P1 first polygon
+ * \param *P2 second polygon
+ * \return true - are connected, false = are note
+ */
+bool ArePolygonsEdgeConnected(const BoundaryPolygonSet * const P1, const BoundaryPolygonSet * const P2)
+{
+  Info FunctionInfo(__func__);
+  int counter = 0;
+  for(PointSet::const_iterator Runner = P1->endpoints.begin(); Runner != P1->endpoints.end(); Runner++) {
+    if (P2->ContainsBoundaryPoint((*Runner))) {
+      counter++;
+      DoLog(1) && (Log() << Verbose(1) << *(*Runner) << " of second polygon is found in the first one." << endl);
+      return true;
+    }
+  }
+  return false;
+};
+
+/** Combines second into the first and deletes the second.
+ * \param *P1 first polygon, contains all nodes on return
+ * \param *&P2 second polygon, is deleted.
+ */
+void CombinePolygons(BoundaryPolygonSet * const P1, BoundaryPolygonSet * &P2)
+{
+  Info FunctionInfo(__func__);
+  pair <PointSet::iterator, bool> Tester;
+  for(PointSet::iterator Runner = P2->endpoints.begin(); Runner != P2->endpoints.end(); Runner++) {
+    Tester = P1->endpoints.insert((*Runner));
+    if (Tester.second)
+      DoLog(0) && (Log() << Verbose(0) << "Inserting endpoint " << *(*Runner) << " into first polygon." << endl);
+  }
+  P2->endpoints.clear();
+  delete(P2);
+};
+
Index: src/tesselationhelpers.hpp
===================================================================
--- src/tesselationhelpers.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/tesselationhelpers.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,81 @@
+/*
+ * TesselationHelpers.hpp
+ *
+ *  Auxiliary functions for the tesselation.
+ *
+ *  Created on: Aug 3, 2009
+ *      Author: heber
+ */
+
+#ifndef TESSELATIONHELPERS_HPP_
+#define TESSELATIONHELPERS_HPP_
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#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 <iostream>
+
+#include "defs.hpp"
+
+/****************************************** forward declarations *****************************/
+
+class BoundaryPointSet;
+class BoundaryLineSet;
+class BoundaryTriangleSet;
+class LinkedCell;
+class TesselPoint;
+class PointCloud;
+class Tesselation;
+class Vector;
+
+/********************************************** 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);
+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);
+double GetAngle(const Vector &point, const Vector &reference, const Vector &OrthogonalVector);
+
+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);
+Vector * GetClosestPointBetweenLine(const BoundaryLineSet * const Base, const BoundaryLineSet * const OtherBase);
+
+void WriteTecplotFile(ofstream * const tecplot, const Tesselation * const TesselStruct, const PointCloud * const cloud, const int N);
+void WriteRaster3dFile(ofstream * const rasterfile, const Tesselation * const Tess, const PointCloud * const cloud);
+void IncludeSphereinRaster3D(ofstream * const rasterfile, const Tesselation *Tess, const PointCloud *cloud);
+void WriteVrmlFile(ofstream * const vrmlfile, const Tesselation * const Tess, const PointCloud * const cloud);
+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);
+
+bool CheckListOfBaselines(const Tesselation * const TesselStruct);
+
+int CountTrianglePairContainingPolygon(const BoundaryPolygonSet * const P, const TriangleSet * const T);
+bool ArePolygonsEdgeConnected(const BoundaryPolygonSet * const P1, const BoundaryPolygonSet * const P2);
+void CombinePolygons(BoundaryPolygonSet * const P1, BoundaryPolygonSet * &P2);
+
+
+#endif /* TESSELATIONHELPERS_HPP_ */
Index: src/test/ActOnAlltest.hpp
===================================================================
--- src/test/ActOnAlltest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/test/ActOnAlltest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,110 @@
+/*
+ * ActOnAlltest.hpp
+ *
+ *  Created on: 04.10.2009
+ *      Author: FrederikHeber
+ */
+
+#ifndef ACTONALLTEST_HPP_
+#define ACTONALLTEST_HPP_
+
+using namespace std;
+
+#include <list>
+#include "../vector.hpp"
+
+#define ListOfVectors list<Vector *>
+
+class VectorList
+{
+public:
+  VectorList();
+  VectorList(VectorList &ref);
+  ~VectorList();
+
+  void AddVector(Vector *v);
+  void EmptyList();
+
+  template <typename klasse, typename res, typename T> void ActOnAll( res (klasse::*f)(T), T t );
+  template <typename klasse, typename res, typename T> void ActOnAll( res (klasse::*f)(T&), T &t );
+  template <typename klasse, typename res, typename T, typename U> void ActOnAll( res (klasse::*f)(T, U), T t, U u );
+  template <typename klasse, typename res, typename T, typename U, typename V> void ActOnAll( res (klasse::*f)(T, U, V), T t, U u, V v);
+
+  bool operator == (VectorList &rhs);
+  VectorList& operator = (VectorList &ref);
+
+//private:
+  ListOfVectors Vectors;
+};
+
+
+VectorList::VectorList() { };
+VectorList::VectorList(VectorList &ref)
+{
+  ref.EmptyList();
+  for (ListOfVectors::iterator Runner = Vectors.begin(); Runner != Vectors.end(); Runner++) {
+    ref.Vectors.push_back(new Vector (**Runner));
+  }
+};
+
+VectorList & VectorList::operator = (VectorList &ref)
+{
+  EmptyList();
+  for (ListOfVectors::iterator Runner = ref.Vectors.begin(); Runner != ref.Vectors.end(); Runner++) {
+    Vectors.push_back(new Vector (**Runner));
+  }
+  return *this;
+};
+
+bool VectorList::operator == (VectorList &rhs)
+{
+  bool status = true;
+  ListOfVectors::iterator lRunner = Vectors.begin();
+  ListOfVectors::iterator rRunner = rhs.Vectors.begin();
+  for (;(lRunner != Vectors.end()) && (rRunner != rhs.Vectors.end()); lRunner++, rRunner++) {
+    //Log() << Verbose(0) << **lRunner << " == " << **rRunner << endl;
+    status = status && (**lRunner == **rRunner);
+  }
+  return status;
+};
+
+VectorList::~VectorList() { };
+
+template <typename klasse, typename res, typename T> void VectorList::ActOnAll( res (klasse::*f)(T), T t )
+{
+  for (ListOfVectors::iterator Runner = Vectors.begin(); Runner != Vectors.end(); Runner++)
+    ((*Runner)->*f)(t);
+};
+
+template <typename klasse, typename res, typename T> void VectorList::ActOnAll( res (klasse::*f)(T&), T &t )
+{
+  for (ListOfVectors::iterator Runner = Vectors.begin(); Runner != Vectors.end(); Runner++)
+    ((*Runner)->*f)(t);
+};
+
+template <typename klasse, typename res, typename T, typename U> void VectorList::ActOnAll( res (klasse::*f)(T, U), T t, U u )
+{
+  for (ListOfVectors::iterator Runner = Vectors.begin(); Runner != Vectors.end(); Runner++)
+    ((*Runner)->*f)(t, u);
+};
+
+template <typename klasse, typename res, typename T, typename U, typename V> void VectorList::ActOnAll( res (klasse::*f)(T, U, V), T t, U u, V v)
+{
+  for (ListOfVectors::iterator Runner = Vectors.begin(); Runner != Vectors.end(); Runner++)
+    ((*Runner)->*f)(t, u, v);
+};
+
+void VectorList::AddVector(Vector *v)
+{
+  Vectors.push_back(v);
+};
+
+void VectorList::EmptyList()
+{
+  for (ListOfVectors::iterator Runner = Vectors.begin(); Runner != Vectors.end(); Runner++) {
+    delete(*Runner);
+  }
+  Vectors.clear();
+}
+
+#endif /* ACTONALLTEST_HPP_ */
Index: src/triangleintersectionlist.cpp
===================================================================
--- src/triangleintersectionlist.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/triangleintersectionlist.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,176 @@
+/*
+ * triangleintersectionlist.cpp
+ *
+ * This files encapsulates the TriangleIntersectionList class where all matters related to points in space being how close to
+ * a tesselated surface are answered, i.e. distance, is inside, ...
+ *
+ *  Created on: Mar 1, 2010
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include <boost/scoped_ptr.hpp>
+
+#include "triangleintersectionlist.hpp"
+
+#include "info.hpp"
+#include "tesselation.hpp"
+#include "vector.hpp"
+
+/** Constructor for class TriangleIntersectionList.
+ *
+ */
+TriangleIntersectionList::TriangleIntersectionList(const Vector *x, const Tesselation *surface, const LinkedCell* LC) :
+  Point(x),
+  Tess(surface),
+  Vicinity(LC)
+{
+  Info FunctionInfo(__func__);
+  GatherIntersectionsWithTriangles();
+};
+
+/** Destructor for class TriangleIntersectionList.
+ * Free's all allocated intersection vectors
+ */
+TriangleIntersectionList::~TriangleIntersectionList()
+{
+  Info FunctionInfo(__func__);
+  for (TriangleVectorMap::iterator Runner = IntersectionList.begin(); Runner != IntersectionList.end(); Runner++)
+    delete((*Runner).second);
+};
+
+/** Returns the smallest distance between TriangleIntersectionList::Point and the surface given by
+ * TriangleIntersectionList::Tess.
+ * \return distance >=0, -1 if no specific distance could be found
+ */
+double TriangleIntersectionList::GetSmallestDistance() const
+{
+  Info FunctionInfo(__func__);
+  FillDistanceList();
+  if (!DistanceList.empty())
+    return DistanceList.begin()->first;
+  else
+    // return reference, if none can be found
+    return -1.;
+};
+
+/** Returns the vector of closest intersection between TriangleIntersectionList::Point and the surface
+ * TriangleIntersectionList::Tess.
+ * \return Intersection vector or TriangleIntersectionList::Point if none could be found
+ */
+Vector TriangleIntersectionList::GetClosestIntersection() const
+{
+  Info FunctionInfo(__func__);
+  TriangleVectorMap::const_iterator runner;
+  runner = GetIteratortoSmallestDistance();
+  if (runner != IntersectionList.end()) {
+    return *((*runner).second);
+  }
+  // return reference, if none can be found
+  return *Point;
+};
+
+/** Returns the triangle closest to TriangleIntersectionList::Point and the surface
+ * TriangleIntersectionList::Tess.
+ * \return pointer to triangle or NULL if none could be found
+ */
+BoundaryTriangleSet * TriangleIntersectionList::GetClosestTriangle() const
+{
+  Info FunctionInfo(__func__);
+  TriangleVectorMap::const_iterator runner;
+  runner = GetIteratortoSmallestDistance();
+  if (runner != IntersectionList.end()) {
+    return ((*runner).first);
+  }
+  // return reference, if none can be found
+  return NULL;
+};
+
+/** Checks whether reference TriangleIntersectionList::Point of this class is inside or outside.
+ * \return true - TriangleIntersectionList::Point is inside, false - is outside
+ */
+bool TriangleIntersectionList::IsInside() const
+{
+  Info FunctionInfo(__func__);
+  TriangleVectorMap::const_iterator runner;
+  runner = GetIteratortoSmallestDistance();
+  if (runner != IntersectionList.end()) {
+    // if we have found one, check Scalarproduct between the vector
+    Vector TestVector = (*Point) - (*(*runner).second);
+    if (fabs(TestVector.NormSquared()) < MYEPSILON) //
+      return true;
+    const double sign = (*runner).first->NormalVector.ScalarProduct(TestVector);
+    if (sign < 0) {
+      return true;
+    } else {
+      return false;
+    }
+  }
+  // so far away from surface that there are no triangles in list
+  return false;
+};
+
+/** Puts all triangles in vicinity (by \a *LC) into a hash map with Intersection vectors.
+ * Private function for constructor of TriangleIntersectionList.
+ */
+void TriangleIntersectionList::GatherIntersectionsWithTriangles()
+{
+  Info FunctionInfo(__func__);
+
+  // get closest points
+  boost::scoped_ptr< DistanceToPointMap > points(Tess->FindClosestBoundaryPointsToVector(Point,Vicinity));
+  if (points == NULL) {
+    DoeLog(1) && (eLog()<< Verbose(1) << "There is no nearest point: too far away from the surface." << endl);
+    return;
+  }
+
+  // gather all triangles in *LC-neighbourhood
+  TriangleSet triangles;
+  for (DistanceToPointMap::iterator Runner = points->begin(); Runner != points->end(); Runner++)
+    for (LineMap::iterator LineRunner = Runner->second->lines.begin(); LineRunner != Runner->second->lines.end(); LineRunner++)
+      for (TriangleMap::iterator TriangleRunner = LineRunner->second->triangles.begin(); TriangleRunner != LineRunner->second->triangles.end(); TriangleRunner++)
+        triangles.insert(TriangleRunner->second);
+
+  Vector *Intersection = NULL;
+  for (TriangleSet::const_iterator TriangleRunner = triangles.begin(); TriangleRunner != triangles.end(); TriangleRunner++) {
+    // get intersection with triangle plane
+    Intersection = new Vector;
+    (*TriangleRunner)->GetClosestPointInsideTriangle(Point, Intersection);
+    //Log() << Verbose(1) << "Intersection between " << *Point << " and " << **TriangleRunner << " is at " << *Intersection << "." << endl;
+    IntersectionList.insert( pair<BoundaryTriangleSet *, Vector * > (*TriangleRunner, Intersection) );
+  }
+};
+
+/** Fills the private distance list
+ */
+void TriangleIntersectionList::FillDistanceList() const
+{
+  Info FunctionInfo(__func__);
+  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) );
+
+  //for (DistanceTriangleMap::const_iterator runner = DistanceList.begin(); runner != DistanceList.end(); runner++)
+  //  Log() << Verbose(1) << (*runner).first << " away from " << *(*runner).second << endl;
+};
+
+
+/** Returns the iterator in VectorTriangleMap to the smallest distance.
+ * This is a private helper function as the iterator is then evaluated in some other functions.
+ * \return iterator or TriangleIntersectionList::IntersectionList.end() if none could be found
+ */
+TriangleVectorMap::const_iterator TriangleIntersectionList::GetIteratortoSmallestDistance() const
+{
+  Info FunctionInfo(__func__);
+  FillDistanceList();
+
+  // do we have any intersections?
+  TriangleVectorMap::const_iterator runner;
+  if (!DistanceList.empty()) {
+    // get closest triangle
+    runner = IntersectionList.find(DistanceList.begin()->second);
+  }
+  return runner;
+};
+
Index: src/triangleintersectionlist.hpp
===================================================================
--- src/triangleintersectionlist.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/triangleintersectionlist.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,61 @@
+/*
+ * TriangleIntersectionList.hpp
+ *
+ *  Created on: Mar 1, 2010
+ *      Author: heber
+ */
+
+#ifndef TRIANGLEINTERSECTIONLIST_HPP_
+#define TRIANGLEINTERSECTIONLIST_HPP_
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <map>
+
+/****************************************** forward declarations *****************************/
+
+class BoundaryTriangleSet;
+class LinkedCell;
+class Tesselation;
+class Vector;
+
+/********************************************** definitions *********************************/
+
+#define TriangleVectorMap map < class BoundaryTriangleSet *, Vector *>
+#define DistanceTriangleMap map < double, class BoundaryTriangleSet *>
+
+// ======================================================== class TriangleIntersectionList =======================================
+
+/** Stores all intersection vectors to a list of triangles.
+ */
+class TriangleIntersectionList
+{
+public:
+  TriangleIntersectionList(const Vector *x, const Tesselation *surface, const LinkedCell* LC);
+  ~TriangleIntersectionList();
+
+  double GetSmallestDistance() const;
+  Vector GetClosestIntersection() const;
+  BoundaryTriangleSet * GetClosestTriangle() const;
+  bool IsInside() const;
+
+private:
+  void GatherIntersectionsWithTriangles();
+  TriangleVectorMap::const_iterator GetIteratortoSmallestDistance() const;
+  void FillDistanceList() const;
+
+  const Vector *Point;
+  const Tesselation *Tess;
+  const LinkedCell *Vicinity;
+  TriangleVectorMap IntersectionList;
+  mutable DistanceTriangleMap DistanceList;
+};
+
+#endif /* TRIANGLEINTERSECTIONLIST_HPP_ */
Index: src/types.hpp
===================================================================
--- src/types.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/types.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,21 @@
+/*
+ * types.hpp
+ *
+ *  Created on: Mar 12, 2010
+ *      Author: crueger
+ */
+
+#ifndef TYPES_HPP_
+#define TYPES_HPP_
+
+
+/**
+ *  This file defines some globally used types for later use
+ */
+
+
+typedef unsigned int atomId_t;        //!< The type of atomIds
+typedef unsigned int moleculeId_t;    //!< The type of moleculeIds
+typedef unsigned int atomicNumber_t;  //!< The type of atomicNumbers
+
+#endif /* TYPES_HPP_ */
Index: src/unittests/ActOnAllUnitTest.cpp
===================================================================
--- src/unittests/ActOnAllUnitTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/ActOnAllUnitTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,123 @@
+/*
+ * ActOnAllUnitTest.cpp
+ *
+ *  Created on: 04.10.2009
+ *      Author: FrederikHeber
+ */
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "../test/ActOnAlltest.hpp"
+#include "ActOnAllUnitTest.hpp"
+#include "memoryallocator.hpp"
+#include "vector.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( ActOnAllTest );
+
+
+void ActOnAllTest::setUp()
+{
+  Vector *temp = NULL;
+  // fill list with vectors
+  temp = new Vector(1,0,0);
+  VL.AddVector(temp);
+  temp = new Vector(0,1,0);
+  VL.AddVector(temp);
+  temp = new Vector(0,0,1);
+  VL.AddVector(temp);
+  Ref = VL;
+};
+
+
+void ActOnAllTest::tearDown()
+{
+  VL.EmptyList();
+  // Ref was copy constructed, hence has to be cleaned, too!
+  Ref.EmptyList();
+};
+
+/** UnitTest for VectorList::ActOnAll() and Vector::AddVector(), Vector::SubtractVector(),
+ */
+void ActOnAllTest::AddSubtractTest()
+{
+  const Vector test(1.,0.,0.);
+
+  // adding, subtracting
+  VL.ActOnAll( &Vector::AddVector, test );
+  CPPUNIT_ASSERT_EQUAL( VL == Ref , false );
+  VL.ActOnAll( &Vector::SubtractVector, test );
+  CPPUNIT_ASSERT_EQUAL( VL == Ref , true );
+};
+
+/** UnitTest for VectorList::ActOnAll()
+ */
+void ActOnAllTest::ScaleTest()
+{
+  double factor=2.;
+  double inverse=1./2.;
+
+  // scaling by value
+  VL.ActOnAll( (void (Vector::*)(const double)) &Vector::Scale, factor );
+  CPPUNIT_ASSERT_EQUAL( VL == Ref , false );
+
+  VL.ActOnAll( (void (Vector::*)(const double)) &Vector::Scale, inverse );
+  CPPUNIT_ASSERT_EQUAL( VL == Ref , true );
+
+  // scaling by three values
+  double *factors = new double[NDIM];
+  double *inverses = new double[NDIM];
+  for (int i=0;i<NDIM;++i) {
+    factors[i] = 2.;
+    inverses[i] = 1./factors[i];
+  }
+  VL.ActOnAll<Vector,void,const double*>(&Vector::ScaleAll, factors );
+  CPPUNIT_ASSERT_EQUAL( VL == Ref , false );
+
+  VL.ActOnAll<Vector,void,const double*>(&Vector::ScaleAll, inverses );
+  CPPUNIT_ASSERT_EQUAL( VL == Ref , true );
+  delete[](factors);
+  delete[](inverses);
+};
+
+#if 0
+
+// Unitttest deactivated for now...
+// Reasons:
+//    Vector::MakeNormalVector has been removed and is now part of Plane class
+//    VectorList::ActOnAll is in the test directory and seems to be used only for unittests
+//    MakeNormal never depended on the input Vector except in the case of linear dependence (i.e. failure)
+//
+// TODO: Rethink what exactely is being tested at this point and introduce a new unittest for the
+//       tested behaviour. Most likely this should result in a thourough unittest of the plane class
+
+/** UnitTest for VectorList::ActOnAll() and Vector::MakeNormalVector()
+ */
+void ActOnAllTest::NormalizeTest()
+{
+  const Vector xaxis(1.,0.,0.);
+  const Vector yaxis(0.,1.,0.);
+
+  // normalize with respect to x and y axis
+  bool (Vector::*f)(const Vector *, const Vector *) = &Vector::MakeNormalVector;
+  VL.ActOnAll( f, &xaxis, &yaxis );
+  CPPUNIT_ASSERT_EQUAL( VL == Ref , false );
+
+  // check that x and y components are zero
+  for (ListOfVectors::iterator Runner = VL.Vectors.begin(); Runner != VL.Vectors.end(); Runner++) {
+    CPPUNIT_ASSERT_EQUAL( (*Runner)->at(0) , 0. );
+    CPPUNIT_ASSERT_EQUAL( (*Runner)->at(1) , 0. );
+  }
+};
+
+#endif
Index: src/unittests/ActOnAllUnitTest.hpp
===================================================================
--- src/unittests/ActOnAllUnitTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/ActOnAllUnitTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,41 @@
+/*
+ * ActOnAllUnitTest.hpp
+ *
+ *  Created on: 04.10.2009
+ *      Author: FrederikHeber
+ */
+
+#ifndef ACTONALLUNITTEST_HPP_
+#define ACTONALLUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "../test/ActOnAlltest.hpp"
+
+/********************************************** Test classes **************************************/
+
+class ActOnAllTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( ActOnAllTest) ;
+    CPPUNIT_TEST ( AddSubtractTest );
+    CPPUNIT_TEST ( ScaleTest );
+#if 0
+    // test deactivated. See .cpp for reasons and workarounds
+    CPPUNIT_TEST ( NormalizeTest );
+#endif
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+      void AddSubtractTest();
+      void ScaleTest();
+      void NormalizeTest();
+
+private:
+      class VectorList VL;
+      class VectorList Ref;
+};
+
+
+#endif /* ACTONALLUNITTEST_HPP_ */
Index: src/unittests/ActionSequenceTest.cpp
===================================================================
--- src/unittests/ActionSequenceTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/ActionSequenceTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,231 @@
+/*
+ * ActionSequenzTest.cpp
+ *
+ *  Created on: Dec 17, 2009
+ *      Author: crueger
+ */
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "unittests/ActionSequenceTest.hpp"
+#include "Actions/Action.hpp"
+#include "Actions/ActionSequence.hpp"
+#include "Actions/MakroAction.hpp"
+#include "Actions/ActionHistory.hpp"
+#include "Actions/ActionRegistry.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( ActionSequenceTest );
+
+/* some neccessary stubs for tests */
+class canUndoActionStub : public Action
+{
+public:
+  canUndoActionStub(): Action("canUndoActionStub",false){}
+  virtual ~canUndoActionStub(){}
+
+  virtual Action::state_ptr performCall(){
+    return Action::success;
+  }
+  virtual Action::state_ptr performUndo(Action::state_ptr){
+    return Action::success;
+  }
+  virtual Action::state_ptr performRedo(Action::state_ptr){
+    return Action::success;
+  }
+  virtual bool canUndo(){
+    return true;
+  }
+  virtual bool shouldUndo(){
+    return true;
+  }
+};
+
+class cannotUndoActionStub : public Action
+{
+public:
+  cannotUndoActionStub() : Action("cannotUndoActionStub",false){}
+  virtual ~cannotUndoActionStub(){}
+
+  virtual Action::state_ptr performCall(){
+    return Action::success;
+  }
+  virtual Action::state_ptr performUndo(Action::state_ptr){
+    return Action::success;
+  }
+  virtual Action::state_ptr performRedo(Action::state_ptr){
+    return Action::success;
+  }
+  virtual bool canUndo(){
+    return false;
+  }
+  virtual bool shouldUndo(){
+   return true;
+  }
+};
+
+class wasCalledActionStub : public Action
+{
+public:
+  wasCalledActionStub() :
+      Action("wasCalledActionStub",false),
+      called(false)
+  {}
+  virtual ~wasCalledActionStub(){}
+
+  virtual Action::state_ptr performCall(){
+    called = true;
+    return Action::success;
+  }
+  virtual Action::state_ptr performUndo(Action::state_ptr){
+    called = false;
+    return Action::success;
+  }
+  virtual Action::state_ptr performRedo(Action::state_ptr){
+    called = true;
+    return Action::success;
+  }
+  virtual bool canUndo(){
+    return true;
+  }
+  virtual bool shouldUndo(){
+    return true;
+  }
+  bool wasCalled(){
+    return called;
+  }
+private:
+  bool called;
+};
+
+void ActionSequenceTest::setUp(){
+  ActionHistory::init();
+  // create some necessary stubs used in this test
+  positive1 = new canUndoActionStub();
+  positive2 = new canUndoActionStub();
+  negative1 = new cannotUndoActionStub();
+  negative2 = new cannotUndoActionStub();
+
+  shouldCall1 = new wasCalledActionStub();
+  shouldCall2 = new wasCalledActionStub();
+  shouldNotCall1 = new wasCalledActionStub();
+  shouldNotCall2 = new wasCalledActionStub();
+
+}
+
+void ActionSequenceTest::tearDown(){
+  delete positive1;
+  delete positive2;
+  delete negative1;
+  delete negative2;
+
+  delete shouldCall1;
+  delete shouldCall2;
+  delete shouldNotCall1;
+  delete shouldNotCall2;
+
+  ActionHistory::purgeInstance();
+  ActionRegistry::purgeInstance();
+}
+
+void ActionSequenceTest::canUndoTest(){
+  // first section:
+  {
+    // test some combinations
+    {
+      ActionSequence *sequence = new ActionSequence();
+      sequence->addAction(positive1);
+      sequence->addAction(positive2);
+      CPPUNIT_ASSERT_EQUAL( true, sequence->canUndo() );
+      delete sequence;
+    }
+    {
+      ActionSequence *sequence = new ActionSequence();
+      sequence->addAction(positive1);
+      sequence->addAction(negative2);
+      CPPUNIT_ASSERT_EQUAL( false, sequence->canUndo() );
+      delete sequence;
+    }
+    {
+      ActionSequence *sequence = new ActionSequence();
+      sequence->addAction(negative1);
+      sequence->addAction(positive2);
+      CPPUNIT_ASSERT_EQUAL( false, sequence->canUndo() );
+      delete sequence;
+    }
+    {
+      ActionSequence *sequence = new ActionSequence();
+      sequence->addAction(negative1);
+      sequence->addAction(negative2);
+      CPPUNIT_ASSERT_EQUAL( false, sequence->canUndo() );
+      delete sequence;
+    }
+  }
+
+  // second section:
+  {
+    // empty sequence can be undone
+    ActionSequence *sequence = new ActionSequence();
+    CPPUNIT_ASSERT_EQUAL( true, sequence->canUndo() );
+    // if only a positive action is contained it can be undone
+    sequence->addAction(positive1);
+    CPPUNIT_ASSERT_EQUAL( true, sequence->canUndo() );
+    // the single negative action should block the process
+    sequence->addAction(negative1);
+    CPPUNIT_ASSERT_EQUAL( false, sequence->canUndo() );
+    // after removing the negative action all is well again
+    sequence->removeLastAction();
+    CPPUNIT_ASSERT_EQUAL( true, sequence->canUndo() );
+    delete sequence;
+  }
+}
+
+void ActionSequenceTest::doesCallTest(){
+  ActionSequence *sequence = new ActionSequence();
+  sequence->addAction(shouldCall1);
+  sequence->addAction(shouldCall2);
+  sequence->addAction(shouldNotCall1);
+  sequence->addAction(shouldNotCall2);
+  sequence->removeLastAction();
+  sequence->removeLastAction();
+
+  sequence->callAll();
+
+  CPPUNIT_ASSERT_EQUAL(true,shouldCall1->wasCalled());
+  CPPUNIT_ASSERT_EQUAL(true,shouldCall2->wasCalled());
+  CPPUNIT_ASSERT_EQUAL(false,shouldNotCall1->wasCalled());
+  CPPUNIT_ASSERT_EQUAL(false,shouldNotCall2->wasCalled());
+
+  delete sequence;
+}
+
+void ActionSequenceTest::doesUndoTest(){
+  ActionSequence *sequence = new ActionSequence();
+  wasCalledActionStub *wasCalled1 = new wasCalledActionStub();
+  wasCalledActionStub *wasCalled2 = new wasCalledActionStub();
+  sequence->addAction(wasCalled1);
+  sequence->addAction(wasCalled2);
+
+  MakroAction act("Test MakroAction",sequence,false);
+
+  act.call();
+
+  CPPUNIT_ASSERT_EQUAL(true,wasCalled1->wasCalled());
+  CPPUNIT_ASSERT_EQUAL(true,wasCalled1->wasCalled());
+
+  ActionHistory::getInstance().undoLast();
+
+  CPPUNIT_ASSERT_EQUAL(false,wasCalled1->wasCalled());
+  CPPUNIT_ASSERT_EQUAL(false,wasCalled1->wasCalled());
+
+}
+
+
Index: src/unittests/ActionSequenceTest.hpp
===================================================================
--- src/unittests/ActionSequenceTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/ActionSequenceTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,43 @@
+/*
+ * ActionSequenzTest.hpp
+ *
+ *  Created on: Dec 17, 2009
+ *      Author: crueger
+ */
+
+#ifndef ACTIONSEQUENZTEST_HPP_
+#define ACTIONSEQUENZTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class Action;
+class wasCalledActionStub;
+
+class ActionSequenceTest :  public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( ActionSequenceTest) ;
+  CPPUNIT_TEST ( canUndoTest );
+  CPPUNIT_TEST ( doesCallTest );
+  CPPUNIT_TEST ( doesUndoTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void canUndoTest();
+  void doesCallTest();
+  void doesUndoTest();
+
+private:
+  Action *positive1;
+  Action *positive2;
+  Action *negative1;
+  Action *negative2;
+  wasCalledActionStub* shouldCall1;
+  wasCalledActionStub* shouldCall2;
+  wasCalledActionStub* shouldNotCall1;
+  wasCalledActionStub* shouldNotCall2;
+};
+
+#endif /* ACTIONSEQUENZTEST_HPP_ */
Index: src/unittests/AnalysisCorrelationToPointUnitTest.cpp
===================================================================
--- src/unittests/AnalysisCorrelationToPointUnitTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/AnalysisCorrelationToPointUnitTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,133 @@
+/*
+ * AnalysisCorrelationToPointUnitTest.cpp
+ *
+ *  Created on: Oct 13, 2009
+ *      Author: heber
+ */
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <cstring>
+
+#include "analysis_correlation.hpp"
+#include "AnalysisCorrelationToPointUnitTest.hpp"
+
+#include "atom.hpp"
+#include "element.hpp"
+#include "molecule.hpp"
+#include "linkedcell.hpp"
+#include "periodentafel.hpp"
+#include "World.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( AnalysisCorrelationToPointUnitTest );
+
+void AnalysisCorrelationToPointUnitTest::setUp()
+{
+  atom *Walker = NULL;
+
+  // init private all pointers to zero
+  TestList = NULL;
+  TestMolecule = NULL;
+  pointmap = NULL;
+  binmap = NULL;
+  point = NULL;
+
+  // construct element list
+  std::vector<element *> elements;
+  hydrogen = World::getInstance().getPeriode()->FindElement(1);
+  CPPUNIT_ASSERT(hydrogen != NULL && "hydrogen element not found");
+  elements.push_back(hydrogen);
+  // construct molecule (tetraeder of hydrogens)
+  TestMolecule = World::getInstance().createMolecule();
+  Walker = World::getInstance().createAtom();
+  Walker->type = hydrogen;
+  *Walker->node = Vector(1., 0., 1. );
+  TestMolecule->AddAtom(Walker);
+  Walker = World::getInstance().createAtom();
+  Walker->type = hydrogen;
+  *Walker->node = Vector(0., 1., 1. );
+  TestMolecule->AddAtom(Walker);
+  Walker = World::getInstance().createAtom();
+  Walker->type = hydrogen;
+  *Walker->node = Vector(1., 1., 0. );
+  TestMolecule->AddAtom(Walker);
+  Walker = World::getInstance().createAtom();
+  Walker->type = hydrogen;
+  *Walker->node = Vector(0., 0., 0. );
+  TestMolecule->AddAtom(Walker);
+
+  // check that TestMolecule was correctly constructed
+  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 );
+
+  TestList = World::getInstance().getMolecules();
+  TestList->insert(TestMolecule);
+  TestMolecule->ActiveFlag = true;
+
+  // init point
+  point = new Vector(1.,1.,1.);
+
+  // init maps
+  pointmap = CorrelationToPoint( (MoleculeListClass * const)TestList, elements, (const Vector *)point );
+  binmap = NULL;
+
+};
+
+
+void AnalysisCorrelationToPointUnitTest::tearDown()
+{
+  if (pointmap != NULL)
+    delete(pointmap);
+  if (binmap != NULL)
+    delete(binmap);
+
+  delete(point);
+  World::purgeInstance();
+  logger::purgeInstance();
+};
+
+void AnalysisCorrelationToPointUnitTest::CorrelationToPointTest()
+{
+  // do the pair correlation
+  CPPUNIT_ASSERT( pointmap != NULL );
+  CPPUNIT_ASSERT_EQUAL( (size_t)4, pointmap->size() );
+
+};
+
+void AnalysisCorrelationToPointUnitTest::CorrelationToPointBinNoRangeTest()
+{
+  BinPairMap::iterator tester;
+  // put pair correlation into bins and check with no range
+  binmap = BinData( pointmap, 0.5, 0., 0. );
+  OutputCorrelation ( (ofstream *)&cout, binmap );
+  CPPUNIT_ASSERT_EQUAL( (size_t)3, binmap->size() );
+  tester = binmap->begin();
+  CPPUNIT_ASSERT_EQUAL( 1., tester->first );
+  CPPUNIT_ASSERT_EQUAL( 3, tester->second );
+
+};
+
+void AnalysisCorrelationToPointUnitTest::CorrelationToPointBinRangeTest()
+{
+  BinPairMap::iterator tester;
+  // ... and check with [0., 2.] range
+  binmap = BinData( pointmap, 0.5, 0., 2. );
+  OutputCorrelation ( (ofstream *)&cout, binmap );
+  CPPUNIT_ASSERT_EQUAL( (size_t)5, binmap->size() );
+  tester = binmap->begin();
+  CPPUNIT_ASSERT_EQUAL( 0., tester->first );
+  tester = binmap->find(1.);
+  CPPUNIT_ASSERT_EQUAL( 1., tester->first );
+  CPPUNIT_ASSERT_EQUAL( 3, tester->second );
+
+};
Index: src/unittests/AnalysisCorrelationToPointUnitTest.hpp
===================================================================
--- src/unittests/AnalysisCorrelationToPointUnitTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/AnalysisCorrelationToPointUnitTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,46 @@
+/*
+ * AnalysisCorrelationToPointUnitTest.hpp
+ *
+ *  Created on: Oct 13, 2009
+ *      Author: heber
+ */
+
+#ifndef ANALYSISCORRELATIONTOPOINTUNITTEST_HPP_
+#define ANALYSISCORRELATIONTOPOINTUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class element;
+class molecule;
+class MoleculeListClass;
+class Vector;
+
+/********************************************** Test classes **************************************/
+
+class AnalysisCorrelationToPointUnitTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( AnalysisCorrelationToPointUnitTest ) ;
+    CPPUNIT_TEST ( CorrelationToPointTest );
+    CPPUNIT_TEST ( CorrelationToPointBinNoRangeTest );
+    CPPUNIT_TEST ( CorrelationToPointBinRangeTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+      void CorrelationToPointTest();
+      void CorrelationToPointBinNoRangeTest();
+      void CorrelationToPointBinRangeTest();
+
+private:
+
+      MoleculeListClass *TestList;
+      molecule *TestMolecule;
+      element *hydrogen;
+
+      CorrelationToPointMap *pointmap;
+      BinPairMap *binmap;
+      Vector *point;
+};
+
+#endif /* ANALYSISCORRELATIONTOPOINTUNITTEST_HPP_ */
Index: src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
===================================================================
--- src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,237 @@
+/*
+ * AnalysisCorrelationToSurfaceUnitTest.cpp
+ *
+ *  Created on: Oct 13, 2009
+ *      Author: heber
+ */
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <cstring>
+
+#include "analysis_correlation.hpp"
+#include "AnalysisCorrelationToSurfaceUnitTest.hpp"
+
+#include "atom.hpp"
+#include "boundary.hpp"
+#include "element.hpp"
+#include "molecule.hpp"
+#include "linkedcell.hpp"
+#include "periodentafel.hpp"
+#include "tesselation.hpp"
+#include "World.hpp"
+#include "Helpers/Assert.hpp"
+
+#include "Helpers/Assert.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( AnalysisCorrelationToSurfaceUnitTest );
+
+void AnalysisCorrelationToSurfaceUnitTest::setUp()
+{
+  ASSERT_DO(Assert::Throw);
+
+  atom *Walker = NULL;
+
+  // init private all pointers to zero
+  TestList = NULL;
+  TestSurfaceMolecule = NULL;
+  surfacemap = NULL;
+  binmap = NULL;
+  Surface = NULL;
+  LC = NULL;
+
+  // prepare element list
+  hydrogen = World::getInstance().getPeriode()->FindElement(1);
+  CPPUNIT_ASSERT(hydrogen != NULL && "hydrogen element not found");
+  elements.clear();
+
+  // construct molecule (tetraeder of hydrogens) base
+  TestSurfaceMolecule = World::getInstance().createMolecule();
+
+  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. );
+  TestSurfaceMolecule->AddAtom(Walker);
+
+  // check that TestMolecule was correctly constructed
+  CPPUNIT_ASSERT_EQUAL( TestSurfaceMolecule->getAtomCount(), 4 );
+
+  TestList = World::getInstance().getMolecules();
+  TestSurfaceMolecule->ActiveFlag = true;
+  TestList->insert(TestSurfaceMolecule);
+
+  // init tesselation and linked cell
+  Surface = new Tesselation;
+  LC = new LinkedCell(TestSurfaceMolecule, 5.);
+  FindNonConvexBorder(TestSurfaceMolecule, Surface, (const LinkedCell *&)LC, 2.5, NULL);
+
+  // add outer atoms
+  carbon = World::getInstance().getPeriode()->FindElement(6);
+  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. );
+  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);
+
+  // init maps
+  surfacemap = NULL;
+  binmap = NULL;
+
+};
+
+
+void AnalysisCorrelationToSurfaceUnitTest::tearDown()
+{
+  if (surfacemap != NULL)
+    delete(surfacemap);
+  if (binmap != NULL)
+    delete(binmap);
+
+  delete(Surface);
+  // note that all the atoms are cleaned by TestMolecule
+  delete(LC);
+  World::purgeInstance();
+  logger::purgeInstance();
+};
+
+
+/** Checks whether setup() does the right thing.
+ */
+void AnalysisCorrelationToSurfaceUnitTest::SurfaceTest()
+{
+  CPPUNIT_ASSERT_EQUAL( 4, TestSurfaceMolecule->getAtomCount() );
+  CPPUNIT_ASSERT_EQUAL( (size_t)2, TestList->ListOfMolecules.size() );
+  CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() );
+  CPPUNIT_ASSERT_EQUAL( (size_t)6, Surface->LinesOnBoundary.size() );
+  CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->TrianglesOnBoundary.size() );
+};
+
+void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceTest()
+{
+  // do the pair correlation
+  elements.push_back(hydrogen);
+  surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );
+//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
+  CPPUNIT_ASSERT( surfacemap != NULL );
+  CPPUNIT_ASSERT_EQUAL( (size_t)4, surfacemap->size() );
+};
+
+void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceHydrogenBinNoRangeTest()
+{
+  BinPairMap::iterator tester;
+  elements.push_back(hydrogen);
+  surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );
+  // put pair correlation into bins and check with no range
+//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
+  binmap = BinData( surfacemap, 0.5, 0., 0. );
+  CPPUNIT_ASSERT_EQUAL( (size_t)1, binmap->size() );
+  OutputCorrelation ( (ofstream *)&cout, binmap );
+  tester = binmap->begin();
+  CPPUNIT_ASSERT_EQUAL( 0., tester->first );
+  CPPUNIT_ASSERT_EQUAL( 4, tester->second );
+
+};
+
+void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceHydrogenBinRangeTest()
+{
+  BinPairMap::iterator tester;
+  elements.push_back(hydrogen);
+  surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );
+//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
+  // ... and check with [0., 2.] range
+  binmap = BinData( surfacemap, 0.5, 0., 2. );
+  CPPUNIT_ASSERT_EQUAL( (size_t)5, binmap->size() );
+//  OutputCorrelation ( (ofstream *)&cout, binmap );
+  tester = binmap->begin();
+  CPPUNIT_ASSERT_EQUAL( 0., tester->first );
+  CPPUNIT_ASSERT_EQUAL( 4, tester->second );
+  tester = binmap->find(1.);
+  CPPUNIT_ASSERT_EQUAL( 1., tester->first );
+  CPPUNIT_ASSERT_EQUAL( 0, tester->second );
+
+};
+
+void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceCarbonBinNoRangeTest()
+{
+  BinPairMap::iterator tester;
+  elements.push_back(carbon);
+  surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );
+//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
+  // put pair correlation into bins and check with no range
+  binmap = BinData( surfacemap, 0.5, 0., 0. );
+  //OutputCorrelation ( (ofstream *)&cout, binmap );
+  CPPUNIT_ASSERT_EQUAL( (size_t)9, binmap->size() );
+  // inside point is first and must have negative value
+  tester = binmap->lower_bound(4.25-0.5); // start depends on the min value and
+  CPPUNIT_ASSERT( tester != binmap->end() );
+  CPPUNIT_ASSERT_EQUAL( 3, tester->second );
+  // inner point
+  tester = binmap->lower_bound(0.);
+  CPPUNIT_ASSERT( tester != binmap->end() );
+  CPPUNIT_ASSERT_EQUAL( 1, tester->second );
+};
+
+void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceCarbonBinRangeTest()
+{
+  BinPairMap::iterator tester;
+  elements.push_back(carbon);
+  surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );
+//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
+  // ... and check with [0., 2.] range
+  binmap = BinData( surfacemap, 0.5, -2., 4. );
+  //OutputCorrelation ( (ofstream *)&cout, binmap );
+  CPPUNIT_ASSERT_EQUAL( (size_t)13, binmap->size() );
+  // three outside points
+  tester = binmap->lower_bound(4.25-0.5);
+  CPPUNIT_ASSERT( tester != binmap->end() );
+  CPPUNIT_ASSERT_EQUAL( 3, tester->second );
+  // inner point
+  tester = binmap->lower_bound(0.);
+  CPPUNIT_ASSERT( tester != binmap->end() );
+  CPPUNIT_ASSERT_EQUAL( 1, tester->second );
+};
Index: src/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp
===================================================================
--- src/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,57 @@
+/*
+ * AnalysisCorrelationToSurfaceUnitTest.hpp
+ *
+ *  Created on: Oct 13, 2009
+ *      Author: heber
+ */
+
+#ifndef ANALYSISCORRELATIONTOSURFACEUNITTEST_HPP_
+#define ANALYSISCORRELATIONTOSURFACEUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class element;
+class LinkedCell;
+class molecule;
+class MoleculeListClass;
+class periodentafel;
+class Tesselation;
+
+/********************************************** Test classes **************************************/
+
+class AnalysisCorrelationToSurfaceUnitTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( AnalysisCorrelationToSurfaceUnitTest ) ;
+    CPPUNIT_TEST ( SurfaceTest );
+    CPPUNIT_TEST ( CorrelationToSurfaceTest );
+    CPPUNIT_TEST ( CorrelationToSurfaceHydrogenBinNoRangeTest );
+    CPPUNIT_TEST ( CorrelationToSurfaceHydrogenBinRangeTest );
+    CPPUNIT_TEST ( CorrelationToSurfaceCarbonBinNoRangeTest );
+    CPPUNIT_TEST ( CorrelationToSurfaceCarbonBinRangeTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+      void SurfaceTest();
+      void CorrelationToSurfaceTest();
+      void CorrelationToSurfaceHydrogenBinNoRangeTest();
+      void CorrelationToSurfaceHydrogenBinRangeTest();
+      void CorrelationToSurfaceCarbonBinNoRangeTest();
+      void CorrelationToSurfaceCarbonBinRangeTest();
+
+private:
+
+      MoleculeListClass *TestList;
+      molecule *TestSurfaceMolecule;
+      element *hydrogen;
+      element *carbon;
+      std::vector<element *> elements;
+
+      CorrelationToSurfaceMap *surfacemap;
+      BinPairMap *binmap;
+      Tesselation *Surface;
+      LinkedCell *LC;
+};
+
+#endif /* ANALYSISCORRELATIONTOSURFACEUNITTEST_HPP_ */
Index: src/unittests/AnalysisPairCorrelationUnitTest.cpp
===================================================================
--- src/unittests/AnalysisPairCorrelationUnitTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/AnalysisPairCorrelationUnitTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,133 @@
+/*
+ * AnalysisPairCorrelationUnitTest.cpp
+ *
+ *  Created on: Oct 13, 2009
+ *      Author: heber
+ */
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <cstring>
+
+#include "analysis_correlation.hpp"
+#include "AnalysisPairCorrelationUnitTest.hpp"
+
+#include "World.hpp"
+#include "atom.hpp"
+#include "boundary.hpp"
+#include "element.hpp"
+#include "molecule.hpp"
+#include "linkedcell.hpp"
+#include "periodentafel.hpp"
+#include "tesselation.hpp"
+#include "World.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( AnalysisPairCorrelationUnitTest );
+
+
+void AnalysisPairCorrelationUnitTest::setUp()
+{
+  atom *Walker = NULL;
+
+  // init private all pointers to zero
+  TestList = NULL;
+  TestMolecule = NULL;
+  correlationmap = NULL;
+  binmap = NULL;
+
+  // construct element list
+  std::vector<element *> elements;
+  hydrogen = World::getInstance().getPeriode()->FindElement(1);
+  CPPUNIT_ASSERT(hydrogen != NULL && "hydrogen element not found");
+  elements.push_back(hydrogen);
+  elements.push_back(hydrogen);
+
+  // construct molecule (tetraeder of hydrogens)
+  TestMolecule = World::getInstance().createMolecule();
+  Walker = World::getInstance().createAtom();
+  Walker->type = hydrogen;
+  *Walker->node = Vector(1., 0., 1. );
+  TestMolecule->AddAtom(Walker);
+  Walker = World::getInstance().createAtom();
+  Walker->type = hydrogen;
+  *Walker->node = Vector(0., 1., 1. );
+  TestMolecule->AddAtom(Walker);
+  Walker = World::getInstance().createAtom();
+  Walker->type = hydrogen;
+  *Walker->node = Vector(1., 1., 0. );
+  TestMolecule->AddAtom(Walker);
+  Walker = World::getInstance().createAtom();
+  Walker->type = hydrogen;
+  *Walker->node = Vector(0., 0., 0. );
+  TestMolecule->AddAtom(Walker);
+
+  // check that TestMolecule was correctly constructed
+  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 );
+
+  TestList = World::getInstance().getMolecules();
+  TestMolecule->ActiveFlag = true;
+  TestList->insert(TestMolecule);
+
+  // init maps
+  correlationmap = PairCorrelation( TestList, elements);
+  binmap = NULL;
+
+};
+
+
+void AnalysisPairCorrelationUnitTest::tearDown()
+{
+  if (correlationmap != NULL)
+    delete(correlationmap);
+  if (binmap != NULL)
+    delete(binmap);
+
+  // note that all the atoms are cleaned by TestMolecule
+  World::purgeInstance();
+  logger::purgeInstance();
+  errorLogger::purgeInstance();
+};
+
+void AnalysisPairCorrelationUnitTest::PairCorrelationTest()
+{
+  // do the pair correlation
+  CPPUNIT_ASSERT( correlationmap != NULL );
+  CPPUNIT_ASSERT_EQUAL( (size_t)6, correlationmap->size() );
+};
+
+void AnalysisPairCorrelationUnitTest::PairCorrelationBinNoRangeTest()
+{
+  BinPairMap::iterator tester;
+  // put pair correlation into bins and check with no range
+  binmap = BinData( correlationmap, 0.5, 0., 0. );
+  CPPUNIT_ASSERT_EQUAL( (size_t)1, binmap->size() );
+  //OutputCorrelation ( binmap );
+  tester = binmap->begin();
+  CPPUNIT_ASSERT_EQUAL( sqrt(2.), tester->first );
+  CPPUNIT_ASSERT_EQUAL( 6, tester->second );
+};
+
+void AnalysisPairCorrelationUnitTest::PairCorrelationBinRangeTest()
+{
+  BinPairMap::iterator tester;
+  // ... and check with [0., 2.] range
+  binmap = BinData( correlationmap, 0.5, 0., 2. );
+  CPPUNIT_ASSERT_EQUAL( (size_t)5, binmap->size() );
+  //OutputCorrelation ( binmap );
+  tester = binmap->begin();
+  CPPUNIT_ASSERT_EQUAL( 0., tester->first );
+  tester = binmap->find(1.);
+  CPPUNIT_ASSERT_EQUAL( 1., tester->first );
+  CPPUNIT_ASSERT_EQUAL( 6, tester->second );
+};
Index: src/unittests/AnalysisPairCorrelationUnitTest.hpp
===================================================================
--- src/unittests/AnalysisPairCorrelationUnitTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/AnalysisPairCorrelationUnitTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,45 @@
+/*
+ * AnalysisPairCorrelationUnitTest.hpp
+ *
+ *  Created on: Oct 13, 2009
+ *      Author: heber
+ */
+
+#ifndef ANALYSISPAIRCORRELATIONUNITTEST_HPP_
+#define ANALYSISPAIRCORRELATIONUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class element;
+class molecule;
+class MoleculeListClass;
+class Vector;
+
+/********************************************** Test classes **************************************/
+
+class AnalysisPairCorrelationUnitTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( AnalysisPairCorrelationUnitTest ) ;
+    CPPUNIT_TEST ( PairCorrelationTest );
+    CPPUNIT_TEST ( PairCorrelationBinNoRangeTest );
+    CPPUNIT_TEST ( PairCorrelationBinRangeTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+      void PairCorrelationTest();
+      void PairCorrelationBinNoRangeTest();
+      void PairCorrelationBinRangeTest();
+
+private:
+
+      MoleculeListClass *TestList;
+      molecule *TestMolecule;
+      element *hydrogen;
+
+      PairCorrelationMap *correlationmap;
+      BinPairMap *binmap;
+};
+
+#endif /* ANALYSISPAIRCORRELATIONUNITTEST_HPP_ */
Index: src/unittests/AtomDescriptorTest.cpp
===================================================================
--- src/unittests/AtomDescriptorTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/AtomDescriptorTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,157 @@
+/*
+ * DescriptorUnittest.cpp
+ *
+ *  Created on: Feb 9, 2010
+ *      Author: crueger
+ */
+
+#include "AtomDescriptorTest.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include <iostream>
+
+#include <Descriptors/AtomDescriptor.hpp>
+#include <Descriptors/AtomIdDescriptor.hpp>
+
+#include "World.hpp"
+#include "atom.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( AtomDescriptorTest );
+
+// set up and tear down
+void AtomDescriptorTest::setUp(){
+  World::getInstance();
+  for(int i=0;i<ATOM_COUNT;++i){
+    atoms[i]= World::getInstance().createAtom();
+    atomIds[i]= atoms[i]->getId();
+  }
+}
+
+void AtomDescriptorTest::tearDown(){
+  World::purgeInstance();
+}
+
+// some helper functions
+static bool hasAllAtoms(std::vector<atom*> atoms,atomId_t ids[ATOM_COUNT], std::set<atomId_t> excluded = std::set<atomId_t>()){
+  for(int i=0;i<ATOM_COUNT;++i){
+    atomId_t id = ids[i];
+    if(!excluded.count(id)){
+      std::vector<atom*>::iterator iter;
+      bool res=false;
+      for(iter=atoms.begin();iter!=atoms.end();++iter){
+        res |= (*iter)->getId() == id;
+      }
+      if(!res) {
+        cout << "Atom " << id << " missing in returned list" << endl;
+        return false;
+      }
+    }
+  }
+  return true;
+}
+
+static bool hasNoDuplicateAtoms(std::vector<atom*> atoms){
+  std::set<atomId_t> found;
+  std::vector<atom*>::iterator iter;
+  for(iter=atoms.begin();iter!=atoms.end();++iter){
+    int id = (*iter)->getId();
+    if(found.count(id))
+      return false;
+    found.insert(id);
+  }
+  return true;
+}
+
+
+void AtomDescriptorTest::AtomBaseSetsTest(){
+  std::vector<atom*> allAtoms = World::getInstance().getAllAtoms(AllAtoms());
+  CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(allAtoms,atomIds));
+  CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(allAtoms));
+
+  std::vector<atom*> noAtoms = World::getInstance().getAllAtoms(NoAtoms());
+  CPPUNIT_ASSERT_EQUAL( true , noAtoms.empty());
+}
+void AtomDescriptorTest::AtomIdTest(){
+  // test Atoms from boundaries and middle of the set
+  atom* testAtom;
+  testAtom = World::getInstance().getAtom(AtomById(atomIds[0]));
+  CPPUNIT_ASSERT(testAtom);
+  CPPUNIT_ASSERT_EQUAL( atomIds[0], testAtom->getId());
+  testAtom = World::getInstance().getAtom(AtomById(atomIds[ATOM_COUNT/2]));
+  CPPUNIT_ASSERT(testAtom);
+  CPPUNIT_ASSERT_EQUAL( atomIds[ATOM_COUNT/2], testAtom->getId());
+  testAtom = World::getInstance().getAtom(AtomById(atomIds[ATOM_COUNT-1]));
+  CPPUNIT_ASSERT(testAtom);
+  CPPUNIT_ASSERT_EQUAL( atomIds[ATOM_COUNT-1], testAtom->getId());
+
+  // find some ID that has not been created
+  atomId_t outsideId=0;
+  bool res = false;
+  for(outsideId=0;!res;++outsideId) {
+    res = true;
+    for(int i = 0; i < ATOM_COUNT; ++i){
+      res &= atomIds[i]!=outsideId;
+    }
+  }
+  // test from outside of set
+  testAtom = World::getInstance().getAtom(AtomById(outsideId));
+  CPPUNIT_ASSERT(!testAtom);
+}
+void AtomDescriptorTest::AtomCalcTest(){
+  // test some elementary set operations
+  {
+    std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(AllAtoms()||NoAtoms());
+    CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(testAtoms,atomIds));
+    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(testAtoms));
+  }
+
+  {
+    std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(NoAtoms()||AllAtoms());
+    CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(testAtoms,atomIds));
+    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(testAtoms));
+  }
+
+  {
+    std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(NoAtoms()&&AllAtoms());
+    CPPUNIT_ASSERT_EQUAL( true , testAtoms.empty());
+  }
+
+  {
+    std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(AllAtoms()&&NoAtoms());
+    CPPUNIT_ASSERT_EQUAL( true , testAtoms.empty());
+  }
+
+  {
+    std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(!AllAtoms());
+    CPPUNIT_ASSERT_EQUAL( true , testAtoms.empty());
+  }
+
+  {
+    std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(!NoAtoms());
+    CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(testAtoms,atomIds));
+    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(testAtoms));
+  }
+  // exclude and include some atoms
+  {
+    std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(AllAtoms()&&(!AtomById(atomIds[ATOM_COUNT/2])));
+    std::set<atomId_t> excluded;
+    excluded.insert(atomIds[ATOM_COUNT/2]);
+    CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(testAtoms,atomIds,excluded));
+    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(testAtoms));
+    CPPUNIT_ASSERT_EQUAL( (size_t)(ATOM_COUNT-1), testAtoms.size());
+  }
+
+  {
+    std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(NoAtoms()||(AtomById(atomIds[ATOM_COUNT/2])));
+    CPPUNIT_ASSERT_EQUAL( (size_t)1, testAtoms.size());
+    CPPUNIT_ASSERT_EQUAL( atomIds[ATOM_COUNT/2], testAtoms[0]->getId());
+  }
+}
Index: src/unittests/AtomDescriptorTest.hpp
===================================================================
--- src/unittests/AtomDescriptorTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/AtomDescriptorTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,40 @@
+/*
+ * AtomDescriptorTest.hpp
+ *
+ *  Created on: Feb 9, 2010
+ *      Author: crueger
+ */
+
+#ifndef ATOMDESCRIPTORTEST_HPP_
+#define ATOMDESCRIPTORTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "types.hpp"
+
+#define ATOM_COUNT (10)
+
+class atom;
+
+class AtomDescriptorTest : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( AtomDescriptorTest );
+  CPPUNIT_TEST ( AtomBaseSetsTest );
+  CPPUNIT_TEST ( AtomIdTest );
+  CPPUNIT_TEST ( AtomCalcTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void AtomBaseSetsTest();
+  void AtomIdTest();
+  void AtomCalcTest();
+
+private:
+  atom *atoms [ATOM_COUNT];
+  atomId_t atomIds [ATOM_COUNT];
+};
+
+#endif /* ATOMDESCRIPTORTEST_HPP_ */
Index: src/unittests/CacheableTest.cpp
===================================================================
--- src/unittests/CacheableTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/CacheableTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,91 @@
+/*
+ * CacheableTest.cpp
+ *
+ *  Created on: Feb 2, 2010
+ *      Author: crueger
+ */
+
+#include "CacheableTest.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <boost/bind.hpp>
+
+#include "Patterns/Cacheable.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( CacheableTest );
+
+class threeNumbers : public Observable {
+public:
+  int x;
+  int y;
+  int z;
+  Cacheable<int> sum;
+  bool hasRecalced;
+
+  void setX(int _x){
+    OBSERVE;
+    x = _x;
+  }
+
+  void setY
+  (int _y){
+    OBSERVE;
+    y = _y;
+  }
+
+  void setZ(int _z){
+    OBSERVE;
+    z = _z;
+  }
+
+  int calcSum(){
+    hasRecalced = true;
+    return x+y+z;
+  }
+
+  threeNumbers(int _x,int _y, int _z) :
+    Observable("threeNumbers"),
+    x(_x),y(_y),z(_z),
+    sum(this,boost::bind(&threeNumbers::calcSum,this),"sum"),
+    hasRecalced(false)
+  {}
+};
+
+
+
+
+void CacheableTest::setUp(){
+  numbers = new threeNumbers(1,2,3);
+}
+
+void CacheableTest::tearDown(){
+  delete numbers;
+}
+
+void CacheableTest::doesRecalcTest()
+{
+  CPPUNIT_ASSERT_EQUAL( 6, *(numbers->sum));
+  CPPUNIT_ASSERT_EQUAL( true, numbers->hasRecalced);
+  numbers->hasRecalced=false;
+  numbers->setX(4);
+  CPPUNIT_ASSERT_EQUAL( false, numbers->hasRecalced);
+  CPPUNIT_ASSERT_EQUAL( 9, *(numbers->sum));
+  CPPUNIT_ASSERT_EQUAL( true, numbers->hasRecalced);
+  numbers->hasRecalced=false;
+  CPPUNIT_ASSERT_EQUAL( 9, *(numbers->sum));
+#ifndef NO_CACHING
+  CPPUNIT_ASSERT_EQUAL( false, numbers->hasRecalced);
+#else
+  CPPUNIT_ASSERT_EQUAL( true, numbers->hasRecalced);
+#endif
+}
Index: src/unittests/CacheableTest.hpp
===================================================================
--- src/unittests/CacheableTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/CacheableTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,31 @@
+/*
+ * CacheableTest.hpp
+ *
+ *  Created on: Feb 2, 2010
+ *      Author: crueger
+ */
+
+#ifndef CACHEABLETEST_HPP_
+#define CACHEABLETEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+
+// stub classes
+class threeNumbers;
+
+class CacheableTest :  public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( CacheableTest );
+  CPPUNIT_TEST ( doesRecalcTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void doesRecalcTest();
+  threeNumbers *numbers;
+};
+
+#endif /* CACHEABLETEST_HPP_ */
Index: src/unittests/CountBondsUnitTest.cpp
===================================================================
--- src/unittests/CountBondsUnitTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/CountBondsUnitTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,227 @@
+/*
+ * CountBondsUnitTest.cpp
+ *
+ *  Created on: Mar 30, 2010
+ *      Author: heber
+ */
+
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <iostream>
+#include <stdio.h>
+#include <cstring>
+
+#include "Helpers/Assert.hpp"
+
+#include "analysis_bonds.hpp"
+#include "atom.hpp"
+#include "bond.hpp"
+#include "bondgraph.hpp"
+#include "element.hpp"
+#include "molecule.hpp"
+#include "periodentafel.hpp"
+#include "World.hpp"
+#include "CountBondsUnitTest.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( CountBondsTest );
+
+
+void CountBondsTest::setUp()
+{
+  atom *Walker = NULL;
+
+  // construct element
+  hydrogen = World::getInstance().getPeriode()->FindElement(1);
+  oxygen = World::getInstance().getPeriode()->FindElement(8);
+  CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen");
+  CPPUNIT_ASSERT(oxygen != NULL && "could not find element oxygen");
+
+  // construct molecule (water molecule)
+  TestMolecule1 = World::getInstance().createMolecule();
+  CPPUNIT_ASSERT(TestMolecule1 != NULL && "could not create first molecule");
+  Walker = World::getInstance().createAtom();
+  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
+  Walker->type = hydrogen;
+  *Walker->node = 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. );
+  TestMolecule1->AddAtom(Walker);
+  Walker = World::getInstance().createAtom();
+  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
+  Walker->type = oxygen;
+  *Walker->node = Vector(0., 0., 0. );
+  TestMolecule1->AddAtom(Walker);
+
+  TestMolecule2 = World::getInstance().createMolecule();
+  CPPUNIT_ASSERT(TestMolecule2 != NULL && "could not create second molecule");
+  Walker = World::getInstance().createAtom();
+  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
+  Walker->type = hydrogen;
+  *Walker->node = 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. );
+  TestMolecule2->AddAtom(Walker);
+  Walker = World::getInstance().createAtom();
+  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
+  Walker->type = oxygen;
+  *Walker->node = Vector(0., 0., 0. );
+  TestMolecule2->AddAtom(Walker);
+
+  molecules = World::getInstance().getMolecules();
+  CPPUNIT_ASSERT(molecules != NULL && "could not obtain list of molecules");
+  molecules->insert(TestMolecule1);
+  molecules->insert(TestMolecule2);
+
+  // check that TestMolecule was correctly constructed
+  CPPUNIT_ASSERT_EQUAL( TestMolecule1->getAtomCount(), 3 );
+  CPPUNIT_ASSERT_EQUAL( TestMolecule2->getAtomCount(), 3 );
+
+  // create a small file with table
+  BG = new BondGraph(true);
+  CPPUNIT_ASSERT(BG != NULL && "could not create BondGraph");
+
+  // construct bond graphs
+  CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule1) );
+  CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule2) );
+//  TestMolecule1->Output((ofstream *)&cout);
+//  TestMolecule1->OutputBondsList();
+};
+
+
+void CountBondsTest::tearDown()
+{
+  // remove the file
+  delete(BG);
+
+  World::purgeInstance();
+};
+
+/** UnitTest for CountBondsTest::BondsOfTwoTest().
+ */
+void CountBondsTest::BondsOfTwoTest()
+{
+  CPPUNIT_ASSERT_EQUAL( 4 , CountBondsOfTwo(molecules, hydrogen, oxygen) );
+  CPPUNIT_ASSERT_EQUAL( 0 , CountBondsOfTwo(molecules, hydrogen, hydrogen) );
+  CPPUNIT_ASSERT_EQUAL( 0 , CountBondsOfTwo(molecules, oxygen, oxygen) );
+};
+
+/** UnitTest for CountBondsTest::BondsOfThreeTest().
+ */
+void CountBondsTest::BondsOfThreeTest()
+{
+  CPPUNIT_ASSERT_EQUAL( 2 , CountBondsOfThree(molecules, hydrogen, oxygen, hydrogen) );
+  CPPUNIT_ASSERT_EQUAL( 0 , CountBondsOfThree(molecules, oxygen, hydrogen, oxygen) );
+};
+
+void OutputTestMolecule(molecule *mol, const char *name)
+{
+  ofstream output(name);
+  mol->OutputXYZ(&output);
+  output.close();
+}
+
+/** UnitTest for CountBondsTest::HydrogenBridgeBondsTest().
+ */
+void CountBondsTest::HydrogenBridgeBondsTest()
+{
+  double *mirror = new double[3];
+  CPPUNIT_ASSERT(mirror != NULL && "could not create array of doubles");
+  for (int i=0;i<3;i++)
+    mirror[i] = -1.;
+  Vector Translator;
+
+  //OutputTestMolecule(TestMolecule1, "testmolecule1.xyz");
+
+  cout << "Case 1: offset of (3,0,0), hence angles are (104.5, 0, 75.5, 180) < 30." << endl;
+  Translator  = Vector(3,0,0);
+  TestMolecule2->Translate(&Translator);
+  CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL, NULL) );
+  CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, oxygen, NULL) );
+  //OutputTestMolecule(TestMolecule2, "testmolecule2-1.xyz");
+  Translator = Vector(-3,0,0);
+  TestMolecule2->Translate(&Translator);
+
+  cout << "Case 2: offset of (0,3,0), hence angle are (14.5, 165.5, 90) < 30 (only three, because other 90 is missing due to first H01 only fulfilling H-bond criteria)." << endl;
+  Translator = Vector(0,3,0);
+  TestMolecule2->Translate(&Translator);
+  CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL, NULL) );
+  //OutputTestMolecule(TestMolecule2, "testmolecule2-2.xyz");
+  Translator = Vector(0,-3,0);
+  TestMolecule2->Translate(&Translator);
+
+  cout << "Case 3: offset of (0,-3,0) and mirror, hence angle are (165.5, 90, 165.5, 90) > 30." << endl;
+  Translator = Vector(0,-3,0);
+  TestMolecule2->Scale((const double ** const)&mirror);
+  TestMolecule2->Translate(&Translator);
+  CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) );
+  //OutputTestMolecule(TestMolecule2, "testmolecule2-3.xyz");
+  Translator = Vector(0,3,0);
+  TestMolecule2->Translate(&Translator);
+  TestMolecule2->Scale((const double ** const)&mirror);
+
+  cout << "Case 4: offset of (2,1,0), hence angle are (78, 26.6, 102, 153.4) < 30." << endl;
+  Translator = Vector(2,1,0);
+  TestMolecule2->Translate(&Translator);
+  CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL, NULL) );
+  //OutputTestMolecule(TestMolecule2, "testmolecule2-4.xyz");
+  Translator = Vector(-2,-1,0);
+  TestMolecule2->Translate(&Translator);
+
+  cout << "Case 5: offset of (0,0,3), hence angle are (90, 90, 90, 90) > 30." << endl;
+  Translator = Vector(0,0,3);
+  TestMolecule2->Translate(&Translator);
+  CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) );
+  //OutputTestMolecule(TestMolecule2, "testmolecule2-5.xyz");
+  Translator = Vector(0,0,-3);
+  TestMolecule2->Translate(&Translator);
+
+  cout << "Case 6: offset of (-3,0,0) and mirror, hence angle are (75.5, 180, 104.5, 180) > 30." << endl;
+  Translator = Vector(-3,0,0);
+  TestMolecule2->Scale((const double ** const)&mirror);
+  TestMolecule2->Translate(&Translator);
+  CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) );
+  //OutputTestMolecule(TestMolecule2, "testmolecule2-6.xyz");
+  Translator = Vector(3,0,0);
+  TestMolecule2->Translate(&Translator);
+  TestMolecule2->Scale((const double ** const)&mirror);
+
+  cout << "Case 7: offset of (3,0,0) and mirror, hence angles are (104.5, 0, 104.5, 0) < 30, but interfering hydrogens." << endl;
+  Translator = Vector(3,0,0);
+  TestMolecule2->Scale((const double ** const)&mirror);
+  TestMolecule2->Translate(&Translator);
+  CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) );
+  //OutputTestMolecule(TestMolecule2, "testmolecule2-7.xyz");
+  Translator = Vector(-3,0,0);
+  TestMolecule2->Translate(&Translator);
+  TestMolecule2->Scale((const double ** const)&mirror);
+
+  cout << "Case 8: offset of (0,3,0), hence angle are (14.5, 90, 14.5, 90) < 30, but interfering hydrogens." << endl;
+  Translator = Vector(0,3,0);
+  TestMolecule2->Scale((const double ** const)&mirror);
+  TestMolecule2->Translate(&Translator);
+  //OutputTestMolecule(TestMolecule2, "testmolecule2-8.xyz");
+  CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) );
+  Translator = Vector(0,-3,0);
+  TestMolecule2->Translate(&Translator);
+  TestMolecule2->Scale((const double ** const)&mirror);
+
+  delete[](mirror);
+};
Index: src/unittests/CountBondsUnitTest.hpp
===================================================================
--- src/unittests/CountBondsUnitTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/CountBondsUnitTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,49 @@
+/*
+ * CountBondsUnitTest.hpp
+ *
+ *  Created on: Mar 30, 2010
+ *      Author: heber
+ */
+
+#ifndef COUNTBONDSUNITTEST_HPP_
+#define COUNTBONDSUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+
+class BondGraph;
+class element;
+class molecule;
+class periodentafel;
+
+/********************************************** Test classes **************************************/
+
+class CountBondsTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( CountBondsTest) ;
+    CPPUNIT_TEST ( BondsOfTwoTest );
+    CPPUNIT_TEST ( BondsOfThreeTest );
+    CPPUNIT_TEST ( HydrogenBridgeBondsTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+      void BondsOfTwoTest();
+      void BondsOfThreeTest();
+      void HydrogenBridgeBondsTest();
+
+private:
+
+      MoleculeListClass *molecules;
+      molecule *TestMolecule1;
+      molecule *TestMolecule2;
+      const element *hydrogen;
+      const element *oxygen;
+
+      BondGraph *BG;
+      string *filename;
+};
+
+
+#endif /* COUNTBONDSUNITTEST_HPP_ */
Index: src/unittests/LineUnittest.cpp
===================================================================
--- src/unittests/LineUnittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/LineUnittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,353 @@
+/*
+ * LineUnittest.cpp
+ *
+ *  Created on: May 27, 2010
+ *      Author: crueger
+ */
+
+#include "LineUnittest.hpp"
+
+#include "vector.hpp"
+#include "Exceptions/LinearDependenceException.hpp"
+#include "Exceptions/SkewException.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <iostream>
+
+using namespace std;
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+CPPUNIT_TEST_SUITE_REGISTRATION( LineUnittest );
+
+void LineUnittest::setUp(){
+  // three lines along the axes
+  la1 = new Line(zeroVec,e1);
+  la2 = new Line(zeroVec,e2);
+  la3 = new Line(zeroVec,e3);
+
+  // the lines along the planes defined by two coordinate axes
+  lp1 = new Line(e1,e1-e2);
+  lp2 = new Line(e2,e2-e3);
+  lp3 = new Line(e3,e3-e1);
+}
+void LineUnittest::tearDown(){
+  delete la1;
+  delete la2;
+  delete la3;
+
+  delete lp1;
+  delete lp2;
+  delete lp3;
+}
+
+void LineUnittest::constructionErrorTest(){
+  // test some constructions
+
+  // direction+origin should never fail
+  CPPUNIT_ASSERT_NO_THROW(Line(zeroVec,e1));
+  CPPUNIT_ASSERT_NO_THROW(Line(zeroVec,e2));
+  CPPUNIT_ASSERT_NO_THROW(Line(zeroVec,e3));
+
+  // two points fails if both points are the same
+  CPPUNIT_ASSERT_NO_THROW(makeLineThrough(e1,e2));
+  CPPUNIT_ASSERT_NO_THROW(makeLineThrough(e2,e3));
+  CPPUNIT_ASSERT_NO_THROW(makeLineThrough(e3,e1));
+  // for zerovectors
+  CPPUNIT_ASSERT_NO_THROW(makeLineThrough(e1,zeroVec));
+  CPPUNIT_ASSERT_NO_THROW(makeLineThrough(e2,zeroVec));
+  CPPUNIT_ASSERT_NO_THROW(makeLineThrough(e3,zeroVec));
+  // now we pass two times the same point
+  CPPUNIT_ASSERT_THROW(makeLineThrough(zeroVec,zeroVec),LinearDependenceException);
+  CPPUNIT_ASSERT_THROW(makeLineThrough(e1,e1),LinearDependenceException);
+  CPPUNIT_ASSERT_THROW(makeLineThrough(e2,e2),LinearDependenceException);
+  CPPUNIT_ASSERT_THROW(makeLineThrough(e3,e3),LinearDependenceException);
+
+}
+
+bool testDirection(const Vector &dir1,const Vector &dir2){
+  return (dir1==dir2) || (dir1==-1*dir2);
+}
+
+void LineUnittest::constructionResultTest(){
+  // test all directions
+  CPPUNIT_ASSERT(testDirection(la1->getDirection(),e1));
+  CPPUNIT_ASSERT(testDirection(la2->getDirection(),e2));
+  CPPUNIT_ASSERT(testDirection(la3->getDirection(),e3));
+
+  // test origins
+  CPPUNIT_ASSERT_EQUAL(la1->getOrigin(),zeroVec);
+  CPPUNIT_ASSERT_EQUAL(la2->getOrigin(),zeroVec);
+  CPPUNIT_ASSERT_EQUAL(la2->getOrigin(),zeroVec);
+
+  // test if desired points are on the lines
+  CPPUNIT_ASSERT(la1->isContained(zeroVec));
+  CPPUNIT_ASSERT(la2->isContained(zeroVec));
+  CPPUNIT_ASSERT(la3->isContained(zeroVec));
+
+  CPPUNIT_ASSERT(la1->isContained(e1));
+  CPPUNIT_ASSERT(la2->isContained(e2));
+  CPPUNIT_ASSERT(la3->isContained(e3));
+
+  CPPUNIT_ASSERT(lp1->isContained(e1));
+  CPPUNIT_ASSERT(lp2->isContained(e2));
+  CPPUNIT_ASSERT(lp3->isContained(e3));
+
+  CPPUNIT_ASSERT(lp1->isContained(e2));
+  CPPUNIT_ASSERT(lp2->isContained(e3));
+  CPPUNIT_ASSERT(lp3->isContained(e1));
+}
+
+void LineUnittest::isContainedTest(){
+  // Zerovector on the axes lines
+  CPPUNIT_ASSERT(la1->isContained(zeroVec));
+  CPPUNIT_ASSERT(la2->isContained(zeroVec));
+  CPPUNIT_ASSERT(la3->isContained(zeroVec));
+
+  // multiples of the second support vector
+  CPPUNIT_ASSERT(la1->isContained(e1));
+  CPPUNIT_ASSERT(la2->isContained(e2));
+  CPPUNIT_ASSERT(la3->isContained(e3));
+
+  CPPUNIT_ASSERT(la1->isContained(2*e1));
+  CPPUNIT_ASSERT(la2->isContained(2*e2));
+  CPPUNIT_ASSERT(la3->isContained(2*e3));
+
+  CPPUNIT_ASSERT(la1->isContained(3*e1));
+  CPPUNIT_ASSERT(la2->isContained(3*e2));
+  CPPUNIT_ASSERT(la3->isContained(3*e3));
+
+  // negative multiples
+  CPPUNIT_ASSERT(la1->isContained(-1*e1));
+  CPPUNIT_ASSERT(la2->isContained(-1*e2));
+  CPPUNIT_ASSERT(la3->isContained(-1*e3));
+
+  CPPUNIT_ASSERT(la1->isContained(-2*e1));
+  CPPUNIT_ASSERT(la2->isContained(-2*e2));
+  CPPUNIT_ASSERT(la3->isContained(-2*e3));
+
+  // points that should not be on the lines
+  CPPUNIT_ASSERT(!la1->isContained(e2));
+  CPPUNIT_ASSERT(!la2->isContained(e3));
+  CPPUNIT_ASSERT(!la3->isContained(e1));
+
+  CPPUNIT_ASSERT(!la1->isContained(2*e2));
+  CPPUNIT_ASSERT(!la2->isContained(2*e3));
+  CPPUNIT_ASSERT(!la3->isContained(2*e1));
+
+  CPPUNIT_ASSERT(!la1->isContained(-1*e2));
+  CPPUNIT_ASSERT(!la2->isContained(-1*e3));
+  CPPUNIT_ASSERT(!la3->isContained(-1*e1));
+
+  // For the plane lines
+  CPPUNIT_ASSERT(lp1->isContained(e1));
+  CPPUNIT_ASSERT(lp2->isContained(e2));
+  CPPUNIT_ASSERT(lp3->isContained(e3));
+
+  CPPUNIT_ASSERT(lp1->isContained(e2));
+  CPPUNIT_ASSERT(lp2->isContained(e3));
+  CPPUNIT_ASSERT(lp3->isContained(e1));
+
+  CPPUNIT_ASSERT(lp1->isContained(e1+2*(e1-e2)));
+  CPPUNIT_ASSERT(lp2->isContained(e2+2*(e2-e3)));
+  CPPUNIT_ASSERT(lp3->isContained(e3+2*(e3-e1)));
+
+  CPPUNIT_ASSERT(lp1->isContained(e1-2*(e1-e2)));
+  CPPUNIT_ASSERT(lp2->isContained(e2-2*(e2-e3)));
+  CPPUNIT_ASSERT(lp3->isContained(e3-2*(e3-e1)));
+}
+
+void LineUnittest::intersectionTest(){
+  Vector fixture;
+
+  // intersection of the axis lines
+  fixture = la1->getIntersection(*la2);
+  CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
+  fixture = la2->getIntersection(*la3);
+  CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
+  fixture = la3->getIntersection(*la1);
+  CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
+
+  // axes and plane lines
+  fixture = la1->getIntersection(*lp1);
+  CPPUNIT_ASSERT_EQUAL(fixture,e1);
+  fixture = la2->getIntersection(*lp2);
+  CPPUNIT_ASSERT_EQUAL(fixture,e2);
+  fixture = la3->getIntersection(*lp3);
+  CPPUNIT_ASSERT_EQUAL(fixture,e3);
+
+  fixture = la1->getIntersection(*lp3);
+  CPPUNIT_ASSERT_EQUAL(fixture,e1);
+  fixture = la2->getIntersection(*lp1);
+  CPPUNIT_ASSERT_EQUAL(fixture,e2);
+  fixture = la3->getIntersection(*lp2);
+  CPPUNIT_ASSERT_EQUAL(fixture,e3);
+
+  // two plane lines
+  fixture = lp1->getIntersection(*lp2);
+  CPPUNIT_ASSERT_EQUAL(fixture,e2);
+  fixture = lp2->getIntersection(*lp3);
+  CPPUNIT_ASSERT_EQUAL(fixture,e3);
+  fixture = lp3->getIntersection(*lp1);
+  CPPUNIT_ASSERT_EQUAL(fixture,e1);
+
+  // When we have two times the same line, we check if the point is on the line
+  fixture = la1->getIntersection(*la1);
+  CPPUNIT_ASSERT(la1->isContained(fixture));
+  fixture = la2->getIntersection(*la2);
+  CPPUNIT_ASSERT(la2->isContained(fixture));
+  fixture = la3->getIntersection(*la3);
+  CPPUNIT_ASSERT(la3->isContained(fixture));
+
+  fixture = lp1->getIntersection(*lp1);
+  CPPUNIT_ASSERT(lp1->isContained(fixture));
+  fixture = lp2->getIntersection(*lp2);
+  CPPUNIT_ASSERT(lp2->isContained(fixture));
+  fixture = lp3->getIntersection(*lp3);
+  CPPUNIT_ASSERT(lp3->isContained(fixture));
+
+  // lines that are askew should produce an Error
+  CPPUNIT_ASSERT_THROW(lp1->getIntersection(*la3),SkewException);
+  CPPUNIT_ASSERT_THROW(lp2->getIntersection(*la1),SkewException);
+  CPPUNIT_ASSERT_THROW(lp3->getIntersection(*la2),SkewException);
+
+  CPPUNIT_ASSERT_THROW(la1->getIntersection(*lp2),SkewException);
+  CPPUNIT_ASSERT_THROW(la2->getIntersection(*lp3),SkewException);
+  CPPUNIT_ASSERT_THROW(la3->getIntersection(*lp1),SkewException);
+}
+
+void LineUnittest::rotationTest(){
+  Vector fixture;
+
+  // rotate zero Vector along the axes lines by various degrees
+  fixture = la1->rotateVector(zeroVec,1.);
+  CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
+  fixture = la2->rotateVector(zeroVec,1.);
+  CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
+  fixture = la3->rotateVector(zeroVec,1.);
+  CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
+
+  fixture = la1->rotateVector(zeroVec,2.);
+  CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
+  fixture = la2->rotateVector(zeroVec,2.);
+  CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
+  fixture = la3->rotateVector(zeroVec,2.);
+  CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
+
+  // rotate vectors on the axis around their lines
+  fixture = la1->rotateVector(e1,1.);
+  CPPUNIT_ASSERT_EQUAL(fixture,e1);
+  fixture = la2->rotateVector(e2,1.);
+  CPPUNIT_ASSERT_EQUAL(fixture,e2);
+  fixture = la3->rotateVector(e3,1.);
+  CPPUNIT_ASSERT_EQUAL(fixture,e3);
+
+  fixture = la1->rotateVector(e1,2.);
+  CPPUNIT_ASSERT_EQUAL(fixture,e1);
+  fixture = la2->rotateVector(e2,2.);
+  CPPUNIT_ASSERT_EQUAL(fixture,e2);
+  fixture = la3->rotateVector(e3,2.);
+  CPPUNIT_ASSERT_EQUAL(fixture,e3);
+
+  // more vectors on the axis
+  fixture = la1->rotateVector(2*e1,1.);
+  CPPUNIT_ASSERT_EQUAL(fixture,2*e1);
+  fixture = la2->rotateVector(2*e2,1.);
+  CPPUNIT_ASSERT_EQUAL(fixture,2*e2);
+  fixture = la3->rotateVector(2*e3,1.);
+  CPPUNIT_ASSERT_EQUAL(fixture,2*e3);
+
+  fixture = la1->rotateVector(2*e1,2.);
+  CPPUNIT_ASSERT_EQUAL(fixture,2*e1);
+  fixture = la2->rotateVector(2*e2,2.);
+  CPPUNIT_ASSERT_EQUAL(fixture,2*e2);
+  fixture = la3->rotateVector(2*e3,2.);
+  CPPUNIT_ASSERT_EQUAL(fixture,2*e3);
+
+  // negative factors
+  fixture = la1->rotateVector(-1*e1,1.);
+  CPPUNIT_ASSERT_EQUAL(fixture,-1*e1);
+  fixture = la2->rotateVector(-1*e2,1.);
+  CPPUNIT_ASSERT_EQUAL(fixture,-1*e2);
+  fixture = la3->rotateVector(-1*e3,1.);
+  CPPUNIT_ASSERT_EQUAL(fixture,-1*e3);
+
+  fixture = la1->rotateVector(-1*e1,2.);
+  CPPUNIT_ASSERT_EQUAL(fixture,-1*e1);
+  fixture = la2->rotateVector(-1*e2,2.);
+  CPPUNIT_ASSERT_EQUAL(fixture,-1*e2);
+  fixture = la3->rotateVector(-1*e3,2.);
+  CPPUNIT_ASSERT_EQUAL(fixture,-1*e3);
+
+
+
+  // now the real rotations
+  // e2 around e1
+  fixture = la1->rotateVector(e2,0);
+  CPPUNIT_ASSERT_EQUAL(fixture,e2);
+  fixture = la1->rotateVector(e2,1./2.*M_PI);
+  CPPUNIT_ASSERT_EQUAL(fixture,-1*e3);
+  fixture = la1->rotateVector(e2,M_PI);
+  CPPUNIT_ASSERT_EQUAL(fixture,-1*e2);
+  fixture = la1->rotateVector(e2,2*M_PI);
+  CPPUNIT_ASSERT_EQUAL(fixture,e2);
+
+  // e3 around e2
+  fixture = la2->rotateVector(e3,0);
+  CPPUNIT_ASSERT_EQUAL(fixture,e3);
+  fixture = la2->rotateVector(e3,1./2.*M_PI);
+  CPPUNIT_ASSERT_EQUAL(fixture,-1*e1);
+  fixture = la2->rotateVector(e3,M_PI);
+  CPPUNIT_ASSERT_EQUAL(fixture,-1*e3);
+  fixture = la2->rotateVector(e3,2*M_PI);
+  CPPUNIT_ASSERT_EQUAL(fixture,e3);
+
+  // e1 around e3
+  fixture = la3->rotateVector(e1,0);
+  CPPUNIT_ASSERT_EQUAL(fixture,e1);
+  fixture = la3->rotateVector(e1,1./2.*M_PI);
+  CPPUNIT_ASSERT_EQUAL(fixture,-1*e2);
+  fixture = la3->rotateVector(e1,M_PI);
+  CPPUNIT_ASSERT_EQUAL(fixture,-1*e1);
+  fixture = la3->rotateVector(e1,2*M_PI);
+  CPPUNIT_ASSERT_EQUAL(fixture,e1);
+
+
+  // and some rotation around the plane lines
+
+  // Vectors on the line
+  fixture = lp1->rotateVector(e1,1.);
+  CPPUNIT_ASSERT_EQUAL(fixture,e1);
+  fixture = lp1->rotateVector(e2,1.);
+  CPPUNIT_ASSERT_EQUAL(fixture,e2);
+
+  fixture = lp2->rotateVector(e2,1.);
+  CPPUNIT_ASSERT_EQUAL(fixture,e2);
+  fixture = lp2->rotateVector(e3,1.);
+  CPPUNIT_ASSERT_EQUAL(fixture,e3);
+
+  fixture = lp3->rotateVector(e3,1.);
+  CPPUNIT_ASSERT_EQUAL(fixture,e3);
+  fixture = lp3->rotateVector(e1,1.);
+  CPPUNIT_ASSERT_EQUAL(fixture,e1);
+
+  // the real stuff
+  fixture = lp1->rotateVector(zeroVec,M_PI);
+  CPPUNIT_ASSERT_EQUAL(fixture,Vector(1,1,0));
+  fixture = lp2->rotateVector(zeroVec,M_PI);
+  CPPUNIT_ASSERT_EQUAL(fixture,Vector(0,1,1));
+  fixture = lp3->rotateVector(zeroVec,M_PI);
+  CPPUNIT_ASSERT_EQUAL(fixture,Vector(1,0,1));
+
+  fixture = lp1->rotateVector(zeroVec,2*M_PI);
+  CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
+  fixture = lp2->rotateVector(zeroVec,2*M_PI);
+  CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
+  fixture = lp3->rotateVector(zeroVec,2*M_PI);
+  CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
+}
Index: src/unittests/LineUnittest.hpp
===================================================================
--- src/unittests/LineUnittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/LineUnittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,46 @@
+/*
+ * LineUnittest.hpp
+ *
+ *  Created on: May 27, 2010
+ *      Author: crueger
+ */
+
+#ifndef LINEUNITTEST_HPP_
+#define LINEUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "Line.hpp"
+
+class LineUnittest : public CppUnit::TestFixture
+{
+
+  CPPUNIT_TEST_SUITE( LineUnittest) ;
+  CPPUNIT_TEST ( constructionErrorTest );
+  CPPUNIT_TEST ( constructionResultTest );
+  CPPUNIT_TEST ( isContainedTest );
+  CPPUNIT_TEST ( intersectionTest );
+  CPPUNIT_TEST ( rotationTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void constructionErrorTest();
+  void constructionResultTest();
+  void isContainedTest();
+  void intersectionTest();
+  void rotationTest();
+
+private:
+  Line *la1;
+  Line *la2;
+  Line *la3;
+  Line *lp1;
+  Line *lp2;
+  Line *lp3;
+
+};
+
+#endif /* LINEUNITTEST_HPP_ */
Index: src/unittests/LinkedCellUnitTest.cpp
===================================================================
--- src/unittests/LinkedCellUnitTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/LinkedCellUnitTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,346 @@
+/*
+ * LinkedCellUnitTest.cpp
+ *
+ *  Created on: Apr 9, 2010
+ *      Author: heber
+ */
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <iostream>
+#include <stdio.h>
+#include <cstring>
+
+#include "atom.hpp"
+#include "element.hpp"
+#include "linkedcell.hpp"
+#include "molecule.hpp"
+#include "periodentafel.hpp"
+#include "LinkedCellUnitTest.hpp"
+#include "World.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( LinkedCellTest );
+
+
+void LinkedCellTest::setUp()
+{
+  atom *Walker = NULL;
+
+  // construct element
+  hydrogen = World::getInstance().getPeriode()->FindElement(1);
+  CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen");
+
+  // construct molecule (water molecule)
+  TestMolecule = World::getInstance().createMolecule();
+  CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule");
+  for (double x=0.5;x<3;x+=1.)
+    for (double y=0.5;y<3;y+=1.)
+      for (double z=0.5;z<3;z+=1.) {
+        Walker = World::getInstance().createAtom();
+        CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
+        Walker->type = hydrogen;
+        *Walker->node = Vector(x, y, z );
+        TestMolecule->AddAtom(Walker);
+      }
+
+  // construct linked cell
+  LC = new LinkedCell (TestMolecule, 1.);
+  CPPUNIT_ASSERT(LC != NULL && "could not create LinkedCell");
+
+  // check that TestMolecule was correctly constructed
+  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 3*3*3 );
+};
+
+
+void LinkedCellTest::tearDown()
+{
+  delete(LC);
+  World::purgeInstance();
+};
+
+
+/** UnitTest for LinkedCell::CheckBounds().
+ */
+void LinkedCellTest::CheckBoundsTest()
+{
+  // check for within bounds
+  LC->n[0] = LC->n[1] = LC->n[2] = 0;
+  CPPUNIT_ASSERT_EQUAL( true, LC->CheckBounds() );
+  LC->n[0] = LC->n[1] = LC->n[2] = 1;
+  CPPUNIT_ASSERT_EQUAL( true, LC->CheckBounds() );
+  LC->n[0] = LC->n[1] = LC->n[2] = 2;
+  CPPUNIT_ASSERT_EQUAL( true, LC->CheckBounds() );
+
+  // check for out of bounds
+  cout << "The following test is supposed to fail and produce an ERROR." << endl;
+  LC->n[0] = 404040;
+  CPPUNIT_ASSERT_EQUAL( false, LC->CheckBounds() );
+  cout << "The following test is supposed to fail and produce an ERROR." << endl;
+  LC->n[0] = 0;
+  LC->n[1] = 5000;
+  CPPUNIT_ASSERT_EQUAL( false, LC->CheckBounds() );
+  cout << "The following test is supposed to fail and produce an ERROR." << endl;
+  LC->n[1] = 0;
+  LC->n[2] = -70;
+  CPPUNIT_ASSERT_EQUAL( false, LC->CheckBounds() );
+  cout << "The following test is supposed to fail and produce an ERROR." << endl;
+  LC->n[0] = LC->n[1] = LC->n[2] = 3;
+  CPPUNIT_ASSERT_EQUAL( false, LC->CheckBounds() );
+};
+
+
+/** UnitTest for LinkedCell::GetCurrentCell().
+ * Note that CheckBounds() is used and has to be tested already.
+ */
+void LinkedCellTest::GetCurrentCellTest()
+{
+  // within bounds
+  LC->n[0] = LC->n[1] = LC->n[2] = 0;
+  CPPUNIT_ASSERT_EQUAL( (const LinkedCell::LinkedNodes*)&LC->LC[0 * 3*3 + 0 * 3 + 0], LC->GetCurrentCell() );
+  LC->n[0] = LC->n[1] = LC->n[2] = 1;
+  CPPUNIT_ASSERT_EQUAL( (const LinkedCell::LinkedNodes*)&LC->LC[1 * 3*3 + 1 * 3 + 1], LC->GetCurrentCell() );
+  LC->n[0] = LC->n[1] = LC->n[2] = 2;
+  CPPUNIT_ASSERT_EQUAL( (const LinkedCell::LinkedNodes*)&LC->LC[2 * 3*3 + 2 * 3 + 2], LC->GetCurrentCell() );
+
+  // out of bounds
+  LC->n[0] = LC->n[1] = LC->n[2] = 3;
+  cout << "The following test is supposed to fail and produce an ERROR." << endl;
+  CPPUNIT_ASSERT_EQUAL( (const LinkedCell::LinkedNodes*)NULL, LC->GetCurrentCell() );
+  LC->n[0] = LC->n[1] = LC->n[2] = -1;
+  cout << "The following test is supposed to fail and produce an ERROR." << endl;
+  CPPUNIT_ASSERT_EQUAL( (const LinkedCell::LinkedNodes*)NULL, LC->GetCurrentCell() );
+};
+
+/** UnitTest for LinkedCell::GetRelativeToCurrentCell().
+ */
+void LinkedCellTest::GetRelativeToCurrentCellTest()
+{
+  int offset[3];
+
+  // offset to (0,0,0) always
+  offset[0] = offset[1] = offset[2] = 0;
+  LC->n[0] = LC->n[1] = LC->n[2] = 0;
+  CPPUNIT_ASSERT_EQUAL( (const LinkedCell::LinkedNodes*)&LC->LC[0], LC->GetRelativeToCurrentCell(offset) );
+  offset[0] = offset[1] = offset[2] = -1;
+  LC->n[0] = LC->n[1] = LC->n[2] = 1;
+  CPPUNIT_ASSERT_EQUAL( (const LinkedCell::LinkedNodes*)&LC->LC[0], LC->GetRelativeToCurrentCell(offset) );
+  offset[0] = offset[1] = offset[2] = -2;
+  LC->n[0] = LC->n[1] = LC->n[2] = 2;
+  CPPUNIT_ASSERT_EQUAL( (const LinkedCell::LinkedNodes*)&LC->LC[0], LC->GetRelativeToCurrentCell(offset) );
+
+  // offset to (0,0,0) - 1.*(x/y/z) out of bounds
+  offset[0] = offset[1] = offset[2] = 0;
+  offset[0] = -1;
+  LC->n[0] = LC->n[1] = LC->n[2] = 0;
+  cout << "The following test is supposed to fail and produce an ERROR." << endl;
+  CPPUNIT_ASSERT_EQUAL( (const LinkedCell::LinkedNodes*)NULL, LC->GetRelativeToCurrentCell(offset) );
+  offset[0] = offset[1] = offset[2] = 0;
+  offset[1] = -1;
+  LC->n[0] = LC->n[1] = LC->n[2] = 0;
+  cout << "The following test is supposed to fail and produce an ERROR." << endl;
+  CPPUNIT_ASSERT_EQUAL( (const LinkedCell::LinkedNodes*)NULL, LC->GetRelativeToCurrentCell(offset) );
+  offset[0] = offset[1] = offset[2] = 0;
+  offset[2] = -1;
+  LC->n[0] = LC->n[1] = LC->n[2] = 0;
+  cout << "The following test is supposed to fail and produce an ERROR." << endl;
+  CPPUNIT_ASSERT_EQUAL( (const LinkedCell::LinkedNodes*)NULL, LC->GetRelativeToCurrentCell(offset) );
+
+  // out of bounds
+  offset[0] = offset[1] = offset[2] = -5054932;
+  LC->n[0] = LC->n[1] = LC->n[2] = 1;
+  cout << "The following test is supposed to fail and produce an ERROR." << endl;
+  CPPUNIT_ASSERT_EQUAL( (const LinkedCell::LinkedNodes*)NULL, LC->GetRelativeToCurrentCell(offset) );
+  offset[0] = offset[1] = offset[2] = 192345;
+  LC->n[0] = LC->n[1] = LC->n[2] = 1;
+  cout << "The following test is supposed to fail and produce an ERROR." << endl;
+  CPPUNIT_ASSERT_EQUAL( (const LinkedCell::LinkedNodes*)NULL, LC->GetRelativeToCurrentCell(offset) );
+
+  // index is out of bounds, offset points within
+  offset[0] = offset[1] = offset[2] = -2;
+  LC->n[0] = LC->n[1] = LC->n[2] = 4;
+  CPPUNIT_ASSERT_EQUAL( (const LinkedCell::LinkedNodes*)&LC->LC[2 * 3*3 + 2 * 3 + 2], LC->GetRelativeToCurrentCell(offset) );
+
+  // index is within bounds, offset points out
+  offset[0] = offset[1] = offset[2] = 2;
+  LC->n[0] = LC->n[1] = LC->n[2] = 2;
+  cout << "The following test is supposed to fail and produce an ERROR." << endl;
+  CPPUNIT_ASSERT_EQUAL( (const LinkedCell::LinkedNodes*)NULL, LC->GetRelativeToCurrentCell(offset) );
+};
+
+
+/** UnitTest for LinkedCell::SetIndexToNode().
+ */
+void LinkedCellTest::SetIndexToNodeTest()
+{
+  // check all atoms
+  for(molecule::iterator iter = TestMolecule->begin(); iter != TestMolecule->end();++iter){
+    CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToNode(*iter) );
+  }
+
+  // check internal vectors, returns false, because this atom is not in LC-list!
+  atom *newAtom = World::getInstance().createAtom();
+  newAtom->setName("test");
+  newAtom->x= Vector(1,1,1);
+  CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(newAtom) );
+  World::getInstance().destroyAtom(newAtom);
+
+  // check out of bounds vectors
+  newAtom = World::getInstance().createAtom();
+  newAtom->setName("test");
+  newAtom->x = Vector(0,-1,0);
+  CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(newAtom) );
+  World::getInstance().destroyAtom(newAtom);
+};
+
+
+/** UnitTest for LinkedCell::SetIndexToVector().
+ */
+void LinkedCellTest::SetIndexToVectorTest()
+{
+  Vector tester;
+
+  // check center of each cell
+  for (double x=0.5;x<3;x+=1.)
+    for (double y=0.5;y<3;y+=1.)
+      for (double z=0.5;z<3;z+=1.) {
+        tester = Vector(x,y,z);
+        CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToVector(&tester) );
+      }
+  // check corners of each cell
+  for (double x=1.;x<4;x+=1.)
+    for (double y=1.;y<4;y+=1.)
+      for (double z=1.;z<4;z+=1.) {
+        tester= Vector(x,y,z);
+        cout << "Tester is at " << tester << "." << endl;
+        CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToVector(&tester) );
+      }
+  // check out of bounds
+  for (double x=0.5-1e-10;x<5;x+=3.1)
+    for (double y=0.5-1e-10;y<5;y+=3.1)
+      for (double z=0.5-1e-10;z<5;z+=3.1) {
+        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) );
+      }
+  // 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) );
+};
+
+
+/** UnitTest for LinkedCell::GetNeighbourBounds().
+ */
+void LinkedCellTest::GetNeighbourBoundsTest()
+{
+  Vector tester;
+  int lower[NDIM], upper[NDIM];
+
+  tester= Vector(0.5,0.5,0.5);
+  LC->SetIndexToVector(&tester);
+  LC->GetNeighbourBounds(lower, upper);
+  for (int i=0;i<NDIM;i++)
+    CPPUNIT_ASSERT_EQUAL( 0, lower[i]);
+  for (int i=0;i<NDIM;i++)
+    CPPUNIT_ASSERT_EQUAL( 1, upper[i]);
+};
+
+
+/** UnitTest for LinkedCell::GetallNeighbours().
+ */
+void LinkedCellTest::GetallNeighboursTest()
+{
+  Vector tester;
+  LinkedCell::LinkedNodes *ListOfPoints = NULL;
+  size_t size = 0;
+
+  // get all atoms
+  tester= Vector(1.5,1.5,1.5);
+  CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(&tester) );
+  ListOfPoints = LC->GetallNeighbours();
+  size = ListOfPoints->size();
+  CPPUNIT_ASSERT_EQUAL( (size_t)27, size );
+
+  for(molecule::iterator iter = TestMolecule->begin(); iter != TestMolecule->end(); ++iter){
+    ListOfPoints->remove((*iter));
+    size--;
+    CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() );
+  }
+  CPPUNIT_ASSERT_EQUAL( (size_t)0, size );
+  CPPUNIT_ASSERT_EQUAL( (size_t)0, ListOfPoints->size() );
+  CPPUNIT_ASSERT_EQUAL( true, ListOfPoints->empty() );
+  delete(ListOfPoints);
+
+  // get all atoms in one corner
+  tester= Vector(0.5, 0.5, 0.5);
+  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)) {
+      ListOfPoints->remove(*iter);
+      size--;
+      CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() );
+    }
+  }
+  CPPUNIT_ASSERT_EQUAL( (size_t)0, size );
+  CPPUNIT_ASSERT_EQUAL( (size_t)0, ListOfPoints->size() );
+  CPPUNIT_ASSERT_EQUAL( true, ListOfPoints->empty() );
+  delete(ListOfPoints);
+
+  // get all atoms from one corner
+  tester = Vector(0.5, 0.5, 0.5);
+  CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(&tester) );
+  ListOfPoints = LC->GetallNeighbours(3);
+  size=ListOfPoints->size();
+  CPPUNIT_ASSERT_EQUAL( (size_t)27, size );
+  for(molecule::iterator iter = TestMolecule->begin(); iter!=TestMolecule->end();++iter){
+    ListOfPoints->remove(*iter);
+    size--;
+    CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() );
+  }
+  CPPUNIT_ASSERT_EQUAL( (size_t)0, size );
+  CPPUNIT_ASSERT_EQUAL( (size_t)0, ListOfPoints->size() );
+  CPPUNIT_ASSERT_EQUAL( true, ListOfPoints->empty() );
+  delete(ListOfPoints);
+};
+
+
+/** UnitTest for LinkedCell::GetPointsInsideSphere().
+ */
+void LinkedCellTest::GetPointsInsideSphereTest()
+{
+  Vector tester;
+  LinkedCell::LinkedNodes *ListOfPoints = NULL;
+  size_t size = 0;
+
+  // get all points around central arom with radius 1.
+  tester= Vector(1.5,1.5,1.5);
+  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 ) {
+      ListOfPoints->remove(*iter);
+      size--;
+      CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() );
+    }
+  }
+  CPPUNIT_ASSERT_EQUAL( (size_t)0, size );
+  CPPUNIT_ASSERT_EQUAL( (size_t)0, ListOfPoints->size() );
+  CPPUNIT_ASSERT_EQUAL( true, ListOfPoints->empty() );
+  delete(ListOfPoints);
+};
Index: src/unittests/LinkedCellUnitTest.hpp
===================================================================
--- src/unittests/LinkedCellUnitTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/LinkedCellUnitTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,55 @@
+/*
+ * LinkedCellUnitTest.hpp
+ *
+ *  Created on: Apr 9, 2010
+ *      Author: heber
+ */
+
+#ifndef LINKEDCELLUNITTEST_HPP_
+#define LINKEDCELLUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+
+class element;
+class LinkedCell;
+class molecule;
+class periodentafel;
+
+/********************************************** Test classes **************************************/
+
+class LinkedCellTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( LinkedCellTest) ;
+    CPPUNIT_TEST ( CheckBoundsTest );
+    CPPUNIT_TEST ( GetCurrentCellTest );
+    CPPUNIT_TEST ( GetRelativeToCurrentCellTest );
+    CPPUNIT_TEST ( SetIndexToNodeTest );
+    CPPUNIT_TEST ( SetIndexToVectorTest );
+    CPPUNIT_TEST ( GetNeighbourBoundsTest );
+    CPPUNIT_TEST ( GetallNeighboursTest );
+    CPPUNIT_TEST ( GetPointsInsideSphereTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+
+      void GetCurrentCellTest();
+      void GetRelativeToCurrentCellTest();
+      void SetIndexToNodeTest();
+      void SetIndexToVectorTest();
+      void CheckBoundsTest();
+      void GetNeighbourBoundsTest();
+      void GetallNeighboursTest();
+      void GetPointsInsideSphereTest();
+
+private:
+
+      molecule *TestMolecule;
+      const element *hydrogen;
+      LinkedCell *LC;
+};
+
+
+#endif /* LINKEDCELLUNITTEST_HPP_ */
Index: src/unittests/Makefile.am
===================================================================
--- src/unittests/Makefile.am	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/Makefile.am	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,233 @@
+# 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)
+
+MENUTESTS = \
+  ActionSequenceTest
+
+TESTS = \
+  ActOnAllUnitTest \
+  AnalysisBondsUnitTests \
+  AnalysisCorrelationToPointUnitTest \
+  AnalysisCorrelationToSurfaceUnitTest \
+  AnalysisPairCorrelationUnitTest \
+  atomsCalculationTest \
+  AtomDescriptorTest \
+  BondGraphUnitTest \
+  CacheableTest \
+  CountBondsUnitTest \
+  GSLMatrixSymmetricUnitTest \
+  GSLMatrixUnitTest \
+  GSLVectorUnitTest \
+  InfoUnitTest \
+  LinearSystemOfEquationsUnitTest \
+  LineUnittest \
+  LinkedCellUnitTest \
+  ListOfBondsUnitTest \
+  LogUnitTest \
+  manipulateAtomsTest \
+  MemoryUsageObserverUnitTest \
+  MemoryAllocatorUnitTest \
+  MoleculeDescriptorTest \
+  ObserverTest \
+  ParserUnitTest \
+  periodentafelTest \
+  PlaneUnittest \
+  SingletonTest \
+  StackClassUnitTest \
+  TesselationUnitTest \
+  Tesselation_BoundaryTriangleUnitTest \
+  Tesselation_InOutsideUnitTest \
+  VectorUnitTest \
+  ${MENUTESTS}
+  
+  
+check_PROGRAMS = $(TESTS) 
+noinst_PROGRAMS = $(TESTS) TestRunner
+
+GSLLIBS = ../libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB}
+ALLLIBS = ../libmolecuilder.a ${GSLLIBS} 
+PARSERLIBS = ../libparser.a ${ALLLIBS} 
+
+TESTSOURCES = \
+  ActOnAllUnitTest.cpp \
+  ActionSequenceTest.cpp \
+  analysisbondsunittest.cpp \
+  AnalysisCorrelationToPointUnitTest.cpp \
+  AnalysisCorrelationToSurfaceUnitTest.cpp  \
+  AnalysisPairCorrelationUnitTest.cpp \
+  AtomDescriptorTest.cpp \
+  atomsCalculationTest.cpp \
+  bondgraphunittest.cpp \
+  CacheableTest.cpp \
+  CountBondsUnitTest.cpp \
+  gslmatrixsymmetricunittest.cpp \
+  gslmatrixunittest.cpp \
+  gslvectorunittest.cpp \
+  infounittest.cpp \
+  linearsystemofequationsunittest.cpp \
+  LineUnittest.cpp \
+  LinkedCellUnitTest.cpp \
+  listofbondsunittest.cpp \
+  logunittest.cpp \
+  manipulateAtomsTest.cpp \
+  memoryallocatorunittest.cpp  \
+  memoryusageobserverunittest.cpp \
+  MoleculeDescriptorTest.cpp \
+  ObserverTest.cpp \
+  ParserUnitTest.cpp \
+  periodentafelTest.cpp \
+  PlaneUnittest.cpp \
+  SingletonTest.cpp \
+  stackclassunittest.cpp \
+  tesselationunittest.cpp \
+  tesselation_boundarytriangleunittest.cpp \
+  tesselation_insideoutsideunittest.cpp \
+  vectorunittest.cpp
+
+TESTHEADERS = \
+  ActOnAllUnitTest.hpp \
+  ActionSequenceTest.hpp \
+  analysisbondsunittest.hpp \
+  AnalysisCorrelationToPointUnitTest.hpp \
+  AnalysisCorrelationToSurfaceUnitTest.hpp  \
+  AnalysisPairCorrelationUnitTest.hpp \
+  AtomDescriptorTest.hpp \
+  atomsCalculationTest.hpp \
+  bondgraphunittest.hpp \
+  CacheableTest.hpp \
+  CountBondsUnitTest.hpp \
+  gslmatrixsymmetricunittest.hpp \
+  gslmatrixunittest.hpp \
+  gslvectorunittest.hpp \
+  infounittest.hpp \
+  linearsystemofequationsunittest.hpp \
+  LineUnittest.hpp \
+  LinkedCellUnitTest.hpp \
+  listofbondsunittest.hpp \
+  logunittest.hpp \
+  manipulateAtomsTest.hpp \
+  memoryallocatorunittest.hpp  \
+  memoryusageobserverunittest.hpp \
+  MoleculeDescriptorTest.hpp \
+  periodentafelTest.hpp \
+  PlaneUnittest.hpp \
+  ObserverTest.hpp \
+  SingletonTest.hpp \
+  stackclassunittest.hpp \
+  tesselationunittest.hpp \
+  tesselation_boundarytriangleunittest.hpp \
+  tesselation_insideoutsideunittest.hpp \
+  vectorunittest.hpp
+  
+
+ActionSequenceTest_SOURCES = UnitTestMain.cpp ../../../TestRunnerClient.hpp ActionSequenceTest.cpp ActionSequenceTest.hpp
+ActionSequenceTest_LDADD = ${ALLLIBS}
+
+ActOnAllUnitTest_SOURCES = UnitTestMain.cpp ../test/ActOnAllTest.hpp ActOnAllUnitTest.cpp ActOnAllUnitTest.hpp
+ActOnAllUnitTest_LDADD = ${ALLLIBS}
+
+AnalysisBondsUnitTests_SOURCES = UnitTestMain.cpp analysisbondsunittest.cpp analysisbondsunittest.hpp
+AnalysisBondsUnitTests_LDADD = ${ALLLIBS}
+
+AnalysisCorrelationToPointUnitTest_SOURCES = UnitTestMain.cpp analysis_correlation.hpp AnalysisCorrelationToPointUnitTest.cpp AnalysisCorrelationToPointUnitTest.hpp
+AnalysisCorrelationToPointUnitTest_LDADD = ${ALLLIBS}
+
+AnalysisCorrelationToSurfaceUnitTest_SOURCES = UnitTestMain.cpp analysis_correlation.hpp AnalysisCorrelationToSurfaceUnitTest.cpp AnalysisCorrelationToSurfaceUnitTest.hpp
+AnalysisCorrelationToSurfaceUnitTest_LDADD = ${ALLLIBS}
+
+AnalysisPairCorrelationUnitTest_SOURCES = UnitTestMain.cpp analysis_correlation.hpp AnalysisPairCorrelationUnitTest.cpp AnalysisPairCorrelationUnitTest.hpp
+AnalysisPairCorrelationUnitTest_LDADD = ${ALLLIBS}
+
+atomsCalculationTest_SOURCES = UnitTestMain.cpp atomsCalculationTest.cpp atomsCalculationTest.hpp
+atomsCalculationTest_LDADD = ${ALLLIBS}
+
+AtomDescriptorTest_SOURCES = UnitTestMain.cpp AtomDescriptorTest.cpp AtomDescriptorTest.hpp
+AtomDescriptorTest_LDADD = ${ALLLIBS}
+
+BondGraphUnitTest_SOURCES = UnitTestMain.cpp bondgraphunittest.cpp bondgraphunittest.hpp
+BondGraphUnitTest_LDADD = ${ALLLIBS}
+
+CacheableTest_SOURCES = UnitTestMain.cpp CacheableTest.cpp CacheableTest.hpp
+CacheableTest_LDADD = ${ALLLIBS}
+
+CountBondsUnitTest_SOURCES = UnitTestMain.cpp CountBondsUnitTest.cpp CountBondsUnitTest.hpp
+CountBondsUnitTest_LDADD = ${ALLLIBS}
+
+GSLMatrixSymmetricUnitTest_SOURCES = UnitTestMain.cpp gslmatrixsymmetricunittest.cpp gslmatrixsymmetricunittest.hpp
+GSLMatrixSymmetricUnitTest_LDADD = ${GSLLIBS}
+
+GSLMatrixUnitTest_SOURCES = UnitTestMain.cpp gslmatrixunittest.cpp gslmatrixunittest.hpp
+GSLMatrixUnitTest_LDADD = ${GSLLIBS}
+
+GSLVectorUnitTest_SOURCES = UnitTestMain.cpp gslvectorunittest.cpp gslvectorunittest.hpp
+GSLVectorUnitTest_LDADD = ${GSLLIBS}
+
+InfoUnitTest_SOURCES = UnitTestMain.cpp infounittest.cpp infounittest.hpp
+InfoUnitTest_LDADD = ${ALLLIBS}
+
+LinearSystemOfEquationsUnitTest_SOURCES = UnitTestMain.cpp linearsystemofequationsunittest.cpp linearsystemofequationsunittest.hpp
+LinearSystemOfEquationsUnitTest_LDADD = ${ALLLIBS}
+
+LineUnittest_SOURCES = UnitTestMain.cpp LineUnittest.cpp LineUnittest.hpp
+LineUnittest_LDADD = ${ALLLIBS}
+
+LinkedCellUnitTest_SOURCES = UnitTestMain.cpp LinkedCellUnitTest.cpp LinkedCellUnitTest.hpp 
+LinkedCellUnitTest_LDADD = ${ALLLIBS}
+
+ListOfBondsUnitTest_SOURCES = UnitTestMain.cpp listofbondsunittest.cpp listofbondsunittest.hpp
+ListOfBondsUnitTest_LDADD = ${ALLLIBS}
+
+LogUnitTest_SOURCES = UnitTestMain.cpp logunittest.cpp logunittest.hpp 
+LogUnitTest_LDADD = ${ALLLIBS}
+
+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}
+
+MoleculeDescriptorTest_SOURCES = UnitTestMain.cpp MoleculeDescriptorTest.cpp MoleculeDescriptorTest.hpp
+MoleculeDescriptorTest_LDADD = ${ALLLIBS}
+
+ObserverTest_SOURCES = UnitTestMain.cpp ObserverTest.cpp ObserverTest.hpp
+ObserverTest_LDADD = ${ALLLIBS}
+
+ParserUnitTest_SOURCES = UnitTestMain.cpp ParserUnitTest.cpp ParserUnitTest.hpp
+ParserUnitTest_LDADD = ${PARSERLIBS}
+
+periodentafelTest_SOURCES = UnitTestMain.cpp periodentafelTest.cpp periodentafelTest.hpp
+periodentafelTest_LDADD = ${ALLLIBS}
+
+PlaneUnittest_SOURCES = UnitTestMain.cpp PlaneUnittest.cpp PlaneUnittest.hpp
+PlaneUnittest_LDADD = ${ALLLIBS}
+
+SingletonTest_SOURCES = UnitTestMain.cpp SingletonTest.cpp SingletonTest.hpp
+SingletonTest_LDADD = ${ALLLIBS} $(BOOST_LIB) ${BOOST_THREAD_LIB}
+
+StackClassUnitTest_SOURCES = UnitTestMain.cpp stackclassunittest.cpp stackclassunittest.hpp
+StackClassUnitTest_LDADD = ${ALLLIBS}
+
+TesselationUnitTest_SOURCES = UnitTestMain.cpp tesselationunittest.cpp tesselationunittest.hpp
+TesselationUnitTest_LDADD = ${ALLLIBS}
+
+Tesselation_BoundaryTriangleUnitTest_SOURCES = UnitTestMain.cpp tesselation_boundarytriangleunittest.cpp tesselation_boundarytriangleunittest.hpp
+Tesselation_BoundaryTriangleUnitTest_LDADD = ${ALLLIBS}
+
+Tesselation_InOutsideUnitTest_SOURCES = UnitTestMain.cpp tesselation_insideoutsideunittest.cpp tesselation_insideoutsideunittest.hpp
+Tesselation_InOutsideUnitTest_LDADD = ${ALLLIBS}
+
+TestRunner_SOURCES = TestRunnerMain.cpp ../memoryallocator.hpp ../memoryallocator.cpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp $(TESTSOURCES) $(TESTHEADERS)
+TestRunner_LDADD = ${ALLLIBS}
+
+VectorUnitTest_SOURCES = UnitTestMain.cpp vectorunittest.cpp vectorunittest.hpp 
+VectorUnitTest_LDADD = ${ALLLIBS}
+
+#AUTOMAKE_OPTIONS = parallel-tests
Index: src/unittests/MapofActionsTest.cpp
===================================================================
--- src/unittests/MapofActionsTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/MapofActionsTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,65 @@
+/*
+ * analysisbondsunittest.cpp
+ *
+ *  Created on: Nov 7, 2009
+ *      Author: heber
+ */
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <iostream>
+#include <stdio.h>
+#include <cstring>
+
+#include "MapOfActionsTest.hpp"
+#include "Actions/MapOfActions.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( MapOfActionsTest );
+
+
+void MapOfActionsTest::setUp()
+{
+  MapOfActions *ActionData = MapOfActions::getInstance();
+};
+
+
+void MapOfActionsTest::tearDown()
+{
+  // note that all the atoms are cleaned by TestMolecule
+  MapOfActions::purgeInstance();
+};
+
+/** UnitTest: check whether each short form action also has a description (the other way round is not always true)
+ */
+void MapOfActionsTest::ShortFormConsistencyTest()
+{
+  for (map<string, string>::iterator ShortFormRunner = ActionData->ShortFormMap.begin(); ShortFormRunner = ActionData->ShortFormMap.begin(); ++ShortFormRunner) {
+    CPPUNIT_ASSERT( ActionData->DescriptionMap.find(ShortFormRunner->first) != ActionData->DescriptionMap.end() && "There is a short form without description.");
+  }
+};
+
+/** UnitTest: check whether each action appears in a list one of the option lists
+ */
+void MapOfActionsTest::OptionsListsConsistencyTest()
+{
+  bool haveFound = false;
+  for (map<string, string>::iterator ActionRunner = ActionData->DescriptionMap.begin(); ShortFormRunner = ActionData->DescriptionMap.begin(); ++ShortFormRunner) {
+    haveFound = haveFound || (ActionData->generic.find(ActionRunner->first) != ActionData->generic.end());
+    haveFound = haveFound || (ActionData->config.find(ActionRunner->first) != ActionData->config.end());
+    haveFound = haveFound || (ActionData->hidden.find(ActionRunner->first) != ActionData->hidden.end());
+    haveFound = haveFound || (ActionData->visible.find(ActionRunner->first) != ActionData->visible.end());
+    CPPUNIT_ASSERT_EQUAL( true , haveFound);
+  }
+};
+
Index: src/unittests/MapofActionsTest.hpp
===================================================================
--- src/unittests/MapofActionsTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/MapofActionsTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,37 @@
+/*
+ * analysisbondsunittest.hpp
+ *
+ *  Created on: Nov 7, 2009
+ *      Author: heber
+ */
+
+#ifndef MAPOFACTIONS_HPP_
+#define MAPOFACTIONS_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class BondGraph;
+class element;
+class molecule;
+class periodentafel;
+
+/********************************************** Test classes **************************************/
+
+class MapOfActionsTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( MapOfActionsTest) ;
+    CPPUNIT_TEST ( ShortFormConsistencyTest );
+    CPPUNIT_TEST ( OptionsListsConsistencyTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+      void ShortFormConsistencyTest();
+      void OptionsListsConsistencyTest();
+
+private:
+
+      MapOfActions *ActionData;
+
+#endif /* MAPOFACTIONS_HPP_ */
Index: src/unittests/MoleculeDescriptorTest.cpp
===================================================================
--- src/unittests/MoleculeDescriptorTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/MoleculeDescriptorTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,158 @@
+/*
+ * MoleculeDescriptorTest.cpp
+ *
+ *  Created on: Mar 4, 2010
+ *      Author: crueger
+ */
+
+#include "MoleculeDescriptorTest.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include <iostream>
+
+#include <Descriptors/MoleculeDescriptor.hpp>
+#include <Descriptors/MoleculeIdDescriptor.hpp>
+
+#include "World.hpp"
+#include "molecule.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( MoleculeDescriptorTest );
+
+// set up and tear down
+void MoleculeDescriptorTest::setUp(){
+  World::getInstance();
+  for(int i=0;i<MOLECULE_COUNT;++i){
+    molecules[i]= World::getInstance().createMolecule();
+    moleculeIds[i]= molecules[i]->getId();
+  }
+}
+
+void MoleculeDescriptorTest::tearDown(){
+  World::purgeInstance();
+}
+
+// some helper functions
+static bool hasAllMolecules(std::vector<molecule*> molecules,moleculeId_t ids[MOLECULE_COUNT], std::set<moleculeId_t> excluded = std::set<moleculeId_t>()){
+  for(int i=0;i<MOLECULE_COUNT;++i){
+    moleculeId_t id = ids[i];
+    if(!excluded.count(id)){
+      std::vector<molecule*>::iterator iter;
+      bool res=false;
+      for(iter=molecules.begin();iter!=molecules.end();++iter){
+        res |= (*iter)->getId() == id;
+      }
+      if(!res) {
+        cout << "Molecule " << id << " missing in returned list" << endl;
+        return false;
+      }
+    }
+  }
+  return true;
+}
+
+static bool hasNoDuplicateMolecules(std::vector<molecule*> molecules){
+  std::set<moleculeId_t> found;
+  std::vector<molecule*>::iterator iter;
+  for(iter=molecules.begin();iter!=molecules.end();++iter){
+    int id = (*iter)->getId();
+    if(found.count(id))
+      return false;
+    found.insert(id);
+  }
+  return true;
+}
+
+
+void MoleculeDescriptorTest::MoleculeBaseSetsTest(){
+  std::vector<molecule*> allMolecules = World::getInstance().getAllMolecules(AllMolecules());
+  CPPUNIT_ASSERT_EQUAL( true , hasAllMolecules(allMolecules,moleculeIds));
+  CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateMolecules(allMolecules));
+
+  std::vector<molecule*> noMolecules = World::getInstance().getAllMolecules(NoMolecules());
+  CPPUNIT_ASSERT_EQUAL( true , noMolecules.empty());
+}
+void MoleculeDescriptorTest::MoleculeIdTest(){
+  // test Molecules from boundaries and middle of the set
+  molecule* testMolecule;
+  testMolecule = World::getInstance().getMolecule(MoleculeById(moleculeIds[0]));
+  CPPUNIT_ASSERT(testMolecule);
+  CPPUNIT_ASSERT_EQUAL( moleculeIds[0], testMolecule->getId());
+  testMolecule = World::getInstance().getMolecule(MoleculeById(moleculeIds[MOLECULE_COUNT/2]));
+  CPPUNIT_ASSERT(testMolecule);
+  CPPUNIT_ASSERT_EQUAL( moleculeIds[MOLECULE_COUNT/2], testMolecule->getId());
+  testMolecule = World::getInstance().getMolecule(MoleculeById(moleculeIds[MOLECULE_COUNT-1]));
+  CPPUNIT_ASSERT(testMolecule);
+  CPPUNIT_ASSERT_EQUAL( moleculeIds[MOLECULE_COUNT-1], testMolecule->getId());
+
+  // find some ID that has not been created
+  moleculeId_t outsideId=0;
+  bool res = false;
+  for(outsideId=0;!res;++outsideId) {
+    res = true;
+    for(int i = 0; i < MOLECULE_COUNT; ++i){
+      res &= moleculeIds[i]!=outsideId;
+    }
+  }
+  // test from outside of set
+  testMolecule = World::getInstance().getMolecule(MoleculeById(outsideId));
+  CPPUNIT_ASSERT(!testMolecule);
+}
+void MoleculeDescriptorTest::MoleculeCalcTest(){
+  // test some elementary set operations
+  {
+    std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(AllMolecules()||NoMolecules());
+    CPPUNIT_ASSERT_EQUAL( true , hasAllMolecules(testMolecules,moleculeIds));
+    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateMolecules(testMolecules));
+  }
+
+  {
+    std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(NoMolecules()||AllMolecules());
+    CPPUNIT_ASSERT_EQUAL( true , hasAllMolecules(testMolecules,moleculeIds));
+    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateMolecules(testMolecules));
+  }
+
+  {
+    std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(NoMolecules()&&AllMolecules());
+    CPPUNIT_ASSERT_EQUAL( true , testMolecules.empty());
+  }
+
+  {
+    std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(AllMolecules()&&NoMolecules());
+    CPPUNIT_ASSERT_EQUAL( true , testMolecules.empty());
+  }
+
+  {
+    std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(!AllMolecules());
+    CPPUNIT_ASSERT_EQUAL( true , testMolecules.empty());
+  }
+
+  {
+    std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(!NoMolecules());
+    CPPUNIT_ASSERT_EQUAL( true , hasAllMolecules(testMolecules,moleculeIds));
+    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateMolecules(testMolecules));
+  }
+
+  // exclude and include some molecules
+  {
+    std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(AllMolecules()&&(!MoleculeById(moleculeIds[MOLECULE_COUNT/2])));
+    std::set<moleculeId_t> excluded;
+    excluded.insert(moleculeIds[MOLECULE_COUNT/2]);
+    CPPUNIT_ASSERT_EQUAL( true , hasAllMolecules(testMolecules,moleculeIds,excluded));
+    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateMolecules(testMolecules));
+    CPPUNIT_ASSERT_EQUAL( (size_t)(MOLECULE_COUNT-1), testMolecules.size());
+  }
+
+  {
+    std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(NoMolecules()||(MoleculeById(moleculeIds[MOLECULE_COUNT/2])));
+    CPPUNIT_ASSERT_EQUAL( (size_t)1, testMolecules.size());
+    CPPUNIT_ASSERT_EQUAL( moleculeIds[MOLECULE_COUNT/2], testMolecules[0]->getId());
+  }
+}
Index: src/unittests/MoleculeDescriptorTest.hpp
===================================================================
--- src/unittests/MoleculeDescriptorTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/MoleculeDescriptorTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,40 @@
+/*
+ * MoleculeDescriptorTest.hpp
+ *
+ *  Created on: Mar 4, 2010
+ *      Author: crueger
+ */
+
+#ifndef MOLECULEDESCRIPTORTEST_HPP_
+#define MOLECULEDESCRIPTORTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "types.hpp"
+
+#define MOLECULE_COUNT (10)
+
+class molecule;
+
+class MoleculeDescriptorTest : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( MoleculeDescriptorTest );
+  CPPUNIT_TEST ( MoleculeBaseSetsTest );
+  CPPUNIT_TEST ( MoleculeIdTest );
+  CPPUNIT_TEST ( MoleculeCalcTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void MoleculeBaseSetsTest();
+  void MoleculeIdTest();
+  void MoleculeCalcTest();
+
+private:
+  molecule *molecules [MOLECULE_COUNT];
+  moleculeId_t moleculeIds [MOLECULE_COUNT];
+};
+
+#endif /* MOLECULEDESCRIPTORTEST_HPP_ */
Index: src/unittests/ObserverTest.cpp
===================================================================
--- src/unittests/ObserverTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/ObserverTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,405 @@
+/*
+ * ObserverTest.cpp
+ *
+ *  Created on: Jan 19, 2010
+ *      Author: crueger
+ */
+
+#include "ObserverTest.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include <set>
+
+#include "Patterns/Observer.hpp"
+#include "Patterns/ObservedIterator.hpp"
+#include "Helpers/Assert.hpp"
+
+#include <iostream>
+
+using namespace std;
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( ObserverTest );
+
+/******************* Test stubs ************************/
+
+class UpdateCountObserver : public Observer {
+public:
+  UpdateCountObserver() :
+    Observer("UpdateCountObserver"),
+    updates(0)
+  {};
+  void update(Observable *publisher){
+    updates++;
+  }
+  void subjectKilled(Observable *publisher) {
+  }
+  int updates;
+};
+
+class SimpleObservable : public Observable {
+public:
+  SimpleObservable() :
+    Observable("SimpleObservable")
+  {}
+
+  void changeMethod() {
+    OBSERVE;
+    int i = 0;
+    i++;
+  }
+};
+
+class CallObservable : public Observable {
+public:
+  CallObservable() :
+    Observable("CallObservable")
+  {}
+
+  void changeMethod1() {
+    OBSERVE;
+    int i = 0;
+    i++;
+  }
+
+  void changeMethod2() {
+    OBSERVE;
+    int i = 0;
+    i++;
+    changeMethod1();
+  }
+};
+
+class BlockObservable : public Observable {
+public:
+  BlockObservable() :
+    Observable("BlockObservable")
+  {}
+
+  void changeMethod1(){
+    OBSERVE;
+    // test if we report correctly as blocked
+    CPPUNIT_ASSERT(isBlocked());
+  }
+
+  void changeMethod2(){
+    OBSERVE;
+    internalMethod1();
+    internalMethod2();
+  }
+
+  void internalMethod1(){
+    // we did not block, but our caller did...
+    // see if this is found
+    CPPUNIT_ASSERT(isBlocked());
+  }
+
+  void internalMethod2(){
+    OBSERVE;
+    // Both this method and the caller do block
+    // Does the reporting still work as expected?
+    CPPUNIT_ASSERT(isBlocked());
+  }
+
+  void noChangeMethod(){
+    // No Block introduced here
+    // reported correctely?
+    CPPUNIT_ASSERT(!isBlocked());
+  }
+};
+
+class SuperObservable : public Observable {
+public:
+  SuperObservable():
+    Observable("SuperObservable")
+  {
+    subObservable = new SimpleObservable();
+    subObservable->signOn(this);
+  }
+  ~SuperObservable(){
+    delete subObservable;
+  }
+  void changeMethod() {
+    OBSERVE;
+    int i = 0;
+    i++;
+    subObservable->changeMethod();
+  }
+  SimpleObservable *subObservable;
+};
+
+class NotificationObservable : public Observable {
+public:
+  NotificationObservable() :
+    Observable("NotificationObservable"),
+    notification1(new Notification(this)),
+    notification2(new Notification(this))
+  {}
+
+  ~NotificationObservable(){
+    delete notification1;
+    delete notification2;
+  }
+
+  void operation1(){
+    OBSERVE;
+    NOTIFY(notification1);
+  }
+
+  void operation2(){
+    OBSERVE;
+    NOTIFY(notification2);
+  }
+
+  Notification_ptr notification1;
+  Notification_ptr notification2;
+};
+
+class NotificationObserver : public Observer {
+public:
+  NotificationObserver(Notification_ptr notification) :
+    Observer("NotificationObserver"),
+    requestedNotification(notification),
+    wasNotified(false)
+  {}
+
+  void update(Observable*){}
+  void subjectKilled(Observable*){}
+  void recieveNotification(Observable *publisher, Notification_ptr notification){
+    ASSERT(requestedNotification==notification,"Notification received that was not requested");
+    wasNotified = true;
+  }
+
+  Notification_ptr requestedNotification;
+
+  bool wasNotified;
+};
+
+class ObservableCollection : public Observable {
+public:
+  typedef std::set<SimpleObservable*> set;
+  typedef ObservedIterator<set> iterator;
+  typedef set::const_iterator const_iterator;
+
+  ObservableCollection(int _num) :
+    Observable("ObservableCollection"),
+    num(_num)
+  {
+    for(int i=0; i<num; ++i){
+      SimpleObservable *content = new SimpleObservable();
+      content->signOn(this);
+      theSet.insert(content);
+    }
+  }
+
+  ~ObservableCollection(){
+    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;
+};
+
+
+/******************* actuall tests ***************/
+
+void ObserverTest::setUp() {
+  ASSERT_DO(Assert::Throw);
+  simpleObservable1 = new SimpleObservable();
+  simpleObservable2 = new SimpleObservable();
+  callObservable = new CallObservable();
+  superObservable = new SuperObservable();
+  blockObservable = new BlockObservable();
+  notificationObservable = new NotificationObservable();
+  collection = new ObservableCollection(5);
+
+  observer1 = new UpdateCountObserver();
+  observer2 = new UpdateCountObserver();
+  observer3 = new UpdateCountObserver();
+  observer4 = new UpdateCountObserver();
+
+  notificationObserver1 = new NotificationObserver(notificationObservable->notification1);
+  notificationObserver2 = new NotificationObserver(notificationObservable->notification2);
+}
+
+void ObserverTest::tearDown() {
+  delete simpleObservable1;
+  delete simpleObservable2;
+  delete callObservable;
+  delete superObservable;
+  delete blockObservable;
+  delete notificationObservable;
+  delete collection;
+
+  delete observer1;
+  delete observer2;
+  delete observer3;
+  delete observer4;
+  delete notificationObserver1;
+  delete notificationObserver2;
+}
+
+void ObserverTest::doesUpdateTest()
+{
+  simpleObservable1->signOn(observer1);
+  simpleObservable1->signOn(observer2);
+  simpleObservable1->signOn(observer3);
+
+  simpleObservable2->signOn(observer2);
+  simpleObservable2->signOn(observer4);
+
+  simpleObservable1->changeMethod();
+  CPPUNIT_ASSERT_EQUAL( 1, observer1->updates );
+  CPPUNIT_ASSERT_EQUAL( 1, observer2->updates );
+  CPPUNIT_ASSERT_EQUAL( 1, observer3->updates );
+  CPPUNIT_ASSERT_EQUAL( 0, observer4->updates );
+
+  simpleObservable1->signOff(observer3);
+
+  simpleObservable1->changeMethod();
+  CPPUNIT_ASSERT_EQUAL( 2, observer1->updates );
+  CPPUNIT_ASSERT_EQUAL( 2, observer2->updates );
+  CPPUNIT_ASSERT_EQUAL( 1, observer3->updates );
+  CPPUNIT_ASSERT_EQUAL( 0, observer4->updates );
+
+  simpleObservable2->changeMethod();
+  CPPUNIT_ASSERT_EQUAL( 2, observer1->updates );
+  CPPUNIT_ASSERT_EQUAL( 3, observer2->updates );
+  CPPUNIT_ASSERT_EQUAL( 1, observer3->updates );
+  CPPUNIT_ASSERT_EQUAL( 1, observer4->updates );
+}
+
+
+void ObserverTest::doesBlockUpdateTest() {
+  callObservable->signOn(observer1);
+
+  callObservable->changeMethod1();
+  CPPUNIT_ASSERT_EQUAL( 1, observer1->updates );
+
+  callObservable->changeMethod2();
+  CPPUNIT_ASSERT_EQUAL( 2, observer1->updates );
+}
+
+void ObserverTest::doesSubObservableTest() {
+  superObservable->signOn(observer1);
+  superObservable->subObservable->signOn(observer2);
+
+  superObservable->subObservable->changeMethod();
+  CPPUNIT_ASSERT_EQUAL( 1, observer1->updates );
+  CPPUNIT_ASSERT_EQUAL( 1, observer2->updates );
+
+  superObservable->changeMethod();
+  CPPUNIT_ASSERT_EQUAL( 2, observer1->updates );
+  CPPUNIT_ASSERT_EQUAL( 2, observer2->updates );
+}
+
+void ObserverTest::doesNotifyTest(){
+  notificationObservable->signOn(notificationObserver1,
+                                 notificationObservable->notification1);
+  notificationObservable->signOn(notificationObserver2,
+                                 notificationObservable->notification2);
+
+  notificationObservable->operation1();
+  CPPUNIT_ASSERT(notificationObserver1->wasNotified);
+  CPPUNIT_ASSERT(!notificationObserver2->wasNotified);
+
+  notificationObserver1->wasNotified=false;
+
+  notificationObservable->operation2();
+  CPPUNIT_ASSERT(!notificationObserver1->wasNotified);
+  CPPUNIT_ASSERT(notificationObserver2->wasNotified);
+
+}
+
+void ObserverTest::doesReportTest(){
+  // Actual checks are in the Stub-methods for this
+  blockObservable->changeMethod1();
+  blockObservable->changeMethod2();
+  blockObservable->noChangeMethod();
+}
+
+void ObserverTest::iteratorTest(){
+  int i = 0;
+  // test the general iterator methods
+  for(ObservableCollection::iterator iter=collection->begin(); iter!=collection->end();++iter){
+    CPPUNIT_ASSERT(i< collection->num);
+    i++;
+  }
+
+  i=0;
+  for(ObservableCollection::const_iterator iter=collection->begin(); iter!=collection->end();++iter){
+    CPPUNIT_ASSERT(i<collection->num);
+    i++;
+  }
+
+  collection->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){
+      (*iter)->changeMethod();
+    }
+    // At this point no change should have been propagated
+    CPPUNIT_ASSERT_EQUAL( 0, observer1->updates);
+  }
+  // After the Iterator has died the propagation should take place
+  CPPUNIT_ASSERT_EQUAL( 1, observer1->updates);
+
+  // when using a const_iterator no changes should be propagated
+  for(ObservableCollection::const_iterator iter = collection->begin(); iter!=collection->end();++iter);
+  CPPUNIT_ASSERT_EQUAL( 1, observer1->updates);
+  collection->signOff(observer1);
+}
+
+void ObserverTest::CircleDetectionTest() {
+  cout << endl << "Warning: the next test involved methods that can produce infinite loops." << endl;
+  cout << "Errors in this methods can not be checked using the CPPUNIT_ASSERT Macros." << endl;
+  cout << "Instead tests are run on these methods to see if termination is assured" << endl << endl;
+  cout << "If this test does not complete in a few seconds, kill the test-suite and fix the Error in the circle detection mechanism" << endl;
+
+  cout << endl << endl << "The following errors displayed by the observer framework can be ignored" << endl;
+
+  // make this Observable its own subject. NEVER DO THIS IN ACTUAL CODE
+  simpleObservable1->signOn(simpleObservable1);
+#ifndef NDEBUG
+  CPPUNIT_ASSERT_THROW(simpleObservable1->changeMethod(),Assert::AssertionFailure);
+#else
+  simpleObservable1->changeMethod();
+#endif
+
+  // more complex test
+  simpleObservable1->signOff(simpleObservable1);
+  simpleObservable1->signOn(simpleObservable2);
+  simpleObservable2->signOn(simpleObservable1);
+#ifndef NDEBUG
+  CPPUNIT_ASSERT_THROW(simpleObservable1->changeMethod(),Assert::AssertionFailure);
+#else
+  simpleObservable1->changeMethod();
+#endif
+
+
+  simpleObservable1->signOff(simpleObservable2);
+  simpleObservable2->signOff(simpleObservable1);
+  // when we reach this line, although we broke the DAG assumption the circle check works fine
+  CPPUNIT_ASSERT(true);
+}
Index: src/unittests/ObserverTest.hpp
===================================================================
--- src/unittests/ObserverTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/ObserverTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,66 @@
+/*
+ * ObserverTest.hpp
+ *
+ *  Created on: Jan 19, 2010
+ *      Author: crueger
+ */
+
+#ifndef OBSERVERTEST_HPP_
+#define OBSERVERTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+// forward declaration for test stubs
+class UpdateCountObserver;
+class NotificationObserver;
+class SimpleObservable;
+class CallObservable;
+class SuperObservable;
+class ObservableCollection;
+class BlockObservable;
+class NotificationObservable;
+
+class ObserverTest :  public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( ObserverTest ) ;
+  CPPUNIT_TEST ( doesUpdateTest );
+  CPPUNIT_TEST ( doesBlockUpdateTest );
+  CPPUNIT_TEST ( doesSubObservableTest );
+  CPPUNIT_TEST ( doesNotifyTest );
+  CPPUNIT_TEST ( doesReportTest );
+  CPPUNIT_TEST ( iteratorTest );
+  CPPUNIT_TEST ( CircleDetectionTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void doesUpdateTest();
+  void doesBlockUpdateTest();
+  void doesSubObservableTest();
+  void doesNotifyTest();
+  void doesReportTest();
+  void iteratorTest();
+  void CircleDetectionTest();
+
+private:
+  UpdateCountObserver *observer1;
+  UpdateCountObserver *observer2;
+  UpdateCountObserver *observer3;
+  UpdateCountObserver *observer4;
+
+  NotificationObserver *notificationObserver1;
+  NotificationObserver *notificationObserver2;
+
+  SimpleObservable *simpleObservable1;
+  SimpleObservable *simpleObservable2;
+  CallObservable *callObservable;
+  BlockObservable *blockObservable;
+  SuperObservable *superObservable;
+  NotificationObservable *notificationObservable;
+  ObservableCollection *collection;
+
+};
+
+#endif /* OBSERVERTEST_HPP_ */
Index: src/unittests/ParserUnitTest.cpp
===================================================================
--- src/unittests/ParserUnitTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/ParserUnitTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,326 @@
+/*
+ * ParserUnitTest.cpp
+ *
+ *  Created on: Mar 3, 2010
+ *      Author: metzler
+ */
+
+#include "ParserUnitTest.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "Parser/MpqcParser.hpp"
+#include "Parser/PcpParser.hpp"
+#include "Parser/TremoloParser.hpp"
+#include "Parser/XyzParser.hpp"
+#include "World.hpp"
+#include "atom.hpp"
+#include "element.hpp"
+#include "periodentafel.hpp"
+#include "Descriptors/AtomTypeDescriptor.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+using namespace std;
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( ParserUnitTest );
+
+static string waterPcp = "# ParallelCarParinello - main configuration file - created with molecuilder\n\
+\n\
+mainname\tpcp\t# programm name (for runtime files)\n\
+defaultpath\not specified\t# where to put files during runtime\n\
+pseudopotpath\not specified\t# where to find pseudopotentials\n\
+\n\
+ProcPEGamma\t8\t# for parallel computing: share constants\n\
+ProcPEPsi\t1\t# for parallel computing: share wave functions\n\
+DoOutVis\t0\t# Output data for OpenDX\n\
+DoOutMes\t1\t# Output data for measurements\n\
+DoOutOrbitals\t0\t# Output all Orbitals\n\
+DoOutCurr\t0\t# Ouput current density for OpenDx\n\
+DoOutNICS\t0\t# Output Nucleus independent current shieldings\n\
+DoPerturbation\t0\t# Do perturbation calculate and determine susceptibility and shielding\n\
+DoFullCurrent\t0\t# Do full perturbation\n\
+DoConstrainedMD\t0\t# Do perform a constrained (>0, relating to current MD step) instead of unconstrained (0) MD\n\
+Thermostat\tBerendsen\t2.5\t# Which Thermostat and its parameters to use in MD case.\n\
+CommonWannier\t0\t# Put virtual centers at indivual orbits, all common, merged by variance, to grid point, to cell center\n\
+SawtoothStart\t0.01\t# Absolute value for smooth transition at cell border \n\
+VectorPlane\t0\t# Cut plane axis (x, y or z: 0,1,2) for two-dim current vector plot\n\
+VectorCut\t0\t# Cut plane axis value\n\
+AddGramSch\t1\t# Additional GramSchmidtOrtogonalization to be safe\n\
+Seed\t1\t# initial value for random seed for Psi coefficients\n\
+\n\
+MaxOuterStep\t0\t# number of MolecularDynamics/Structure optimization steps\n\
+Deltat\t0.01\t# time per MD step\n\
+OutVisStep\t10\t# Output visual data every ...th step\n\
+OutSrcStep\t5\t# Output \"restart\" data every ..th step\n\
+TargetTemp\t0.000950045\t# Target temperature\n\
+MaxPsiStep\t3\t# number of Minimisation steps per state (0 - default)\n\
+EpsWannier\t1e-07\t# tolerance value for spread minimisation of orbitals\n\
+# Values specifying when to stop\n\
+MaxMinStep\t100\t# Maximum number of steps\n\
+RelEpsTotalE\t1e-07\t# relative change in total energy\n\
+RelEpsKineticE\t1e-05\t# relative change in kinetic energy\n\
+MaxMinStopStep\t2\t# check every ..th steps\n\
+MaxMinGapStopStep\t1\t# check every ..th steps\n\
+\n\
+# Values specifying when to stop for INIT, otherwise same as above\n\
+MaxInitMinStep\t100\t# Maximum number of steps\n\
+InitRelEpsTotalE\t1e-05\t# relative change in total energy\n\
+InitRelEpsKineticE\t0.0001\t# relative change in kinetic energy\n\
+InitMaxMinStopStep\t2\t# check every ..th steps\n\
+InitMaxMinGapStopStep\t1\t# check every ..th steps\n\
+\n\
+BoxLength\t# (Length of a unit cell)\n\
+20\n\
+0\t20\n\
+0\t0\t20\n\
+\n\
+ECut\t128\t# energy cutoff for discretization in Hartrees\n\
+MaxLevel\t5\t# number of different levels in the code, >=2\n\
+Level0Factor\t2\t# factor by which node number increases from S to 0 level\n\
+RiemannTensor\t0\t# (Use metric)\n\
+PsiType\t0\t# 0 - doubly occupied, 1 - SpinUp,SpinDown\n\
+MaxPsiDouble\t2\t# here: specifying both maximum number of SpinUp- and -Down-states\n\
+PsiMaxNoUp\t2\t# here: specifying maximum number of SpinUp-states\n\
+PsiMaxNoDown\t2\t# here: specifying maximum number of SpinDown-states\n\
+AddPsis\t0\t# Additional unoccupied Psis for bandgap determination\n\
+\n\
+RCut\t20\t# R-cut for the ewald summation\n\
+StructOpt\t0\t# Do structure optimization beforehand\n\
+IsAngstroem\t1\t# 0 - Bohr, 1 - Angstroem\n\
+RelativeCoord\t0\t# whether ion coordinates are relative (1) or absolute (0)\n\
+MaxTypes\t2\t# maximum number of different ion types\n\
+\n\
+# Ion type data (PP = PseudoPotential, Z = atomic number)\n\
+#Ion_TypeNr.\tAmount\tZ\tRGauss\tL_Max(PP)L_Loc(PP)IonMass\t# chemical name, symbol\n\
+Ion_Type1\t2\t1\t1.0\t3\t3\t1.008\tHydrogen\tH\n\
+Ion_Type2\t1\t8\t1.0\t3\t3\t15.999\tOxygen\tO\n\
+#Ion_TypeNr._Nr.R[0]\tR[1]\tR[2]\tMoveType (0 MoveIon, 1 FixedIon)\n\
+Ion_Type2_1\t0.000000000\t0.000000000\t0.000000000\t0 # molecule nr 0\n\
+Ion_Type1_1\t0.758602\t0.000000000\t0.504284\t0 # molecule nr 1\n\
+Ion_Type1_2\t0.758602\t0.000000000\t-0.504284\t0 # molecule nr 2\n";
+static string waterMpqc ="% Created by MoleCuilder\n\
+mpqc: (\n\
+\tsavestate = no\n\
+\tdo_gradient = yes\n\
+\tmole<MBPT2>: (\n\
+\t\tmaxiter = 200\n\
+\t\tbasis = $:basis\n\
+\t\tmolecule = $:molecule\n\
+\t\treference<CLHF>: (\n\
+\t\t\tbasis = $:basis\n\
+\t\t\tmolecule = $:molecule\n\
+\t\t)\n\
+\t)\n\
+)\n\
+molecule<Molecule>: (\n\
+\tunit = angstrom\n\
+\t{ atoms geometry } = {\n\
+\t\tO [ -0.505735\t0\t0 ]\n\
+\t\tH [ 0.252867\t0\t0.504284 ]\n\
+\t\tH [ 0.252867\t0\t-0.504284 ]\n\
+\t}\n\
+)\n\
+basis<GaussianBasisSet>: (\n\
+\tname = \"3-21G\"\n\
+\tmolecule = $:molecule\n\
+)\n";
+static string waterXyz = "3\n\tH2O: water molecule\nO\t0\t0\t0\nH\t0.758602\t0\t0.504284\nH\t0.758602\t0\t-0.504284\n";
+static string Tremolo_Atomdata1 = "# ATOMDATA\tId\tname\tType\tx=3\n";
+static string Tremolo_Atomdata2 = "#\n#ATOMDATA Id name Type x=3\n1 hydrogen H 3.0 4.5 0.1\n\n";
+static string Tremolo_invalidkey = "#\n#ATOMDATA Id name foo Type x=3\n\n\n";
+static string Tremolo_velocity = "#\n#ATOMDATA Id name Type u=3\n1 hydrogen H 3.0 4.5 0.1\n\n";
+static string Tremolo_neighbours = "#\n#ATOMDATA Id Type neighbors=2\n1 H 3 0\n2 H 3 0\n3 O 1 2\n";
+static string Tremolo_improper = "#\n#ATOMDATA Id Type imprData\n8 H 9-10\n9 H 10-8,8-10\n10 O -\n";
+static string Tremolo_torsion = "#\n#ATOMDATA Id Type torsion\n8 H 9-10\n9 H 10-8,8-10\n10 O -\n";
+static string Tremolo_full = "# ATOMDATA\tx=3\tu=3\tF\tstress\tId\tneighbors=5\timprData\tGroupMeasureTypeNo\tType\textType\tname\tresName\tchainID\tresSeq\toccupancy\ttempFactor\tsegID\tCharge\tcharge\tGrpTypeNo\ttorsion\n0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t-\t0\tH\t-\t-\t-\t0\t0\t0\t0\t0\t0\t0\t0\t-\t\n";
+
+void ParserUnitTest::setUp() {
+  World::getInstance();
+
+  // we need hydrogens and oxygens in the following tests
+  CPPUNIT_ASSERT(World::getInstance().getPeriode()->FindElement(1) != NULL);
+  CPPUNIT_ASSERT(World::getInstance().getPeriode()->FindElement(8) != NULL);
+}
+
+void ParserUnitTest::tearDown() {
+  ChangeTracker::purgeInstance();
+  World::purgeInstance();
+}
+
+/************************************ tests ***********************************/
+
+void ParserUnitTest::rewriteAnXyzTest() {
+  cout << "Testing the XYZ parser." << endl;
+  XyzParser* testParser = new XyzParser();
+  stringstream input;
+  input << waterXyz;
+  testParser->load(&input);
+
+  CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms());
+
+  string newWaterXyz = "";
+  stringstream output;
+  testParser->save(&output);
+  newWaterXyz = output.str();
+
+  CPPUNIT_ASSERT(waterXyz == newWaterXyz);
+}
+
+void ParserUnitTest::readTremoloPreliminaryCommentsTest() {
+  cout << "Testing the tremolo parser." << endl;
+  TremoloParser* testParser = new TremoloParser();
+  stringstream input, output;
+
+  // Atomdata beginning with "# ATOMDATA"
+  input << Tremolo_Atomdata1;
+  testParser->load(&input);
+  testParser->save(&output);
+  CPPUNIT_ASSERT(Tremolo_Atomdata1 == output.str());
+  input.clear();
+  output.clear();
+
+  // Atomdata beginning with "#ATOMDATA"
+  input << Tremolo_Atomdata2;
+  testParser->load(&input);
+  testParser->save(&output);
+  CPPUNIT_ASSERT(output.str().find("hydrogen") != string::npos);
+  input.clear();
+  output.clear();
+
+  // Invalid key in Atomdata line
+  input << Tremolo_invalidkey;
+  testParser->load(&input);
+  //TODO: proove invalidity
+  input.clear();
+}
+
+void ParserUnitTest::readTremoloCoordinatesTest() {
+  TremoloParser* testParser = new TremoloParser();
+  stringstream input;
+
+  // One simple data line
+  input << Tremolo_Atomdata2;
+  testParser->load(&input);
+  CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->x[0] == 3.0);
+  input.clear();
+}
+
+void ParserUnitTest::readTremoloVelocityTest() {
+  TremoloParser* testParser = new TremoloParser();
+  stringstream input;
+
+  // One simple data line
+  input << Tremolo_velocity;
+  testParser->load(&input);
+  CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->v[0] == 3.0);
+  input.clear();
+}
+
+void ParserUnitTest::readTremoloNeighborInformationTest() {
+  TremoloParser* testParser = new TremoloParser();
+  stringstream input;
+
+  // Neighbor data
+  input << Tremolo_neighbours;
+  testParser->load(&input);
+
+  CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms());
+  CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(8))->
+      IsBondedTo(World::getInstance().getAtom(AtomByType(1))));
+  input.clear();
+}
+
+void ParserUnitTest::readAndWriteTremoloImprDataInformationTest() {
+  TremoloParser* testParser = new TremoloParser();
+  stringstream input, output;
+
+  // Neighbor data
+  input << Tremolo_improper;
+  testParser->load(&input);
+  testParser->save(&output);
+  CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms());
+  CPPUNIT_ASSERT(output.str().find("2-0,0-2") != string::npos);
+  input.clear();
+  output.clear();
+}
+
+void ParserUnitTest::readAndWriteTremoloTorsionInformationTest() {
+  TremoloParser* testParser = new TremoloParser();
+  stringstream input, output;
+
+  // Neighbor data
+  input << Tremolo_torsion;
+  testParser->load(&input);
+  testParser->save(&output);
+  CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms());
+  CPPUNIT_ASSERT(output.str().find("2-0,0-2") != string::npos);
+  input.clear();
+  output.clear();
+}
+
+void ParserUnitTest::writeTremoloTest() {
+  TremoloParser* testParser = new TremoloParser();
+  stringstream output;
+
+  // 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);
+  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);
+  CPPUNIT_ASSERT(output.str() == Tremolo_full);
+
+  cout << "testing the tremolo parser is done" << endl;
+}
+
+void ParserUnitTest::readwritePcpTest() {
+  stringstream input(waterPcp);
+  PcpParser* testParser = new PcpParser();
+  testParser->load(&input);
+  input.clear();
+
+  CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms());
+
+  string newWaterPcp = "";
+  stringstream output;
+  testParser->save(&output);
+
+  input << output;
+  PcpParser* testParser2 = new PcpParser();
+  testParser2->load(&input);
+
+  CPPUNIT_ASSERT_EQUAL(6, World::getInstance().numAtoms());
+
+  CPPUNIT_ASSERT(*testParser == *testParser2);
+}
+
+void ParserUnitTest::writeMpqcTest() {
+  // build up water molecule
+  atom *Walker = NULL;
+  Walker = World::getInstance().createAtom();
+  Walker->type = World::getInstance().getPeriode()->FindElement(8);
+  Walker->x = Vector(0,0,0);
+  Walker = World::getInstance().createAtom();
+  Walker->type = World::getInstance().getPeriode()->FindElement(1);
+  Walker->x = 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);
+  CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms());
+
+  // create two stringstreams, one stored, one created
+  stringstream input(waterMpqc);
+  MpqcParser* testParser = new MpqcParser();
+  stringstream output;
+  testParser->save(&output);
+
+  // compare both configs
+  string first = input.str();
+  string second = output.str();
+  CPPUNIT_ASSERT(first == second);
+}
Index: src/unittests/ParserUnitTest.hpp
===================================================================
--- src/unittests/ParserUnitTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/ParserUnitTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,44 @@
+/*
+ * ParserUnitTest.hpp
+ *
+ *  Created on: Mar 3, 2010
+ *      Author: metzler
+ */
+#ifndef PARSERUNITTEST_HPP_
+#define PARSERUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <string>
+
+class ParserUnitTest :  public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( ParserUnitTest ) ;
+  CPPUNIT_TEST ( rewriteAnXyzTest );
+  CPPUNIT_TEST ( readTremoloPreliminaryCommentsTest );
+  CPPUNIT_TEST ( readTremoloCoordinatesTest );
+  CPPUNIT_TEST ( readTremoloVelocityTest );
+  CPPUNIT_TEST ( readTremoloNeighborInformationTest );
+  CPPUNIT_TEST ( readAndWriteTremoloImprDataInformationTest );
+  CPPUNIT_TEST ( readAndWriteTremoloTorsionInformationTest );
+  CPPUNIT_TEST ( writeTremoloTest );
+  CPPUNIT_TEST ( readwritePcpTest );
+  CPPUNIT_TEST ( writeMpqcTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void rewriteAnXyzTest();
+  void readTremoloPreliminaryCommentsTest();
+  void readTremoloCoordinatesTest();
+  void readTremoloVelocityTest();
+  void readTremoloNeighborInformationTest();
+  void readAndWriteTremoloImprDataInformationTest();
+  void readAndWriteTremoloTorsionInformationTest();
+  void writeTremoloTest();
+  void readwritePcpTest();
+  void writeMpqcTest();
+};
+
+#endif /* PARSERUNITTEST_HPP_ */
Index: src/unittests/PlaneUnittest.cpp
===================================================================
--- src/unittests/PlaneUnittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/PlaneUnittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,216 @@
+/*
+ * PlaneUnittest.cpp
+ *
+ *  Created on: Apr 30, 2010
+ *      Author: crueger
+ */
+
+#include "PlaneUnittest.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 "vector.hpp"
+#include "Line.hpp"
+
+CPPUNIT_TEST_SUITE_REGISTRATION( PlaneUnittest );
+
+void PlaneUnittest::setUp(){
+  p1 = new Plane(e1,e2,e3);
+  p2 = new Plane(e1,e2,zeroVec);
+  p3 = new Plane(e1,zeroVec,e3);
+  p4 = new Plane(zeroVec,e2,e3);
+}
+
+void PlaneUnittest::tearDown(){
+  delete p1;
+  delete p2;
+  delete p3;
+  delete p4;
+}
+
+void PlaneUnittest::constructionErrorTest(){
+  // try several method of construction..
+  // see if error checking works
+
+  // three points
+  CPPUNIT_ASSERT_NO_THROW(Plane(e1,e2,e3));
+  // when only two points are differnt this gives an error
+  CPPUNIT_ASSERT_THROW(Plane(e1,e2,e2),LinearDependenceException);
+  // same with only one point
+  CPPUNIT_ASSERT_THROW(Plane(e1,e1,e1),LinearDependenceException);
+
+  // use two vector giving two directions
+  CPPUNIT_ASSERT_NO_THROW(Plane(e1,e2,0));
+  // and again this is actually only one vector
+  CPPUNIT_ASSERT_THROW(Plane(e1,e1,0),LinearDependenceException);
+  // Zero vector does not give a good direction
+  CPPUNIT_ASSERT_THROW(Plane(e1,zeroVec,0),ZeroVectorException);
+
+  // use a normalvector and an scalar offset
+  CPPUNIT_ASSERT_NO_THROW(Plane(e1,0));
+  // The zero vector is no good as a normalvector
+  CPPUNIT_ASSERT_THROW(Plane(zeroVec,0),ZeroVectorException);
+
+  // use a normalvector and an offset vector
+  CPPUNIT_ASSERT_NO_THROW(Plane(e1,zeroVec));
+  // and the bad zeroVector again
+  CPPUNIT_ASSERT_THROW(Plane(zeroVec,zeroVec),ZeroVectorException);
+}
+
+
+// we need to test normals independent of the direction
+bool testNormal(const Vector &normal1, const Vector &normal2){
+  return (normal1==normal2) || (normal1==-1*normal2);
+}
+
+void PlaneUnittest::constructionResultTest(){
+  {
+    // construct with three points on plane
+    Plane p1(e1,e2,zeroVec);
+    CPPUNIT_ASSERT(testNormal(e3,p1.getNormal()));
+    CPPUNIT_ASSERT_EQUAL(0.,p1.getOffset());
+
+    Plane p2(e1,e3,zeroVec);
+    CPPUNIT_ASSERT(testNormal(e2,p2.getNormal()));
+    CPPUNIT_ASSERT_EQUAL(0.,p2.getOffset());
+
+    Plane p3(e2,e3,zeroVec);
+    CPPUNIT_ASSERT(testNormal(e1,p3.getNormal()));
+    CPPUNIT_ASSERT_EQUAL(0.,p3.getOffset());
+  }
+  {
+    // construct with two directions + offset
+    Plane p1(e1,e2,0);
+    CPPUNIT_ASSERT(testNormal(e3,p1.getNormal()));
+    CPPUNIT_ASSERT_EQUAL(0.,p1.getOffset());
+
+    Plane p2(e1,e3,0);
+    CPPUNIT_ASSERT(testNormal(e2,p2.getNormal()));
+    CPPUNIT_ASSERT_EQUAL(0.,p2.getOffset());
+
+    Plane p3(e2,e3,0);
+    CPPUNIT_ASSERT(testNormal(e1,p3.getNormal()));
+    CPPUNIT_ASSERT_EQUAL(0.,p3.getOffset());
+  }
+}
+
+void PlaneUnittest::pointsTest(){
+  std::vector<Vector> points1 = p1->getPointsOnPlane();
+  CPPUNIT_ASSERT(p1->isContained(points1[0]));
+  CPPUNIT_ASSERT(p1->isContained(points1[1]));
+  CPPUNIT_ASSERT(p1->isContained(points1[2]));
+  // check that the three points differ
+  CPPUNIT_ASSERT(points1[0]!=points1[1]);
+  CPPUNIT_ASSERT(points1[0]!=points1[2]);
+  CPPUNIT_ASSERT(points1[1]!=points1[2]);
+
+
+  std::vector<Vector> points2 = p2->getPointsOnPlane();
+  CPPUNIT_ASSERT(p2->isContained(points2[0]));
+  CPPUNIT_ASSERT(p2->isContained(points2[1]));
+  CPPUNIT_ASSERT(p2->isContained(points2[2]));
+  // check that the three points differ
+  CPPUNIT_ASSERT(points2[0]!=points2[1]);
+  CPPUNIT_ASSERT(points2[0]!=points2[2]);
+  CPPUNIT_ASSERT(points2[1]!=points2[2]);
+
+  std::vector<Vector> points3 = p3->getPointsOnPlane();
+  CPPUNIT_ASSERT(p3->isContained(points3[0]));
+  CPPUNIT_ASSERT(p3->isContained(points3[1]));
+  CPPUNIT_ASSERT(p3->isContained(points3[2]));
+  // check that the three points differ
+  CPPUNIT_ASSERT(points3[0]!=points3[1]);
+  CPPUNIT_ASSERT(points3[0]!=points3[2]);
+  CPPUNIT_ASSERT(points3[1]!=points3[2]);
+
+  std::vector<Vector> points4 = p4->getPointsOnPlane();
+  CPPUNIT_ASSERT(p4->isContained(points4[0]));
+  CPPUNIT_ASSERT(p4->isContained(points4[1]));
+  CPPUNIT_ASSERT(p4->isContained(points4[2]));
+  // check that the three points differ
+  CPPUNIT_ASSERT(points4[0]!=points4[1]);
+  CPPUNIT_ASSERT(points4[0]!=points4[2]);
+  CPPUNIT_ASSERT(points4[1]!=points4[2]);
+}
+
+
+void PlaneUnittest::operationsTest(){
+  {
+    Vector t = (1./3.)*(e1+e2+e3);
+    CPPUNIT_ASSERT(fabs(p1->distance(zeroVec)-t.Norm()) < MYEPSILON);
+    CPPUNIT_ASSERT_EQUAL(t,p1->getClosestPoint(zeroVec));
+  }
+
+  CPPUNIT_ASSERT(fabs(p2->distance(e3)-1) < MYEPSILON);
+  CPPUNIT_ASSERT_EQUAL(zeroVec,p2->getClosestPoint(e3));
+  CPPUNIT_ASSERT(fabs(p3->distance(e2)-1) < MYEPSILON);
+  CPPUNIT_ASSERT_EQUAL(zeroVec,p3->getClosestPoint(e2));
+  CPPUNIT_ASSERT(fabs(p4->distance(e1)-1) < MYEPSILON);
+  CPPUNIT_ASSERT_EQUAL(zeroVec,p4->getClosestPoint(e1));
+}
+
+void PlaneUnittest::mirrorTest(){
+  Vector fixture;
+
+  // some Vectors that lie on the planes
+  fixture = p1->mirrorVector(e1);
+  CPPUNIT_ASSERT_EQUAL(fixture,e1);
+  fixture = p1->mirrorVector(e2);
+  CPPUNIT_ASSERT_EQUAL(fixture,e2);
+  fixture = p1->mirrorVector(e3);
+  CPPUNIT_ASSERT_EQUAL(fixture,e3);
+
+  fixture = p2->mirrorVector(zeroVec);
+  CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
+  fixture = p2->mirrorVector(e1);
+  CPPUNIT_ASSERT_EQUAL(fixture,e1);
+  fixture = p2->mirrorVector(e2);
+  CPPUNIT_ASSERT_EQUAL(fixture,e2);
+
+  fixture = p3->mirrorVector(zeroVec);
+  CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
+  fixture = p3->mirrorVector(e1);
+  CPPUNIT_ASSERT_EQUAL(fixture,e1);
+  fixture = p3->mirrorVector(e3);
+  CPPUNIT_ASSERT_EQUAL(fixture,e3);
+
+  fixture = p4->mirrorVector(zeroVec);
+  CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
+  fixture = p4->mirrorVector(e2);
+  CPPUNIT_ASSERT_EQUAL(fixture,e2);
+  fixture = p4->mirrorVector(e3);
+  CPPUNIT_ASSERT_EQUAL(fixture,e3);
+
+  // some Vectors outside of the planes
+  {
+    Vector t = (2./3.)*(e1+e2+e3);
+    fixture = p1->mirrorVector(zeroVec);
+    CPPUNIT_ASSERT_EQUAL(fixture,t);
+  }
+
+  fixture = p2->mirrorVector(e3);
+  CPPUNIT_ASSERT_EQUAL(fixture,-1*e3);
+  fixture = p3->mirrorVector(e2);
+  CPPUNIT_ASSERT_EQUAL(fixture,-1*e2);
+  fixture = p4->mirrorVector(e1);
+  CPPUNIT_ASSERT_EQUAL(fixture,-1*e1);
+}
+
+void PlaneUnittest::LineIntersectionTest(){
+  Vector fixture;
+  // plane at (0,0,0) normal to (1,0,0) cuts line from (0,0,0) to (2,1,0) at ???
+  Line l1 = makeLineThrough(zeroVec,Vector(2,1,0));
+  CPPUNIT_ASSERT_NO_THROW(fixture = Plane(e1, zeroVec).GetIntersection(l1) );
+  CPPUNIT_ASSERT_EQUAL( zeroVec, fixture );
+
+  // plane at (2,1,0) normal to (0,1,0) cuts line from (1,0,0) to (0,1,1) at ???
+  Line l2 = makeLineThrough(e1,Vector(0,1,1));
+  CPPUNIT_ASSERT_NO_THROW(fixture = Plane(e2, Vector(2,1,0)).GetIntersection(l2) );
+  CPPUNIT_ASSERT_EQUAL( Vector(0., 1., 1.), fixture );
+}
Index: src/unittests/PlaneUnittest.hpp
===================================================================
--- src/unittests/PlaneUnittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/PlaneUnittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,44 @@
+/*
+ * PlaneUnittest.hpp
+ *
+ *  Created on: Apr 30, 2010
+ *      Author: crueger
+ */
+
+#ifndef PLANEUNITTEST_HPP_
+#define PLANEUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "Plane.hpp"
+
+class PlaneUnittest : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( PlaneUnittest) ;
+  CPPUNIT_TEST ( constructionErrorTest );
+  CPPUNIT_TEST ( constructionResultTest );
+  CPPUNIT_TEST ( pointsTest );
+  CPPUNIT_TEST ( operationsTest );
+  CPPUNIT_TEST ( mirrorTest );
+  CPPUNIT_TEST ( LineIntersectionTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void constructionErrorTest();
+  void constructionResultTest();
+  void pointsTest();
+  void operationsTest();
+  void mirrorTest();
+  void LineIntersectionTest();
+
+private:
+  Plane *p1;
+  Plane *p2;
+  Plane *p3;
+  Plane *p4;
+};
+
+#endif /* PLANEUNITTEST_HPP_ */
Index: src/unittests/SingletonTest.cpp
===================================================================
--- src/unittests/SingletonTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/SingletonTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,143 @@
+/*
+ * SingletonTest.cpp
+ *
+ *  Created on: Mar 11, 2010
+ *      Author: crueger
+ */
+
+#include "SingletonTest.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include <iostream>
+
+#include "Patterns/Singleton.hpp"
+#include "Patterns/Singleton_impl.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+CPPUNIT_TEST_SUITE_REGISTRATION( SingletonTest );
+
+// some necessary stubs
+class SingletonStub1 : public Singleton <SingletonStub1>{
+  friend class Singleton<SingletonStub1>;
+private:
+  SingletonStub1(){
+    count1++;
+  }
+  // explicit copy constructor to catch if this is ever called
+  SingletonStub1(const SingletonStub1&){
+    CPPUNIT_FAIL    ( "Copy constructor of Singleton called" );
+  }
+  virtual ~SingletonStub1(){
+    count2++;
+  }
+public:
+  static int count1;
+  static int count2;
+};
+
+int SingletonStub1::count1 = 0;
+int SingletonStub1::count2 = 0;
+
+CONSTRUCT_SINGLETON(SingletonStub1);
+
+class SingletonStub2 : public Singleton<SingletonStub2>{
+  friend class Singleton<SingletonStub2>;
+private:
+  SingletonStub2(){
+    count1++;
+  }
+  // explicit copy constructor to catch if this is ever called
+  SingletonStub2(const SingletonStub2&){
+    CPPUNIT_FAIL    ( "Copy constructor of Singleton called" );
+  }
+  virtual ~SingletonStub2(){
+    count2++;
+  }
+public:
+  static int count1;
+  static int count2;
+};
+
+int SingletonStub2::count1 = 0;
+int SingletonStub2::count2 = 0;
+
+CONSTRUCT_SINGLETON(SingletonStub2);
+
+void SingletonTest::setUp(){}
+void SingletonTest::tearDown(){}
+
+void SingletonTest::ConstructionTest(){
+  void *ptr_1_1 = reinterpret_cast<void*>(SingletonStub1::getPointer());
+  void *ptr_1_2 = reinterpret_cast<void*>(SingletonStub1::getPointer());
+  void *ptr_1_3 = reinterpret_cast<void*>(&(SingletonStub1::getInstance()));
+
+  // test if we always get the same instance of our singleton
+  CPPUNIT_ASSERT_EQUAL(ptr_1_1,ptr_1_2);
+  CPPUNIT_ASSERT_EQUAL(ptr_1_1,ptr_1_3);
+
+  void *ptr_2_1 = reinterpret_cast<void*>(SingletonStub2::getPointer());
+  void *ptr_2_2 = reinterpret_cast<void*>(SingletonStub2::getPointer());
+  void *ptr_2_3 = reinterpret_cast<void*>(&(SingletonStub2::getInstance()));
+
+  // same as above but for a different singleton
+  CPPUNIT_ASSERT_EQUAL(ptr_2_1,ptr_2_2);
+  CPPUNIT_ASSERT_EQUAL(ptr_2_1,ptr_2_3);
+
+  // see if the two singletons actually differ
+  CPPUNIT_ASSERT(ptr_1_1!=ptr_2_1);
+
+  // see if each constructor was called exactly once
+  CPPUNIT_ASSERT_EQUAL(1,SingletonStub1::count1);
+  CPPUNIT_ASSERT_EQUAL(1,SingletonStub2::count1);
+  // no calls to the destructor should have occured so far
+  CPPUNIT_ASSERT_EQUAL(0,SingletonStub1::count2);
+  CPPUNIT_ASSERT_EQUAL(0,SingletonStub2::count2);
+
+  SingletonStub1::purgeInstance();
+
+  void *ptr_3_1 = reinterpret_cast<void*>(SingletonStub1::getPointer());
+  void *ptr_3_2 = reinterpret_cast<void*>(SingletonStub1::getPointer());
+
+  // now the constructor should have been called twice
+  CPPUNIT_ASSERT_EQUAL(2,SingletonStub1::count1);
+  // the destructor should have been called once
+  CPPUNIT_ASSERT_EQUAL(1,SingletonStub1::count2);
+  // see if the singleton Assumption holds
+  CPPUNIT_ASSERT_EQUAL(ptr_3_1,ptr_3_2);
+  // Some esoteric thing might cause our pointer to lay at the position of Singleton2 now
+  // See that those two objects still differ
+  CPPUNIT_ASSERT(ptr_3_1!=ptr_2_1);
+  // don't test for pointer difference between first and second singleton here,
+  // because they might be constructed in the same place
+
+
+  SingletonStub2::resetInstance();
+  // now the constructor should have been called twice
+  CPPUNIT_ASSERT_EQUAL(2,SingletonStub2::count1);
+  // the destructor should have been called once
+  CPPUNIT_ASSERT_EQUAL(1,SingletonStub2::count2);
+
+  void *ptr_4_1 = reinterpret_cast<void*>(SingletonStub2::getPointer());
+  void *ptr_4_2 = reinterpret_cast<void*>(SingletonStub2::getPointer());
+
+  // Still only two calls to the constructor, one call to destructor
+  CPPUNIT_ASSERT_EQUAL(2,SingletonStub2::count1);
+  CPPUNIT_ASSERT_EQUAL(1,SingletonStub2::count2);
+
+  // test if Singleton assumption can be broken by reset
+  CPPUNIT_ASSERT_EQUAL(ptr_4_1,ptr_4_2);
+
+  // and again test if we actually have a object seperate from anything else
+  CPPUNIT_ASSERT(ptr_4_1!=ptr_3_1);
+
+
+  // we don't purge our singletons here. Purging should be done automatically by the Singleton
+  // mechanism. Check with Valgrind to see if memory-leak occurs
+  std::cout << "Not purging Singleton!\n Check with Valgrind to see if automatic purgins is working!" << std::endl;
+
+}
Index: src/unittests/SingletonTest.hpp
===================================================================
--- src/unittests/SingletonTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/SingletonTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,26 @@
+/*
+ * SingletonTest.hpp
+ *
+ *  Created on: Mar 11, 2010
+ *      Author: crueger
+ */
+
+#ifndef SINGLETONTEST_HPP_
+#define SINGLETONTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class SingletonTest : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( SingletonTest );
+  CPPUNIT_TEST ( ConstructionTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void ConstructionTest();
+};
+
+#endif /* SINGLETONTEST_HPP_ */
Index: src/unittests/TestRunnerMain.cpp
===================================================================
--- src/unittests/TestRunnerMain.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/TestRunnerMain.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,24 @@
+/*
+ * TestRunnerMain.cpp
+ *
+ *  Created on: Feb 25, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_ECUT
+// give the main function its correct name
+#define CPPUNIT_MAIN main
+// include the TestRunnerClient file containing the main class
+#include "../../../TestRunnerClient.h"
+#include "../../../TestRunnerClient.cpp"
+
+#else
+
+#include "unittests/UnitTestMain.cpp"
+
+#endif /* HAVE_ECUT */
Index: src/unittests/UnitTestMain.cpp
===================================================================
--- src/unittests/UnitTestMain.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/UnitTestMain.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,37 @@
+/*
+ * UnitTestMain.cpp
+ *
+ *  Created on: Feb 24, 2010
+ *      Author: heber
+ */
+
+// 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>
+
+/********************************************** Main routine **************************************/
+
+int main(int argc, char **argv)
+{
+  // Get the top level suite from the registry
+  CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
+
+  // Adds the test to the list of test to run
+  CppUnit::TextUi::TestRunner runner;
+  runner.addTest( suite );
+
+  // Change the default outputter to a compiler error format outputter
+  runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
+                                                       std::cerr ) );
+  // Run the tests.
+  bool wasSucessful = runner.run();
+
+  // Return error code 1 if the one of test failed.
+  return wasSucessful ? 0 : 1;
+};
+
Index: src/unittests/analysisbondsunittest.cpp
===================================================================
--- src/unittests/analysisbondsunittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/analysisbondsunittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,162 @@
+/*
+ * analysisbondsunittest.cpp
+ *
+ *  Created on: Nov 7, 2009
+ *      Author: heber
+ */
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <iostream>
+#include <stdio.h>
+#include <cstring>
+
+#include "World.hpp"
+#include "analysis_bonds.hpp"
+#include "analysisbondsunittest.hpp"
+#include "atom.hpp"
+#include "bond.hpp"
+#include "bondgraph.hpp"
+#include "element.hpp"
+#include "molecule.hpp"
+#include "periodentafel.hpp"
+#include "World.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( AnalysisBondsTest );
+
+
+void AnalysisBondsTest::setUp()
+{
+  atom *Walker = NULL;
+
+  // get elements
+  hydrogen = World::getInstance().getPeriode()->FindElement(1);
+  carbon = World::getInstance().getPeriode()->FindElement(6);
+  CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen");
+  CPPUNIT_ASSERT(carbon != NULL && "could not find element carbon");
+
+  // construct molecule (tetraeder of hydrogens)
+  TestMolecule = World::getInstance().createMolecule();
+  CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule");
+  Walker = World::getInstance().createAtom();
+  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
+  Walker->type = hydrogen;
+  *Walker->node = 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 );
+  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. );
+  TestMolecule->AddAtom(Walker);
+  Walker = World::getInstance().createAtom();
+  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
+  Walker->type = hydrogen;
+  *Walker->node = 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 );
+  TestMolecule->AddAtom(Walker);
+
+  // check that TestMolecule was correctly constructed
+  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 5 );
+
+  // create a small file with table
+  filename = new string("test.dat");
+  CPPUNIT_ASSERT(filename != NULL && "could not create string");
+  ofstream test(filename->c_str());
+  test << ".\tH\tHe\tLi\tBe\tB\tC\n";
+  test << "H\t1.\t1.\t1.\t1.\t1.\t1.2\n";
+  test << "He\t1.\t1.\t1.\t1.\t1.\t1.\n";
+  test << "Li\t1.\t1.\t1.\t1.\t1.\t1.\n";
+  test << "Be\t1.\t1.\t1.\t1.\t1.\t1.\n";
+  test << "B\t1.\t1.\t1.\t1.\t1.\t1.\n";
+  test << "C\t1.2\t1.\t1.\t1.\t1.\t1.5\n";
+  test.close();
+  BG = new BondGraph(true);
+  CPPUNIT_ASSERT(BG != NULL && "could not create BondGraph");
+
+  CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) );
+  CPPUNIT_ASSERT_EQUAL( 1., BG->GetBondLength(0,0) );
+  CPPUNIT_ASSERT_EQUAL( 1.2, BG->GetBondLength(0,5) );
+  CPPUNIT_ASSERT_EQUAL( 1.5, BG->GetBondLength(5,5) );
+
+  BG->ConstructBondGraph(TestMolecule);
+};
+
+
+void AnalysisBondsTest::tearDown()
+{
+  // remove the file
+  remove(filename->c_str());
+  delete(filename);
+  delete(BG);
+
+  // remove molecule
+  World::getInstance().destroyMolecule(TestMolecule);
+  // note that all the atoms are cleaned by TestMolecule
+  World::purgeInstance();
+};
+
+/** UnitTest for GetMaxMinMeanBondCount().
+ */
+void AnalysisBondsTest::GetMaxMinMeanBondCountTest()
+{
+  double Min = 20.; // check that initialization resets these arbitrary values
+  double Mean = 200.;
+  double Max = 1e-6;
+  GetMaxMinMeanBondCount(TestMolecule, Min, Mean, Max);
+  CPPUNIT_ASSERT_EQUAL( 1., Min );
+  CPPUNIT_ASSERT_EQUAL( 1.6, Mean );
+  CPPUNIT_ASSERT_EQUAL( 4., Max );
+
+};
+
+/** UnitTest for MinMaxBondDistanceBetweenElements().
+ */
+void AnalysisBondsTest::MinMeanMaxBondDistanceBetweenElementsTest()
+{
+  double Min = 20.; // check that initialization resets these arbitrary values
+  double Mean = 2e+6;
+  double Max = 1e-6;
+  double Min2 = 20.;
+  double Mean2 = 2e+6;
+  double Max2 = 1e-6;
+  const double maxbondlength = sqrt(1.*1. + 1.*1. + .5*.5);
+  const double minbondlength = sqrt(.5*.5 + .5*.5 + .5*.5);
+  const double meanbondlength = (minbondlength+3.*maxbondlength)/4.;
+  // check bond lengths C-H
+  MinMeanMaxBondDistanceBetweenElements(TestMolecule, hydrogen, carbon, Min, Mean, Max);
+  CPPUNIT_ASSERT_EQUAL( minbondlength , Min );
+  CPPUNIT_ASSERT_EQUAL( meanbondlength , Mean );
+  CPPUNIT_ASSERT_EQUAL( maxbondlength , Max );
+
+  // check that elements are symmetric, i.e. C-H == H-C
+  MinMeanMaxBondDistanceBetweenElements(TestMolecule, carbon, hydrogen, Min2, Mean2, Max2);
+  CPPUNIT_ASSERT_EQUAL( Min , Min2 );
+  CPPUNIT_ASSERT_EQUAL( Mean , Mean2 );
+  CPPUNIT_ASSERT_EQUAL( Max , Max2 );
+
+  // check no bond case (no bonds H-H in system!)
+  MinMeanMaxBondDistanceBetweenElements(TestMolecule, hydrogen, hydrogen, Min, Mean, Max);
+  CPPUNIT_ASSERT_EQUAL( 0. , Min );
+  CPPUNIT_ASSERT_EQUAL( 0. , Mean );
+  CPPUNIT_ASSERT_EQUAL( 0. , Max );
+};
Index: src/unittests/analysisbondsunittest.hpp
===================================================================
--- src/unittests/analysisbondsunittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/analysisbondsunittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,43 @@
+/*
+ * analysisbondsunittest.hpp
+ *
+ *  Created on: Nov 7, 2009
+ *      Author: heber
+ */
+
+#ifndef ANALYSISBONDSUNITTEST_HPP_
+#define ANALYSISBONDSUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class BondGraph;
+class element;
+class molecule;
+class periodentafel;
+
+/********************************************** Test classes **************************************/
+
+class AnalysisBondsTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( AnalysisBondsTest) ;
+    CPPUNIT_TEST ( GetMaxMinMeanBondCountTest );
+    CPPUNIT_TEST ( MinMeanMaxBondDistanceBetweenElementsTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+      void GetMaxMinMeanBondCountTest();
+      void MinMeanMaxBondDistanceBetweenElementsTest();
+
+private:
+
+      molecule *TestMolecule;
+      const element *hydrogen;
+      const element *carbon;
+
+      BondGraph *BG;
+      string *filename;
+};
+
+#endif /* ANALYSISBONDSUNITTEST_HPP_ */
Index: src/unittests/atomsCalculationTest.cpp
===================================================================
--- src/unittests/atomsCalculationTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/atomsCalculationTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,93 @@
+/*
+ * atomsCalculationTest.cpp
+ *
+ *  Created on: Feb 19, 2010
+ *      Author: crueger
+ */
+
+#include "atomsCalculationTest.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include <iostream>
+#include <boost/bind.hpp>
+
+#include "Descriptors/AtomDescriptor.hpp"
+#include "Descriptors/AtomIdDescriptor.hpp"
+#include "Actions/AtomsCalculation.hpp"
+#include "Actions/AtomsCalculation_impl.hpp"
+#include "Actions/ActionRegistry.hpp"
+
+#include "World.hpp"
+#include "World_calculations.hpp"
+#include "atom.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( atomsCalculationTest );
+
+// set up and tear down
+void atomsCalculationTest::setUp(){
+  World::getInstance();
+  for(int i=0;i<ATOM_COUNT;++i){
+    atoms[i]= World::getInstance().createAtom();
+    atomIds[i]= atoms[i]->getId();
+  }
+}
+void atomsCalculationTest::tearDown(){
+  World::purgeInstance();
+  ActionRegistry::purgeInstance();
+}
+
+// some helper functions
+static bool hasAllIds(std::vector<atomId_t> atoms,atomId_t ids[ATOM_COUNT], std::set<atomId_t> excluded = std::set<atomId_t>()){
+  for(int i=0;i<ATOM_COUNT;++i){
+    atomId_t id = ids[i];
+    if(!excluded.count(id)){
+      std::vector<atomId_t>::iterator iter;
+      bool res=false;
+      for(iter=atoms.begin();iter!=atoms.end();++iter){
+        res |= (*iter) == id;
+      }
+      if(!res) {
+        cout << "Atom " << id << " missing in returned list" << endl;
+        return false;
+      }
+    }
+  }
+  return true;
+}
+
+static bool hasNoDuplicates(std::vector<atomId_t> ids){
+  std::set<atomId_t> found;
+  std::vector<atomId_t>::iterator iter;
+  for(iter=ids.begin();iter!=ids.end();++iter){
+    int id = (*iter);
+    if(found.count(id))
+      return false;
+    found.insert(id);
+  }
+  return true;
+}
+
+void atomsCalculationTest::testCalculateSimple(){
+  AtomsCalculation<atomId_t> *calc = World::getInstance().calcOnAtoms<atomId_t>(boost::bind(&atom::getId,_1),"FOO",AllAtoms());
+  std::vector<atomId_t> allIds = (*calc)();
+  CPPUNIT_ASSERT(hasAllIds(allIds,atomIds));
+  CPPUNIT_ASSERT(hasNoDuplicates(allIds));
+}
+
+void atomsCalculationTest::testCalculateExcluded(){
+  atomId_t excluded = atomIds[ATOM_COUNT/2];
+  AtomsCalculation<atomId_t> *calc = World::getInstance().calcOnAtoms<atomId_t>(boost::bind(&atom::getId,_1),"FOO",AllAtoms() && !AtomById(excluded));
+  std::vector<atomId_t> allIds = (*calc)();
+  std::set<atomId_t> excluded_set;
+  excluded_set.insert(excluded);
+  CPPUNIT_ASSERT(hasAllIds(allIds,atomIds,excluded_set));
+  CPPUNIT_ASSERT(hasNoDuplicates(allIds));
+  CPPUNIT_ASSERT_EQUAL((size_t)(ATOM_COUNT-1),allIds.size());
+}
Index: src/unittests/atomsCalculationTest.hpp
===================================================================
--- src/unittests/atomsCalculationTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/atomsCalculationTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,38 @@
+/*
+ * atomsCalculationTest.hpp
+ *
+ *  Created on: Feb 19, 2010
+ *      Author: crueger
+ */
+
+#ifndef ATOMSCALCULATIONTEST_HPP_
+#define ATOMSCALCULATIONTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#define ATOM_COUNT (10)
+
+#include "types.hpp"
+
+class atom;
+
+class atomsCalculationTest :  public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( atomsCalculationTest );
+  CPPUNIT_TEST ( testCalculateSimple );
+  CPPUNIT_TEST ( testCalculateExcluded );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void testCalculateSimple();
+  void testCalculateExcluded();
+
+private:
+  atom *atoms [ATOM_COUNT];
+  atomId_t atomIds [ATOM_COUNT];
+};
+
+#endif /* ATOMSCALCULATIONTEST_HPP_ */
Index: src/unittests/bondgraphunittest.cpp
===================================================================
--- src/unittests/bondgraphunittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/bondgraphunittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,160 @@
+/*
+ * bondgraphunittest.cpp
+ *
+ *  Created on: Oct 29, 2009
+ *      Author: heber
+ */
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <iostream>
+#include <stdio.h>
+#include <cstring>
+
+#include "Helpers/Assert.hpp"
+
+#include "World.hpp"
+#include "atom.hpp"
+#include "bond.hpp"
+#include "bondgraph.hpp"
+#include "element.hpp"
+#include "log.hpp"
+#include "molecule.hpp"
+#include "periodentafel.hpp"
+#include "bondgraphunittest.hpp"
+#include "World.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( BondGraphTest );
+
+
+void BondGraphTest::setUp()
+{
+  atom *Walker = NULL;
+
+  // construct element
+  hydrogen = World::getInstance().getPeriode()->FindElement(1);
+  carbon = World::getInstance().getPeriode()->FindElement(6);
+  CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen");
+  CPPUNIT_ASSERT(carbon != NULL && "could not find element carbon");
+
+  // construct molecule (tetraeder of hydrogens)
+  TestMolecule = World::getInstance().createMolecule();
+  CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule");
+  Walker = World::getInstance().createAtom();
+  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
+  Walker->type = carbon;
+  *Walker->node = 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. );
+  TestMolecule->AddAtom(Walker);
+
+  Walker = World::getInstance().createAtom();
+  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
+  Walker->type = carbon;
+  *Walker->node = 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. );
+  TestMolecule->AddAtom(Walker);
+
+  // check that TestMolecule was correctly constructed
+  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 );
+
+  // create a small file with table
+  dummyname = new string("dummy.dat");
+  CPPUNIT_ASSERT(dummyname != NULL && "could not create string");
+  filename = new string("test.dat");
+  CPPUNIT_ASSERT(filename != NULL && "could not create string");
+  ofstream test(filename->c_str());
+  test << ".\tH\tHe\tLi\tBe\tB\tC\n";
+  test << "H\t1.\t1.\t1.\t1.\t1.\t1.2\n";
+  test << "He\t1.\t1.\t1.\t1.\t1.\t1.\n";
+  test << "Li\t1.\t1.\t1.\t1.\t1.\t1.\n";
+  test << "Be\t1.\t1.\t1.\t1.\t1.\t1.\n";
+  test << "B\t1.\t1.\t1.\t1.\t1.\t1.\n";
+  test << "C\t1.2\t1.\t1.\t1.\t1.\t1.5\n";
+  test.close();
+  BG = new BondGraph(true);
+  CPPUNIT_ASSERT(BG != NULL && "could not create BondGraph");
+};
+
+
+void BondGraphTest::tearDown()
+{
+  // remove the file
+  remove(filename->c_str());
+  delete(filename);
+  delete(dummyname);
+  delete(BG);
+
+  // remove molecule
+  World::getInstance().destroyMolecule(TestMolecule);
+  // note that all the atoms, molecules, the tafel and the elements
+  // are all cleaned when the world is destroyed
+  World::purgeInstance();
+  logger::purgeInstance();
+};
+
+/** Tests whether setup worked.
+ */
+void BondGraphTest::SetupTest()
+{
+  CPPUNIT_ASSERT_EQUAL (false, TestMolecule->empty());
+  CPPUNIT_ASSERT_EQUAL ((size_t)4, TestMolecule->size());
+};
+
+/** UnitTest for BondGraphTest::LoadBondLengthTable().
+ */
+void BondGraphTest::LoadTableTest()
+{
+  CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) );
+  CPPUNIT_ASSERT_EQUAL( 1., BG->GetBondLength(0,0) );
+  CPPUNIT_ASSERT_EQUAL( 1.2, BG->GetBondLength(0,5) );
+  CPPUNIT_ASSERT_EQUAL( 1.5, BG->GetBondLength(5,5) );
+};
+
+/** UnitTest for BondGraphTest::ConstructBondGraph().
+ */
+void BondGraphTest::ConstructGraphFromTableTest()
+{
+  molecule::iterator Walker = TestMolecule->begin();
+  molecule::iterator Runner = TestMolecule->begin();
+  Runner++;
+  CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) );
+  CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) );
+  CPPUNIT_ASSERT_EQUAL( true , (*Walker)->IsBondedTo((*Runner)) );
+};
+
+/** UnitTest for BondGraphTest::ConstructBondGraph().
+ */
+void BondGraphTest::ConstructGraphFromCovalentRadiiTest()
+{
+
+  //atom *Walker = TestMolecule->start->next;
+  //atom *Runner = TestMolecule->end->previous;
+  //CPPUNIT_ASSERT( TestMolecule->end != Walker );
+  CPPUNIT_ASSERT_EQUAL( false , BG->LoadBondLengthTable(*dummyname) );
+  CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) );
+
+  // this cannot be assured using dynamic IDs
+  //CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) );
+};
+
Index: src/unittests/bondgraphunittest.hpp
===================================================================
--- src/unittests/bondgraphunittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/bondgraphunittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,49 @@
+/*
+ * bondgraphunittest.hpp
+ *
+ *  Created on: Oct 29, 2009
+ *      Author: heber
+ */
+
+#ifndef BONDGRAPHUNITTEST_HPP_
+#define BONDGRAPHUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+
+class BondGraph;
+class element;
+class molecule;
+class periodentafel;
+
+/********************************************** Test classes **************************************/
+
+class BondGraphTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( BondGraphTest) ;
+    CPPUNIT_TEST ( SetupTest );
+    CPPUNIT_TEST ( LoadTableTest );
+    CPPUNIT_TEST ( ConstructGraphFromTableTest );
+    CPPUNIT_TEST ( ConstructGraphFromCovalentRadiiTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+      void SetupTest();
+      void LoadTableTest();
+      void ConstructGraphFromTableTest();
+      void ConstructGraphFromCovalentRadiiTest();
+
+private:
+
+      molecule *TestMolecule;
+      const element *hydrogen;
+      const element *carbon;
+
+      BondGraph *BG;
+      string *filename;
+      string *dummyname;
+};
+
+#endif /* BONDGRAPHUNITTEST_HPP_ */
Index: src/unittests/gslmatrixsymmetricunittest.cpp
===================================================================
--- src/unittests/gslmatrixsymmetricunittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/gslmatrixsymmetricunittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,271 @@
+/*
+ * gslmatrixunittest.cpp
+ *
+ *  Created on: Jan 8, 2010
+ *      Author: heber
+ */
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "gslmatrixsymmetricunittest.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( GSLMatrixSymmetricTest );
+
+
+void GSLMatrixSymmetricTest::setUp()
+{
+  m = new GSLMatrix(3,3);
+};
+
+void GSLMatrixSymmetricTest::tearDown()
+{
+  delete(m);
+};
+
+/** Unit Test for accessing matrix elements.
+ *
+ */
+void GSLMatrixSymmetricTest::AccessTest()
+{
+  // check whether all elements are initially zero
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( 0., m->Get(i,j) );
+
+  // set
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      m->Set(i,j, i*3+j );
+
+  // and check
+  double *ptr = NULL;
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++) {
+      CPPUNIT_ASSERT_EQUAL( (double)(i*3+j), m->Get(i,j) );
+      ptr = m->Pointer(i,j);
+      CPPUNIT_ASSERT_EQUAL( (double)(i*3+j), *ptr );
+    }
+
+  // assignment
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      m->Set(i,j, i*3+j );
+  GSLMatrix *dest = new GSLMatrix(3,3);
+  *dest = *m;
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( dest->Get(i,j), m->Get(i,j) );
+  delete(dest);
+
+  // out of bounds
+  //CPPUNIT_ASSERT_EQUAL(0., v->Get(4,2) );
+  //CPPUNIT_ASSERT_EQUAL(0., v->Get(2,17) );
+  //CPPUNIT_ASSERT_EQUAL(0., v->Get(1024,140040) );
+  //CPPUNIT_ASSERT_EQUAL(0., v->Get(-1,0) );
+  //CPPUNIT_ASSERT_EQUAL(0., v->Get(0,-1) );
+  //CPPUNIT_ASSERT_EQUAL(0., v->Get(-1,-1) );
+};
+
+/** Unit Test for initializating matrices.
+ *
+ */
+void GSLMatrixSymmetricTest::InitializationTest()
+{
+  // set zero
+  m->SetZero();
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( 0., m->Get(i,j) );
+
+  // set all
+  m->SetAll(1.5);
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( 1.5, m->Get(i,j) );
+
+  // set basis
+  m->SetIdentity();
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( i == j ? 1. : 0. , m->Get(i,j) );
+
+  // set from array
+  double array[] = { 1., 0., 0.,
+                     0., 1., 0.,
+                     0., 0., 1. };
+  m->SetFromDoubleArray(array);
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( i == j ? 1. : 0. , m->Get(i,j) );
+
+};
+
+/** Unit Test for copying matrices.
+ *
+ */
+void GSLMatrixSymmetricTest::CopyTest()
+{
+  // set basis
+  GSLMatrix *dest = NULL;
+  for (int i=0;i<3;i++) {
+    m->SetAll(i);
+    dest = new GSLMatrix(m);
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( m->Get(i,j) , dest->Get(i,j) );
+
+    delete(dest);
+  }
+};
+
+/** Unit Test for exchanging rows and columns.
+ *
+ */
+void GSLMatrixSymmetricTest::ExchangeTest()
+{
+  // set to 1,1,1,2, ...
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      m->Set(i,j, i+1 );
+
+  // swap such that nothing happens
+  m->SwapColumns(1,2);
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( (double)i+1., m->Get(i,j) );
+
+  // swap two rows
+  m->SwapRows(1,2);
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      switch (j) {
+        case 0:
+          CPPUNIT_ASSERT_EQUAL( 1., m->Get(j,i) );
+          break;
+        case 1:
+          CPPUNIT_ASSERT_EQUAL( 3., m->Get(j,i) );
+          break;
+        case 2:
+          CPPUNIT_ASSERT_EQUAL( 2., m->Get(j,i) );
+          break;
+        default:
+          CPPUNIT_ASSERT_EQUAL( -1., m->Get(i,j) );
+      }
+  // check that op is reversable
+  m->SwapRows(1,2);
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( (double)i+1., m->Get(i,j) );
+
+  // set to 1,2,3,1, ...
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      m->Set(i,j, j+1. );
+
+  // swap such that nothing happens
+  m->SwapRows(0,2);
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( (double)j+1., m->Get(i,j) );
+
+  // swap two columns
+  m->SwapColumns(0,2);
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      switch (j) {
+        case 0:
+          CPPUNIT_ASSERT_EQUAL( 3., m->Get(i,j) );
+          break;
+        case 1:
+          CPPUNIT_ASSERT_EQUAL( 2., m->Get(i,j) );
+          break;
+        case 2:
+          CPPUNIT_ASSERT_EQUAL( 1., m->Get(i,j) );
+          break;
+        default:
+          CPPUNIT_ASSERT_EQUAL( -1., m->Get(i,j) );
+      }
+  // check that op is reversable
+  m->SwapColumns(0,2);
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( (double)j+1., m->Get(i,j) );
+
+
+  // set to 1,2,3,4, ...
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      m->Set(i,j, 3*i+j+1 );
+  // transpose
+  m->Transpose();
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( (double)(3*i+j+1), m->Get(j,i) );
+  // second transpose
+  m->Transpose();
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( (double)(3*i+j+1), m->Get(i,j) );
+};
+
+/** Unit Test for matrix properties.
+ *
+ */
+void GSLMatrixSymmetricTest::PropertiesTest()
+{
+  // is zero
+  m->SetZero();
+  CPPUNIT_ASSERT_EQUAL( true, m->IsNull() );
+  CPPUNIT_ASSERT_EQUAL( false, m->IsPositive() );
+  CPPUNIT_ASSERT_EQUAL( false, m->IsNegative() );
+  CPPUNIT_ASSERT_EQUAL( true, m->IsNonNegative() );
+
+  // is positive
+  m->SetAll(0.5);
+  CPPUNIT_ASSERT_EQUAL( false, m->IsNull() );
+  CPPUNIT_ASSERT_EQUAL( true, m->IsPositive() );
+  CPPUNIT_ASSERT_EQUAL( false, m->IsNegative() );
+  CPPUNIT_ASSERT_EQUAL( true, m->IsNonNegative() );
+
+  // is negative
+  m->SetAll(-0.1);
+  CPPUNIT_ASSERT_EQUAL( false, m->IsNull() );
+  CPPUNIT_ASSERT_EQUAL( false, m->IsPositive() );
+  CPPUNIT_ASSERT_EQUAL( true, m->IsNegative() );
+  CPPUNIT_ASSERT_EQUAL( false, m->IsNonNegative() );
+
+  // is positive definite
+  double array[] = { 1., 0., 0.,
+                     0., 1., 1.,
+                     0., 0., 1. };
+  m->SetFromDoubleArray(array);
+  CPPUNIT_ASSERT_EQUAL( true, m->IsPositiveDefinite() );
+
+  //determinant
+  m->SetIdentity();
+  CPPUNIT_ASSERT_EQUAL( 1., m->Determinant() );
+
+  m->SetZero();
+  CPPUNIT_ASSERT_EQUAL( 0., m->Determinant() );
+
+  m->Set( 0, 0, 1.);
+  m->Set( 1, 1, 1.);
+  m->Set( 2, 1, 1.);
+  CPPUNIT_ASSERT_EQUAL( 0., m->Determinant() );
+  
+  double array2[] = { 2., 0., 1.,
+                     -3., 1., 1.,
+                     1., 5.5, 1. };
+  m->SetFromDoubleArray(array2);
+  CPPUNIT_ASSERT_EQUAL( -26.5, m->Determinant() );
+};
Index: src/unittests/gslmatrixsymmetricunittest.hpp
===================================================================
--- src/unittests/gslmatrixsymmetricunittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/gslmatrixsymmetricunittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+/*
+ * gslmatrixunittest.hpp
+ *
+ *  Created on: Jan 8, 2010
+ *      Author: heber
+ */
+
+#ifndef GSLMATRIXUNITTEST_HPP_
+#define GSLMATRIXUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "gslmatrix.hpp"
+
+/********************************************** Test classes **************************************/
+
+class GSLMatrixSymmetricTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( GSLMatrixSymmetricTest) ;
+    CPPUNIT_TEST (AccessTest );
+    CPPUNIT_TEST (InitializationTest );
+    CPPUNIT_TEST (CopyTest );
+    CPPUNIT_TEST (ExchangeTest );
+    CPPUNIT_TEST (PropertiesTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+    void setUp();
+    void tearDown();
+
+    void AccessTest();
+    void InitializationTest();
+    void CopyTest();
+    void ExchangeTest();
+    void PropertiesTest();
+
+private:
+    GSLMatrix *m;
+};
+
+
+#endif /* GSLMATRIXUNITTEST_HPP_ */
Index: src/unittests/gslmatrixunittest.cpp
===================================================================
--- src/unittests/gslmatrixunittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/gslmatrixunittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,253 @@
+/*
+ * gslmatrixunittest.cpp
+ *
+ *  Created on: Jan 8, 2010
+ *      Author: heber
+ */
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "gslmatrixunittest.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( GSLMatrixTest );
+
+
+void GSLMatrixTest::setUp()
+{
+  m = new GSLMatrix(4,3);
+};
+
+void GSLMatrixTest::tearDown()
+{
+  delete(m);
+};
+
+/** Unit Test for accessing matrix elements.
+ *
+ */
+void GSLMatrixTest::AccessTest()
+{
+  // check whether all elements are initially zero
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( 0., m->Get(i,j) );
+
+  // set
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      m->Set(i,j, i*3+j );
+
+  // and check
+  double *ptr = NULL;
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++) {
+      CPPUNIT_ASSERT_EQUAL( (double)(i*3+j), m->Get(i,j) );
+      ptr = m->Pointer(i,j);
+      CPPUNIT_ASSERT_EQUAL( (double)(i*3+j), *ptr );
+    }
+
+  // assignment
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      m->Set(i,j, i*3+j );
+  GSLMatrix *dest = new GSLMatrix(4,3);
+  *dest = *m;
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( dest->Get(i,j), m->Get(i,j) );
+  delete(dest);
+
+  // out of bounds
+  //CPPUNIT_ASSERT_EQUAL(0., v->Get(5,2) );
+  //CPPUNIT_ASSERT_EQUAL(0., v->Get(2,17) );
+  //CPPUNIT_ASSERT_EQUAL(0., v->Get(1024,140040) );
+  //CPPUNIT_ASSERT_EQUAL(0., v->Get(-1,0) );
+  //CPPUNIT_ASSERT_EQUAL(0., v->Get(0,-1) );
+  //CPPUNIT_ASSERT_EQUAL(0., v->Get(-1,-1) );
+};
+
+/** Unit Test for initializating matrices.
+ *
+ */
+void GSLMatrixTest::InitializationTest()
+{
+  // set zero
+  m->SetZero();
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( 0., m->Get(i,j) );
+
+  // set all
+  m->SetAll(1.5);
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( 1.5, m->Get(i,j) );
+
+  // set basis
+  m->SetIdentity();
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( i == j ? 1. : 0. , m->Get(i,j) );
+
+  // set from array
+  double array[] = { 1., 0., 0.,
+                     0., 1., 0.,
+                     0., 0., 1.,
+                     0., 0., 0. };
+  m->SetFromDoubleArray(array);
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( i == j ? 1. : 0. , m->Get(i,j) );
+
+};
+
+/** Unit Test for copying matrices.
+ *
+ */
+void GSLMatrixTest::CopyTest()
+{
+  // set basis
+  GSLMatrix *dest = NULL;
+  for (int i=0;i<4;i++) {
+    m->SetAll(i);
+    dest = new GSLMatrix(m);
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( m->Get(i,j) , dest->Get(i,j) );
+
+    delete(dest);
+  }
+};
+
+/** Unit Test for exchanging rows and columns.
+ *
+ */
+void GSLMatrixTest::ExchangeTest()
+{
+  // set to 1,1,1,2, ...
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      m->Set(i,j, i+1 );
+
+  // swap such that nothing happens
+  CPPUNIT_ASSERT_EQUAL( true, m->SwapColumns(1,2) );
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( (double)i+1., m->Get(i,j) );
+
+  // swap two rows
+  CPPUNIT_ASSERT_EQUAL( true, m->SwapRows(1,2) );
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      switch (i) {
+        case 0:
+          CPPUNIT_ASSERT_EQUAL( 1., m->Get(i,j) );
+          break;
+        case 1:
+          CPPUNIT_ASSERT_EQUAL( 3., m->Get(i,j) );
+          break;
+        case 2:
+          CPPUNIT_ASSERT_EQUAL( 2., m->Get(i,j) );
+          break;
+        case 3:
+          CPPUNIT_ASSERT_EQUAL( 4., m->Get(i,j) );
+          break;
+        default:
+          CPPUNIT_ASSERT_EQUAL( -1., m->Get(i,j) );
+      }
+  // check that op is reversable
+  CPPUNIT_ASSERT_EQUAL( true, m->SwapRows(1,2) );
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( (double)i+1., m->Get(i,j) );
+
+  // set to 1,2,3,1, ...
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      m->Set(i,j, j+1. );
+
+  // swap such that nothing happens
+  CPPUNIT_ASSERT_EQUAL( true, m->SwapRows(0,2) );
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( (double)j+1., m->Get(i,j) );
+
+  // swap two columns
+  CPPUNIT_ASSERT_EQUAL( true, m->SwapColumns(0,2) );
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      switch (j) {
+        case 0:
+          CPPUNIT_ASSERT_EQUAL( 3., m->Get(i,j) );
+          break;
+        case 1:
+          CPPUNIT_ASSERT_EQUAL( 2., m->Get(i,j) );
+          break;
+        case 2:
+          CPPUNIT_ASSERT_EQUAL( 1., m->Get(i,j) );
+          break;
+        default:
+          CPPUNIT_ASSERT_EQUAL( -1., m->Get(i,j) );
+      }
+  // check that op is reversable
+  CPPUNIT_ASSERT_EQUAL( true, m->SwapColumns(0,2) );
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( (double)j+1., m->Get(i,j) );
+
+
+  // set to 1,2,3,4, ...
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      m->Set(i,j, 3*i+j+1 );
+  // transpose
+  CPPUNIT_ASSERT_EQUAL( true, m->Transpose() );
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( (double)(3*i+j+1), m->Get(j,i) );
+  // second transpose
+  CPPUNIT_ASSERT_EQUAL( true, m->Transpose() );
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( (double)(3*i+j+1), m->Get(i,j) );
+};
+
+/** Unit Test for matrix properties.
+ *
+ */
+void GSLMatrixTest::PropertiesTest()
+{
+  // is zero
+  m->SetZero();
+  CPPUNIT_ASSERT_EQUAL( true, m->IsNull() );
+  CPPUNIT_ASSERT_EQUAL( false, m->IsPositive() );
+  CPPUNIT_ASSERT_EQUAL( false, m->IsNegative() );
+  CPPUNIT_ASSERT_EQUAL( true, m->IsNonNegative() );
+
+  // is positive
+  m->SetAll(0.5);
+  CPPUNIT_ASSERT_EQUAL( false, m->IsNull() );
+  CPPUNIT_ASSERT_EQUAL( true, m->IsPositive() );
+  CPPUNIT_ASSERT_EQUAL( false, m->IsNegative() );
+  CPPUNIT_ASSERT_EQUAL( true, m->IsNonNegative() );
+
+  // is negative
+  m->SetAll(-0.1);
+  CPPUNIT_ASSERT_EQUAL( false, m->IsNull() );
+  CPPUNIT_ASSERT_EQUAL( false, m->IsPositive() );
+  CPPUNIT_ASSERT_EQUAL( true, m->IsNegative() );
+  CPPUNIT_ASSERT_EQUAL( false, m->IsNonNegative() );
+
+  // is positive definite
+  CPPUNIT_ASSERT_EQUAL( false, m->IsPositiveDefinite() );
+};
Index: src/unittests/gslmatrixunittest.hpp
===================================================================
--- src/unittests/gslmatrixunittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/gslmatrixunittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+/*
+ * gslmatrixunittest.hpp
+ *
+ *  Created on: Jan 8, 2010
+ *      Author: heber
+ */
+
+#ifndef GSLMATRIXUNITTEST_HPP_
+#define GSLMATRIXUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "gslmatrix.hpp"
+
+/********************************************** Test classes **************************************/
+
+class GSLMatrixTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( GSLMatrixTest) ;
+    CPPUNIT_TEST (AccessTest );
+    CPPUNIT_TEST (InitializationTest );
+    CPPUNIT_TEST (CopyTest );
+    CPPUNIT_TEST (ExchangeTest );
+    CPPUNIT_TEST (PropertiesTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+    void setUp();
+    void tearDown();
+
+    void AccessTest();
+    void InitializationTest();
+    void CopyTest();
+    void ExchangeTest();
+    void PropertiesTest();
+
+private:
+    GSLMatrix *m;
+};
+
+
+#endif /* GSLMATRIXUNITTEST_HPP_ */
Index: src/unittests/gslvectorunittest.cpp
===================================================================
--- src/unittests/gslvectorunittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/gslvectorunittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,164 @@
+/*
+ * gslvectorunittest.cpp
+ *
+ *  Created on: Jan 8, 2010
+ *      Author: heber
+ */
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "gslvectorunittest.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( GSLVectorTest );
+
+
+void GSLVectorTest::setUp()
+{
+  v = new GSLVector(3);
+};
+
+void GSLVectorTest::tearDown()
+{
+  delete(v);
+};
+
+/** Unit test for accessing elements in the vector.
+ *
+ */
+void GSLVectorTest::AccessTest()
+{
+  // set
+  for (int i=0;i<3;i++)
+    v->Set(i,i);
+
+  // and check
+  double *ptr = NULL;
+  for (int i=0;i<3;i++) {
+    CPPUNIT_ASSERT_EQUAL( (double)i, v->Get(i) );
+    ptr = v->Pointer(i);
+    CPPUNIT_ASSERT_EQUAL( (double)i, *ptr );
+  }
+
+  // out of bounds
+  //CPPUNIT_ASSERT_EQUAL(0., v->Get(3) );
+  //CPPUNIT_ASSERT_EQUAL(0., v->Get(-1) );
+};
+
+
+/** Unit test for initializing the vector.
+ *
+ */
+void GSLVectorTest::InitializaionTest()
+{
+  // set zero
+  v->SetZero();
+  for (int i=0;i<3;i++)
+    CPPUNIT_ASSERT_EQUAL( 0., v->Get(i) );
+
+  // set basis
+  for (int i=0;i<3;i++) {
+    v->SetBasis(i);
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( i == j ? 1. : 0. , v->Get(j) );
+  }
+
+  // set all
+  v->SetAll(1.5);
+  for (int i=0;i<3;i++)
+    CPPUNIT_ASSERT_EQUAL( 1.5, v->Get(i) );
+};
+
+/** Unit test for copying vectors.
+ *
+ */
+void GSLVectorTest::CopyTest()
+{
+  // set basis
+  GSLVector *dest = NULL;
+  for (int i=0;i<3;i++) {
+    v->SetBasis(i);
+    dest = new GSLVector(v);
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( v->Get(j) , dest->Get(j) );
+
+    delete(dest);
+  }
+};
+
+/** Unit test for exchanging elements of a vector.
+ *
+ */
+void GSLVectorTest::ExchangeTest()
+{
+  // set basis
+  for (int i=0;i<3;i++) {
+    v->SetBasis(i);
+    v->SwapElements((i)%3,(i+1)%3);
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( (i+1)%3 == j ? 1. : 0. , v->Get(j) );
+  }
+
+  // set to 1,2,3 and reverse
+  for (int i=0;i<3;i++)
+    v->Set(i,i+1);
+  v->Reverse();
+  for (int j=0;j<3;j++)
+    CPPUNIT_ASSERT_EQUAL( (double)(3-j), v->Get(j) );
+};
+
+/** UnitTest for operators.
+ */
+void GSLVectorTest::OperatorIsTest()
+{
+  GSLVector zero(3);
+  GSLVector unit(3);
+  zero.SetZero();
+  unit.SetZero();
+  unit.Set(1,1.);
+  // summation and scaling
+  CPPUNIT_ASSERT_EQUAL( true, unit.IsOne() );
+  CPPUNIT_ASSERT_EQUAL( false, zero.IsOne() );
+  CPPUNIT_ASSERT_EQUAL( false, unit.IsZero() );
+  CPPUNIT_ASSERT_EQUAL( true, zero.IsZero() );
+};
+
+/** UnitTest for operators.
+ */
+void GSLVectorTest::OperatorAlgebraTest()
+{
+  GSLVector zero(3);
+  GSLVector unit(3);
+  zero.SetZero();
+  unit.SetZero();
+  unit.Set(1,1.);
+  // summation and scaling
+  CPPUNIT_ASSERT_EQUAL( true, (zero+unit).IsOne() );
+  CPPUNIT_ASSERT_EQUAL( true, (zero+unit).IsOne() );
+  CPPUNIT_ASSERT_EQUAL( true, (zero-unit).IsOne() );
+  CPPUNIT_ASSERT_EQUAL( false, (zero-unit).IsZero() );
+  CPPUNIT_ASSERT_EQUAL( true, (zero+zero).IsZero() );
+  CPPUNIT_ASSERT_EQUAL( false, (unit*0.98).IsOne() );
+  CPPUNIT_ASSERT_EQUAL( false, (0.98*unit).IsOne() );
+  CPPUNIT_ASSERT_EQUAL( true, (unit*1.).IsOne() );
+  CPPUNIT_ASSERT_EQUAL( true, (1.*unit).IsOne() );
+
+  CPPUNIT_ASSERT_EQUAL( unit, (zero+unit) );
+  CPPUNIT_ASSERT_EQUAL( zero, (zero+zero) );
+  CPPUNIT_ASSERT_EQUAL( unit, (unit+zero) );
+
+  unit += zero;
+  CPPUNIT_ASSERT_EQUAL( true, unit.IsOne() );
+  unit *= 1.;
+  CPPUNIT_ASSERT_EQUAL( true, unit.IsOne() );
+};
Index: src/unittests/gslvectorunittest.hpp
===================================================================
--- src/unittests/gslvectorunittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/gslvectorunittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,45 @@
+/*
+ * gslvectorunittest.hpp
+ *
+ *  Created on: Jan 8, 2010
+ *      Author: heber
+ */
+
+#ifndef GSLVECTORUNITTEST_HPP_
+#define GSLVECTORUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "gslvector.hpp"
+
+/********************************************** Test classes **************************************/
+
+class GSLVectorTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( GSLVectorTest) ;
+    CPPUNIT_TEST (AccessTest );
+    CPPUNIT_TEST (InitializaionTest );
+    CPPUNIT_TEST (CopyTest );
+    CPPUNIT_TEST (ExchangeTest );
+    CPPUNIT_TEST (OperatorAlgebraTest );
+    CPPUNIT_TEST (OperatorIsTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+    void setUp();
+    void tearDown();
+
+    void AccessTest();
+    void InitializaionTest();
+    void CopyTest();
+    void ExchangeTest();
+    void OperatorIsTest();
+    void OperatorAlgebraTest();
+
+private:
+
+    GSLVector *v;
+};
+
+
+#endif /* GSLVECTORUNITTEST_HPP_ */
Index: src/unittests/infounittest.cpp
===================================================================
--- src/unittests/infounittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/infounittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,50 @@
+/*
+ * InfoUnitTest.cpp
+ *
+ *  Created on: Nov 25, 2009
+ *      Author: heber
+ */
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <iostream>
+#include <stdio.h>
+
+#include "info.hpp"
+#include "infounittest.hpp"
+#include "log.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( InfoTest );
+
+
+void InfoTest::setUp()
+{
+};
+
+
+void InfoTest::tearDown()
+{
+  logger::purgeInstance();
+};
+
+/** UnitTest for FunctionTest().
+ */
+void InfoTest::FunctionTest()
+{
+  const char *msg = __func__;
+  class Info test(msg);
+
+  CPPUNIT_ASSERT_EQUAL( msg , test.FunctionName );
+  CPPUNIT_ASSERT_EQUAL( 1, test.verbosity );
+};
Index: src/unittests/infounittest.hpp
===================================================================
--- src/unittests/infounittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/infounittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,32 @@
+/*
+ * InfoUnitTest.hpp
+ *
+ *  Created on: Nov 25, 2009
+ *      Author: heber
+ */
+
+#ifndef INFOUNITTEST_HPP_
+#define INFOUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class info;
+
+/********************************************** Test classes **************************************/
+
+class InfoTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( InfoTest) ;
+    CPPUNIT_TEST ( FunctionTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+      void FunctionTest();
+
+private:
+
+};
+
+#endif /* INFOUNITTEST_HPP_ */
Index: src/unittests/linearsystemofequationsunittest.cpp
===================================================================
--- src/unittests/linearsystemofequationsunittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/linearsystemofequationsunittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,108 @@
+/*
+ * linearsystemofequationsunittest.cpp
+ *
+ *  Created on: Jan 8, 2010
+ *      Author: heber
+ */
+
+using namespace std;
+
+#include <iomanip>
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "linearsystemofequationsunittest.hpp"
+#include "vector.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( LinearSystemOfEquationsTest );
+
+
+void LinearSystemOfEquationsTest::setUp()
+{
+  s = new LinearSystemOfEquations(4,4);
+};
+
+void LinearSystemOfEquationsTest::tearDown()
+{
+  delete(s);
+};
+
+/** Unit test for initialization.
+ *
+ */
+void LinearSystemOfEquationsTest::InitializationTest()
+{
+  // Setting A
+  double array[] = { 1., 0., 0., 0.,
+                     0., 2., 0., 0.,
+                     0., 0., 3., 0.,
+                     0., 0., 0., 4. };
+  s->SetA(array);
+
+  // Setting b
+};
+
+/** Unit test for symmetry property.
+ *
+ */
+void LinearSystemOfEquationsTest::SymmetricTest()
+{
+  CPPUNIT_ASSERT_EQUAL( true, s->SetSymmetric(true) );
+  //LinearSystemOfEquations *t = new LinearSystemOfEquations(4,3);
+  //CPPUNIT_ASSERT_EQUAL( true, t->SetSymmetric(true) );
+  //delete(t);
+};
+
+/** Unit test for simple Solve.
+ *
+ */
+void LinearSystemOfEquationsTest::SolveSimpleTest()
+{
+  // set up A and b
+  double m_array[] = { 1., 0., 0., 0.,
+                       0., 2., 0., 0.,
+                       0., 0., 3., 0.,
+                       0., 0., 0., 4. };
+  double v_array[] = { 1., 2., 3., 4. };
+  s->SetA(m_array);
+  s->Setb(v_array);
+
+  // solve
+  double *array = new double[4];
+  s->GetSolutionAsArray(array);
+  for (int i=0;i<4;i++)
+    CPPUNIT_ASSERT_EQUAL( 1., array[i]);
+  delete[](array);
+};
+
+/** Unit test for advanced Solve.
+ *
+ */
+void LinearSystemOfEquationsTest::SolveAdvancedTest()
+{
+  // set up A and b
+  double m_array[] = { 0.18, 0.60, 0.57, 0.96,
+                       0.41, 0.24, 0.99, 0.58,
+                       0.14, 0.30, 0.97, 0.66,
+                       0.51, 0.13, 0.19, 0.85 };
+  double v_array[] = { 1.0, 2.0, 3.0, 4.0 };
+  double x_array[] = { -4.05205022957398, -12.60561139590692, 1.660911626708844, 8.693766928795233 };
+  s->SetA(m_array);
+  s->Setb(v_array);
+
+  // solve
+  double *array = new double[4];
+  s->GetSolutionAsArray(array);
+  for (int i=0;i<4;i++) {
+    CPPUNIT_ASSERT( fabs(x_array[i] - array[i]) < MYEPSILON );
+  }
+  delete[](array);
+};
Index: src/unittests/linearsystemofequationsunittest.hpp
===================================================================
--- src/unittests/linearsystemofequationsunittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/linearsystemofequationsunittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,40 @@
+/*
+ * linearsystemofequationsunittest.hpp
+ *
+ *  Created on: Jan 8, 2010
+ *      Author: heber
+ */
+
+#ifndef LINEARSYSTEMOFEQUATIONSUNITTEST_HPP_
+#define LINEARSYSTEMOFEQUATIONSUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "linearsystemofequations.hpp"
+
+/********************************************** Test classes **************************************/
+
+class LinearSystemOfEquationsTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( LinearSystemOfEquationsTest) ;
+    CPPUNIT_TEST ( InitializationTest );
+    CPPUNIT_TEST ( SymmetricTest );
+    CPPUNIT_TEST ( SolveSimpleTest );
+    CPPUNIT_TEST ( SolveAdvancedTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+    void setUp();
+    void tearDown();
+
+    void InitializationTest();
+    void SymmetricTest();
+    void SolveSimpleTest();
+    void SolveAdvancedTest();
+
+private:
+    LinearSystemOfEquations *s;
+};
+
+
+#endif /* LINEARSYSTEMOFEQUATIONSUNITTEST_HPP_ */
Index: src/unittests/listofbondsunittest.cpp
===================================================================
--- src/unittests/listofbondsunittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/listofbondsunittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,280 @@
+/*
+ * listofbondsunittest.cpp
+ *
+ *  Created on: 18 Oct 2009
+ *      Author: user
+ */
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <cstring>
+
+#include "listofbondsunittest.hpp"
+
+#include "World.hpp"
+#include "atom.hpp"
+#include "bond.hpp"
+#include "element.hpp"
+#include "molecule.hpp"
+#include "periodentafel.hpp"
+#include "World.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( ListOfBondsTest );
+
+
+void ListOfBondsTest::setUp()
+{
+  atom *Walker = NULL;
+
+  // construct element
+  hydrogen = World::getInstance().getPeriode()->FindElement(1);
+  CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen");
+
+  // construct molecule (tetraeder of hydrogens)
+  TestMolecule = World::getInstance().createMolecule();
+  CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule");
+  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. );
+  TestMolecule->AddAtom(Walker);
+
+  // check that TestMolecule was correctly constructed
+  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 );
+};
+
+
+void ListOfBondsTest::tearDown()
+{
+  // remove
+  World::getInstance().destroyMolecule(TestMolecule);
+  // note that all the atoms, molecules, the tafel and the elements
+  // are all cleaned when the world is destroyed
+  World::purgeInstance();
+  logger::purgeInstance();
+};
+
+/** Tests whether setup worked correctly.
+ *
+ */
+void ListOfBondsTest::SetupTest()
+{
+  CPPUNIT_ASSERT_EQUAL( false, TestMolecule->empty() );
+  CPPUNIT_ASSERT_EQUAL( (size_t)4, TestMolecule->size() );
+};
+
+/** Unit Test of molecule::AddBond()
+ *
+ */
+void ListOfBondsTest::AddingBondTest()
+{
+  bond *Binder = NULL;
+  molecule::iterator iter = TestMolecule->begin();
+  atom *atom1 = *iter;
+  iter++;
+  atom *atom2 = *iter;
+  CPPUNIT_ASSERT( atom1 != NULL );
+  CPPUNIT_ASSERT( atom2 != NULL );
+
+  // add bond
+  Binder = TestMolecule->AddBond(atom1, atom2, 1);
+  CPPUNIT_ASSERT( Binder != NULL );
+  CPPUNIT_ASSERT_EQUAL ( true, TestMolecule->hasBondStructure() );
+
+  // check that bond contains the two atoms
+  CPPUNIT_ASSERT_EQUAL( true, Binder->Contains(atom1) );
+  CPPUNIT_ASSERT_EQUAL( true, Binder->Contains(atom2) );
+
+  // check that bond is present in both atoms
+  bond *TestBond1 = *(atom1->ListOfBonds.begin());
+  CPPUNIT_ASSERT_EQUAL( TestBond1, Binder );
+  bond *TestBond2 = *(atom2->ListOfBonds.begin());
+  CPPUNIT_ASSERT_EQUAL( TestBond2, Binder );
+};
+
+/** Unit Test of molecule::RemoveBond()
+ *
+ */
+void ListOfBondsTest::RemovingBondTest()
+{
+  bond *Binder = NULL;
+  molecule::iterator iter = TestMolecule->begin();
+  atom *atom1 = *iter;
+  iter++;
+  atom *atom2 = *iter;
+  CPPUNIT_ASSERT( atom1 != NULL );
+  CPPUNIT_ASSERT( atom2 != NULL );
+
+  // add bond
+  Binder = TestMolecule->AddBond(atom1, atom2, 1);
+  CPPUNIT_ASSERT( Binder != NULL );
+
+  // remove bond
+  TestMolecule->RemoveBond(Binder);
+
+  // check if removed from atoms
+  CPPUNIT_ASSERT_EQUAL( (size_t) 0, atom1->ListOfBonds.size() );
+  CPPUNIT_ASSERT_EQUAL( (size_t) 0, atom2->ListOfBonds.size() );
+
+  // check if removed from molecule
+  CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() );
+};
+
+/** Unit Test of molecule::RemoveBonds()
+ *
+ */
+void ListOfBondsTest::RemovingBondsTest()
+{
+  bond *Binder = NULL;
+  molecule::iterator iter = TestMolecule->begin();
+  atom *atom1 = *iter;
+  iter++;
+  atom *atom2 = *iter;
+  iter++;
+  atom *atom3 = *iter;
+  CPPUNIT_ASSERT( atom1 != NULL );
+  CPPUNIT_ASSERT( atom2 != NULL );
+  CPPUNIT_ASSERT( atom3 != NULL );
+
+  // add bond
+  Binder = TestMolecule->AddBond(atom1, atom2, 1);
+  CPPUNIT_ASSERT( Binder != NULL );
+  Binder = TestMolecule->AddBond(atom1, atom3, 1);
+  CPPUNIT_ASSERT( Binder != NULL );
+  Binder = TestMolecule->AddBond(atom2, atom3, 1);
+  CPPUNIT_ASSERT( Binder != NULL );
+
+  // check that all are present
+  CPPUNIT_ASSERT_EQUAL( (size_t) 2, atom1->ListOfBonds.size() );
+  CPPUNIT_ASSERT_EQUAL( (size_t) 2, atom2->ListOfBonds.size() );
+  CPPUNIT_ASSERT_EQUAL( (size_t) 2, atom3->ListOfBonds.size() );
+
+  // remove bond
+  TestMolecule->RemoveBonds(atom1);
+
+  // check if removed from atoms
+  CPPUNIT_ASSERT_EQUAL( (size_t) 0, atom1->ListOfBonds.size() );
+  CPPUNIT_ASSERT_EQUAL( (size_t) 1, atom2->ListOfBonds.size() );
+  CPPUNIT_ASSERT_EQUAL( (size_t) 1, atom3->ListOfBonds.size() );
+
+  // check if removed from molecule
+  CPPUNIT_ASSERT_EQUAL( true, TestMolecule->hasBondStructure() );
+  CPPUNIT_ASSERT_EQUAL( (unsigned int)1, TestMolecule->CountBonds() );
+};
+
+/** Unit Test of delete(bond *)
+ *
+ */
+void ListOfBondsTest::DeleteBondTest()
+{
+  bond *Binder = NULL;
+  molecule::iterator iter = TestMolecule->begin();
+  atom *atom1 = *iter;
+  iter++;
+  atom *atom2 = *iter;
+  CPPUNIT_ASSERT( atom1 != NULL );
+  CPPUNIT_ASSERT( atom2 != NULL );
+
+  // add bond
+  Binder = TestMolecule->AddBond(atom1, atom2, 1);
+  CPPUNIT_ASSERT( Binder != NULL );
+
+  // remove bond
+  delete(Binder);
+
+  // check if removed from atoms
+  CPPUNIT_ASSERT_EQUAL( (size_t) 0, atom1->ListOfBonds.size() );
+  CPPUNIT_ASSERT_EQUAL( (size_t) 0, atom2->ListOfBonds.size() );
+
+  // check if removed from molecule
+  CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() );
+};
+
+/** Unit Test of molecule::RemoveAtom()
+ *
+ */
+void ListOfBondsTest::RemoveAtomTest()
+{
+  bond *Binder = NULL;
+  molecule::iterator iter = TestMolecule->begin();
+  atom *atom1 = *iter;
+  iter++;
+  atom *atom2 = *iter;
+  CPPUNIT_ASSERT( atom1 != NULL );
+  CPPUNIT_ASSERT( atom2 != NULL );
+
+  // add bond
+  Binder = TestMolecule->AddBond(atom1, atom2, 1);
+  CPPUNIT_ASSERT( Binder != NULL );
+
+  // remove atom2
+  TestMolecule->RemoveAtom(atom2);
+
+  // check bond if removed from other atom
+  CPPUNIT_ASSERT_EQUAL( (size_t) 0, atom1->ListOfBonds.size() );
+
+  // check if removed from molecule
+  CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() );
+};
+
+/** Unit Test of delete(atom *)
+ *
+ */
+void ListOfBondsTest::DeleteAtomTest()
+{
+  atom *atom1 = NULL;
+  atom *atom2 = NULL;
+  bond *Binder = NULL;
+  {
+    molecule::iterator iter = TestMolecule->begin();
+    atom1 = *iter;
+    iter++;
+    atom2 = *iter;
+  }
+  CPPUNIT_ASSERT( atom1 != NULL );
+  CPPUNIT_ASSERT( atom2 != NULL );
+
+  // add bond
+  Binder = TestMolecule->AddBond(atom1, atom2, 1);
+  CPPUNIT_ASSERT( Binder != NULL );
+
+  CPPUNIT_ASSERT_EQUAL( (size_t) 1, atom1->ListOfBonds.size() );
+  CPPUNIT_ASSERT_EQUAL( (size_t) 1, atom2->ListOfBonds.size() );
+
+  CPPUNIT_ASSERT_EQUAL( true, TestMolecule->hasBondStructure() );
+
+  // remove atom2
+  World::getInstance().destroyAtom(atom2);
+
+  // check bond if removed from other atom
+  CPPUNIT_ASSERT_EQUAL( (size_t) 0, atom1->ListOfBonds.size() );
+
+  // check if removed from molecule
+  CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() );
+};
Index: src/unittests/listofbondsunittest.hpp
===================================================================
--- src/unittests/listofbondsunittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/listofbondsunittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,49 @@
+/*
+ * listofbondsunittest.hpp
+ *
+ *  Created on: 18 Oct 2009
+ *      Author: user
+ */
+
+#ifndef LISTOFBONDSUNITTEST_HPP_
+#define LISTOFBONDSUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class element;
+class molecule;
+class periodentafel;
+
+/********************************************** Test classes **************************************/
+
+class ListOfBondsTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( ListOfBondsTest) ;
+    CPPUNIT_TEST ( SetupTest );
+    CPPUNIT_TEST ( AddingBondTest );
+    CPPUNIT_TEST ( RemovingBondTest );
+    CPPUNIT_TEST ( RemovingBondsTest );
+    CPPUNIT_TEST ( RemoveAtomTest );
+    CPPUNIT_TEST ( DeleteBondTest );
+    CPPUNIT_TEST ( DeleteAtomTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+      void SetupTest();
+      void AddingBondTest();
+      void RemovingBondTest();
+      void RemovingBondsTest();
+      void RemoveAtomTest();
+      void DeleteBondTest();
+      void DeleteAtomTest();
+
+private:
+
+      molecule *TestMolecule;
+      const element *hydrogen;
+};
+
+
+#endif /* LISTOFBONDSUNITTEST_HPP_ */
Index: src/unittests/logunittest.cpp
===================================================================
--- src/unittests/logunittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/logunittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,55 @@
+/*
+ * logunittest.cpp
+ */
+
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "logunittest.hpp"
+#include "log.hpp"
+#include "defs.hpp"
+#include "verbose.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( LogTest );
+
+
+void LogTest::setUp()
+{
+};
+
+void LogTest::tearDown()
+{
+  logger::purgeInstance();
+  errorLogger::purgeInstance();
+};
+
+/**
+ * UnitTest for log()
+ */
+void LogTest::logTest()
+{
+  logger::getInstance().setVerbosity(2);
+  DoLog(0) && (Log() << Verbose(0) << "Verbosity level is set to 2." << endl);
+  DoLog(0) && (Log() << Verbose(0) << "Test level 0" << endl);
+  DoLog(1) && (Log() << Verbose(1) << "Test level 1" << endl);
+  DoLog(2) && (Log() << Verbose(2) << "Test level 2" << endl);
+  DoLog(3) && (Log() << Verbose(3) << "Test level 3" << endl);
+  DoLog(4) && (Log() << Verbose(4) << "Test level 4" << endl);
+
+  DoLog(0) && (Log() << Verbose(0) << "Output a log message." << endl);
+  DoeLog(0) && (eLog()<< Verbose(0) << "Output an error message." << endl);
+  setVerbosity(3);
+  DoLog(4) && (Log() << Verbose(4) << "This should not be printed." << endl);
+  DoeLog(4) && (eLog()<< Verbose(4) << "This should not be printed." << endl);
+};
Index: src/unittests/logunittest.hpp
===================================================================
--- src/unittests/logunittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/logunittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,26 @@
+/*
+ * logunittest.hpp
+ */
+
+#ifndef LOGTEST_HPP_
+#define LOGTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+
+/********************************************** Test classes **************************************/
+
+class LogTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( LogTest) ;
+    CPPUNIT_TEST ( logTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+    void setUp();
+    void tearDown();
+
+    void logTest();
+};
+
+#endif /* LOGTEST_HPP_ */
Index: src/unittests/manipulateAtomsTest.cpp
===================================================================
--- src/unittests/manipulateAtomsTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/manipulateAtomsTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,133 @@
+/*
+ * manipulateAtomsTest.cpp
+ *
+ *  Created on: Feb 18, 2010
+ *      Author: crueger
+ */
+
+#include "manipulateAtomsTest.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include <iostream>
+#include <boost/bind.hpp>
+
+#include "Descriptors/AtomDescriptor.hpp"
+#include "Descriptors/AtomIdDescriptor.hpp"
+#include "Actions/ManipulateAtomsProcess.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Actions/ActionHistory.hpp"
+
+#include "World.hpp"
+#include "atom.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( manipulateAtomsTest );
+
+// some stubs
+class AtomStub : public atom {
+public:
+  AtomStub(int _id) :
+  atom(),
+  manipulated(false),
+  id(_id)
+  {}
+
+  virtual atomId_t getId(){
+    return id;
+  }
+
+  virtual void doSomething(){
+    manipulated = true;
+  }
+
+  bool manipulated;
+private:
+  atomId_t id;
+};
+
+class countObserver : public Observer{
+public:
+  countObserver() :
+    Observer("countObserver"),
+    count(0)
+    {}
+  virtual ~countObserver(){}
+
+  void update(Observable *){
+    count++;
+  }
+
+  void subjectKilled(Observable *)
+  {}
+
+  int count;
+};
+
+// set up and tear down
+void manipulateAtomsTest::setUp(){
+  ActionHistory::init();
+  World::getInstance();
+  for(int i=0;i<ATOM_COUNT;++i){
+    atoms[i]= new AtomStub(i);
+    World::getInstance().registerAtom(atoms[i]);
+  }
+}
+void manipulateAtomsTest::tearDown(){
+  World::purgeInstance();
+  ActionRegistry::purgeInstance();
+  ActionHistory::purgeInstance();
+}
+
+static void operation(atom* _atom){
+  AtomStub *atom = dynamic_cast<AtomStub*>(_atom);
+  CPPUNIT_ASSERT(atom);
+  atom->doSomething();
+}
+
+
+void manipulateAtomsTest::testManipulateSimple(){
+  ManipulateAtomsProcess *proc = World::getInstance().manipulateAtoms(boost::bind(operation,_1),"FOO",AllAtoms());
+  proc->call();
+  std::vector<atom*> allAtoms = World::getInstance().getAllAtoms(AllAtoms());
+  std::vector<atom*>::iterator iter;
+  for(iter=allAtoms.begin();iter!=allAtoms.end();++iter){
+    AtomStub *atom;
+    atom = dynamic_cast<AtomStub*>(*iter);
+    CPPUNIT_ASSERT(atom);
+    CPPUNIT_ASSERT(atom->manipulated);
+  }
+}
+
+void manipulateAtomsTest::testManipulateExcluded(){
+
+  ManipulateAtomsProcess *proc = World::getInstance().manipulateAtoms(boost::bind(operation,_1),"FOO",AllAtoms() && !AtomById(ATOM_COUNT/2));
+  proc->call();
+  std::vector<atom*> allAtoms = World::getInstance().getAllAtoms(AllAtoms());
+  std::vector<atom*>::iterator iter;
+  for(iter=allAtoms.begin();iter!=allAtoms.end();++iter){
+    AtomStub *atom;
+    atom = dynamic_cast<AtomStub*>(*iter);
+    CPPUNIT_ASSERT(atom);
+    if(atom->getId()!=(int)ATOM_COUNT/2)
+      CPPUNIT_ASSERT(atom->manipulated);
+    else
+      CPPUNIT_ASSERT(!atom->manipulated);
+  }
+}
+
+void manipulateAtomsTest::testObserver(){
+  countObserver *obs = new countObserver();
+  World::getInstance().signOn(obs);
+  ManipulateAtomsProcess *proc = World::getInstance().manipulateAtoms(boost::bind(operation,_1),"FOO",AllAtoms());
+  proc->call();
+
+  CPPUNIT_ASSERT_EQUAL(1,obs->count);
+  World::getInstance().signOff(obs);
+  delete obs;
+}
Index: src/unittests/manipulateAtomsTest.hpp
===================================================================
--- src/unittests/manipulateAtomsTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/manipulateAtomsTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,37 @@
+/*
+ * manipulateAtomsTest.hpp
+ *
+ *  Created on: Feb 18, 2010
+ *      Author: crueger
+ */
+
+#ifndef MANIPULATEATOMSTEST_HPP_
+#define MANIPULATEATOMSTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#define ATOM_COUNT (10)
+
+class atom;
+
+class manipulateAtomsTest : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( manipulateAtomsTest );
+  CPPUNIT_TEST ( testManipulateSimple );
+  CPPUNIT_TEST ( testManipulateExcluded );
+  CPPUNIT_TEST ( testObserver );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void testManipulateSimple();
+  void testManipulateExcluded();
+  void testObserver();
+
+private:
+  atom *atoms [ATOM_COUNT];
+};
+
+#endif /* MANIPULATEATOMSTEST_HPP_ */
Index: src/unittests/memoryallocatorunittest.cpp
===================================================================
--- src/unittests/memoryallocatorunittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/memoryallocatorunittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,110 @@
+/*
+ * memoryallocatorunittest.cpp
+ */
+
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "memoryallocator.hpp"
+#include "memoryallocatorunittest.hpp"
+#include "memoryusageobserver.hpp"
+#include "helpers.hpp"
+#include "log.hpp"
+#include "defs.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( MemoryAllocatorTest );
+
+
+void MemoryAllocatorTest::setUp()
+{
+};
+
+
+void MemoryAllocatorTest::tearDown()
+{
+  MemoryUsageObserver::getInstance()->purgeInstance();
+  logger::purgeInstance();
+};
+
+/**
+ * UnitTest for Malloc()
+ */
+void MemoryAllocatorTest::MallocTest()
+{
+  int* buffer1 = NULL;
+  buffer1 = Malloc<int>(1, "");
+  Free(&buffer1);
+
+  long* buffer2 = NULL;
+  buffer2 = Malloc<long>(1, "");
+  Free(&buffer2);
+
+  char* buffer3 = NULL;
+  buffer3 = Malloc<char>(4, "");
+  DoLog(0) && (Log() << Verbose(0) << buffer3 << endl);
+  Free(&buffer3);
+
+  char** buffer4 = NULL;
+  buffer4 = Malloc<char*>(10, "");
+  for (int i=0;i<10;i++)
+    buffer4[i] = NULL;
+  Free(&buffer4);
+};
+
+/**
+ * UnitTest for Calloc()
+ */
+void MemoryAllocatorTest::CallocTest()
+{
+  int* buffer1 = NULL;
+  buffer1 = Calloc<int>(10, "");
+  Free(&buffer1);
+
+  long* buffer2 = NULL;
+  buffer2 = Calloc<long>(10, "");
+  Free(&buffer2);
+
+  char** buffer3 = NULL;
+  buffer3 = Calloc<char *>(10, "");
+  for (int i=0;i<10;i++)
+    buffer3[i] = NULL;
+  Free(&buffer3);
+};
+
+/**
+ * UnitTest for ReAlloc()
+ */
+void MemoryAllocatorTest::ReAllocTest()
+{
+  int* buffer1 = NULL;
+  buffer1 = Malloc<int>(1, "");
+  buffer1 = ReAlloc<int>(buffer1, 2, "");
+  Free(&buffer1);
+
+  int* buffer2 = NULL;
+  buffer2 = ReAlloc<int>(buffer2, 2, "");
+  Free(&buffer2);
+};
+
+/**
+ * UnitTest for Free()
+ */
+void MemoryAllocatorTest::FreeTest()
+{
+  char** buffer1 = NULL;
+  Free(buffer1);
+
+  int** buffer2 = NULL;
+  Free(buffer2);
+};
Index: src/unittests/memoryallocatorunittest.hpp
===================================================================
--- src/unittests/memoryallocatorunittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/memoryallocatorunittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,32 @@
+/*
+ * memoryallocatorunittest.hpp
+ */
+
+#ifndef MEMORYALLOCATORTEST_HPP_
+#define MEMORYALLOCATORTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+
+/********************************************** Test classes **************************************/
+
+class MemoryAllocatorTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( MemoryAllocatorTest) ;
+    CPPUNIT_TEST ( MallocTest );
+    CPPUNIT_TEST ( CallocTest );
+    CPPUNIT_TEST ( ReAllocTest );
+    CPPUNIT_TEST ( FreeTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+    void setUp();
+    void tearDown();
+
+    void MallocTest();
+    void CallocTest();
+    void ReAllocTest();
+    void FreeTest();
+};
+
+#endif /* MEMORYALLOCATORTEST_HPP_ */
Index: src/unittests/memoryusageobserverunittest.cpp
===================================================================
--- src/unittests/memoryusageobserverunittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/memoryusageobserverunittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,151 @@
+/*
+ * memoryusageobserverunittest.cpp
+ */
+
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "memoryallocator.hpp"
+#include "memoryusageobserver.hpp"
+#include "memoryusageobserverunittest.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( MemoryUsageObserverTest );
+
+
+void MemoryUsageObserverTest::setUp()
+{
+};
+
+
+void MemoryUsageObserverTest::tearDown()
+{
+  MemoryUsageObserver::purgeInstance();
+  logger::purgeInstance();
+  errorLogger::purgeInstance();
+};
+
+/**
+ * UnitTest for getInstance()
+ */
+void MemoryUsageObserverTest::getInstanceReturnsMemoryUsageObserverTest()
+{
+  CPPUNIT_ASSERT_EQUAL(true, MemoryUsageObserver::getInstance() != NULL);
+};
+
+/**
+ * UnitTest for getInstance()
+ */
+void MemoryUsageObserverTest::getInstanceTwiceReturnsSameInstanceTest()
+{
+  int* i = Malloc<int>(1, "MemoryUsageObserverTest::getInstanceTwiceReturnsSameInstanceTest - i");
+  MemoryUsageObserver::getInstance()->addMemory(i, sizeof(int));
+  CPPUNIT_ASSERT_EQUAL(sizeof(int), MemoryUsageObserver::getInstance()->getUsedMemorySize());
+  CPPUNIT_ASSERT_EQUAL(sizeof(int), MemoryUsageObserver::getInstance()->getUsedMemorySize());
+};
+
+/**
+ * UnitTest for getInstance()
+ */
+void MemoryUsageObserverTest::getInstanceAfterPurgeInstanceReturnsNewInstanceTest()
+{
+  int* i = Malloc<int>(1, "MemoryUsageObserverTest::getInstanceAfterPurgeInstanceReturnsNewInstanceTest - i");
+  MemoryUsageObserver::getInstance()->addMemory(i, sizeof(int));
+  CPPUNIT_ASSERT_EQUAL(sizeof(int), MemoryUsageObserver::getInstance()->getUsedMemorySize());
+  MemoryUsageObserver::purgeInstance();
+  CPPUNIT_ASSERT_EQUAL((size_t) 0, MemoryUsageObserver::getInstance()->getUsedMemorySize());
+};
+
+/**
+ * UnitTest for addMemory() and removeMemory()
+ */
+void MemoryUsageObserverTest::addAndRemoveMemoryTest()
+{
+  int* i = Malloc<int>(1, "MemoryUsageObserverTest::addAndRemoveMemoryTest - i");
+  MemoryUsageObserver::getInstance()->addMemory(i, sizeof(int));
+  CPPUNIT_ASSERT_EQUAL(sizeof(int), MemoryUsageObserver::getInstance()->getUsedMemorySize());
+  MemoryUsageObserver::getInstance()->removeMemory(i);
+  CPPUNIT_ASSERT_EQUAL((size_t) 0, MemoryUsageObserver::getInstance()->getUsedMemorySize());
+  Free(i);
+};
+
+/**
+ * UnitTest for addMemory() and removeMemory()
+ */
+void MemoryUsageObserverTest::removeNonTrackedMemoryDoesNotCauseACrashTest()
+{
+  int* i = Malloc<int>(1, "MemoryUsageObserverTest::removeNonTrackedMemoryDoesNotCauseACrashTest - i");
+  MemoryUsageObserver::getInstance()->removeMemory(i);
+  CPPUNIT_ASSERT_EQUAL((size_t) 0, MemoryUsageObserver::getInstance()->getUsedMemorySize());
+  Free(i);
+};
+
+/**
+ * UnitTest for addMemory() and removeMemory()
+ */
+void MemoryUsageObserverTest::addMemoryTwiceTest()
+{
+  int* i = Malloc<int>(1, "MemoryUsageObserverTest::addMemoryTwiceTest - i");
+  int* j = Malloc<int>(1, "MemoryUsageObserverTest::addMemoryTwiceTest - j");
+  MemoryUsageObserver::getInstance()->addMemory(i, sizeof(int));
+  MemoryUsageObserver::getInstance()->addMemory(j, sizeof(int));
+  CPPUNIT_ASSERT_EQUAL(2 * sizeof(int), MemoryUsageObserver::getInstance()->getUsedMemorySize());
+  Free(i);
+  Free(j);
+};
+
+/**
+ * UnitTest for addMemory() and removeMemory()
+ */
+void MemoryUsageObserverTest::addMemoryAndChangeSizeOfAddedMemoryTest()
+{
+  int* i = Malloc<int>(1, "MemoryUsageObserverTest::addMemoryAndChangeSizeOfAddedMemoryTest - i");
+  MemoryUsageObserver::getInstance()->addMemory(i, 2 * sizeof(int));
+  MemoryUsageObserver::getInstance()->addMemory(i, sizeof(int));
+  CPPUNIT_ASSERT_EQUAL(sizeof(int), MemoryUsageObserver::getInstance()->getUsedMemorySize());
+  Free(i);
+};
+
+/**
+ * UnitTest for getMaximumUsedMemory()
+ */
+void MemoryUsageObserverTest::addMemoryChangeSizeOfAddedMemoryAndGetMaximumSizeTest()
+{
+  int* i = Malloc<int>(1, "MemoryUsageObserverTest::addMemoryChangeSizeOfAddedMemoryAndGetMaximumSizeTest - i");
+  MemoryUsageObserver::getInstance()->addMemory(i, 2 * sizeof(int));
+  MemoryUsageObserver::getInstance()->addMemory(i, sizeof(int));
+  CPPUNIT_ASSERT_EQUAL(2 * sizeof(int), MemoryUsageObserver::getInstance()->getMaximumUsedMemory());
+  Free(i);
+};
+
+/**
+ * UnitTest for getMaximumUsedMemory()
+ */
+void MemoryUsageObserverTest::addMemoryRemoveMemoryAndGetMaximumSizeTest()
+{
+  int* i = Malloc<int>(1, "MemoryUsageObserverTest::addMemoryRemoveMemoryAndGetMaximumSizeTest - i");
+  MemoryUsageObserver::getInstance()->addMemory(i, sizeof(int));
+  MemoryUsageObserver::getInstance()->removeMemory(i);
+  CPPUNIT_ASSERT_EQUAL(sizeof(int), MemoryUsageObserver::getInstance()->getMaximumUsedMemory());
+  Free(i);
+};
+
+/**
+ * UnitTest for getPointersToAllocatedMemory()
+ */
+void MemoryUsageObserverTest::getPointersToAllocatedMemoryTest()
+{
+  int* i = Malloc<int>(1, "MemoryUsageObserverTest::getPointersToAllocatedMemoryTest - i");
+  MemoryUsageObserver::getInstance()->addMemory(i, sizeof(int));
+  CPPUNIT_ASSERT_EQUAL(i, (int*) MemoryUsageObserver::getInstance()->getPointersToAllocatedMemory().begin()->first);
+  Free(i);
+};
Index: src/unittests/memoryusageobserverunittest.hpp
===================================================================
--- src/unittests/memoryusageobserverunittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/memoryusageobserverunittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,46 @@
+/*
+ * memoryusageobserverunittest.hpp
+ */
+
+#ifndef MEMORYUSAGEOBSERVERTEST_HPP_
+#define MEMORYUSAGEOBSERVERTEST_HPP_
+
+#include "memoryusageobserver.hpp"
+#include <cppunit/extensions/HelperMacros.h>
+
+
+/********************************************** Test classes **************************************/
+
+class MemoryUsageObserverTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( MemoryUsageObserverTest) ;
+    CPPUNIT_TEST ( getInstanceReturnsMemoryUsageObserverTest );
+    CPPUNIT_TEST ( getInstanceTwiceReturnsSameInstanceTest );
+    CPPUNIT_TEST ( getInstanceAfterPurgeInstanceReturnsNewInstanceTest );
+    CPPUNIT_TEST ( addAndRemoveMemoryTest );
+    CPPUNIT_TEST ( removeNonTrackedMemoryDoesNotCauseACrashTest );
+    CPPUNIT_TEST ( addMemoryTwiceTest );
+    CPPUNIT_TEST ( addMemoryAndChangeSizeOfAddedMemoryTest );
+    CPPUNIT_TEST ( addMemoryChangeSizeOfAddedMemoryAndGetMaximumSizeTest );
+    CPPUNIT_TEST ( addMemoryRemoveMemoryAndGetMaximumSizeTest );
+    CPPUNIT_TEST ( getPointersToAllocatedMemoryTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+    void setUp();
+    void tearDown();
+
+    void getInstanceReturnsMemoryUsageObserverTest();
+    void getInstanceTwiceReturnsSameInstanceTest();
+    void getInstanceAfterPurgeInstanceReturnsNewInstanceTest();
+    void addAndRemoveMemoryTest();
+    void removeNonTrackedMemoryDoesNotCauseACrashTest();
+    void addMemoryTwiceTest();
+    void addMemoryAndChangeSizeOfAddedMemoryTest();
+    void addMemoryChangeSizeOfAddedMemoryAndGetMaximumSizeTest();
+    void addMemoryRemoveMemoryAndGetMaximumSizeTest();
+    void getPointersToAllocatedMemoryTest();
+};
+
+#endif /* MEMORYUSAGEOBSERVERTEST_HPP_ */
+
Index: src/unittests/periodentafelTest.cpp
===================================================================
--- src/unittests/periodentafelTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/periodentafelTest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,78 @@
+/*
+ * periodentafelTest.cpp
+ *
+ *  Created on: May 18, 2010
+ *      Author: heber
+ */
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "Helpers/Assert.hpp"
+
+#include "World.hpp"
+#include "periodentafelTest.hpp"
+#include "element.hpp"
+#include "elements_db.hpp"
+#include "periodentafel.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( periodentafelTest );
+
+
+void periodentafelTest::setUp()
+{
+  // make sure world is present
+  tafel = World::getInstance().getPeriode();
+  CPPUNIT_ASSERT(tafel != NULL && "could not obtain periodentafel");
+};
+
+
+void periodentafelTest::tearDown()
+{
+  World::purgeInstance();
+};
+
+/** UnitTest for AddRemoveTest().
+ */
+void periodentafelTest::AddRemoveTest()
+{
+  // copy the element
+  const element * ElementPtr = tafel->FindElement(3);
+  CPPUNIT_ASSERT( ElementPtr != NULL && "could not find element lithium");
+  element *Elemental = new element(*ElementPtr);
+  // remove element
+  tafel->RemoveElement((element * const)ElementPtr);
+  ElementPtr = tafel->FindElement(3);
+  CPPUNIT_ASSERT_EQUAL( (const element *)NULL, ElementPtr );
+  // add element again
+  tafel->AddElement((element * const)Elemental);
+  ElementPtr = tafel->FindElement(3);
+  CPPUNIT_ASSERT( ElementPtr != NULL && "could not find re-added element lithium");
+};
+
+/** UnitTest for LoadStoreTest().
+ * TODO: periodentafelTest::LoadStoreTest() not implemented yet
+ */
+void periodentafelTest::LoadStoreTest()
+{
+  // reload all databases
+  CPPUNIT_ASSERT(tafel->LoadElementsDatabase(new stringstream(elementsDB,ios_base::in)) && "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");
+  CPPUNIT_ASSERT(tafel->LoadHBondAngleDatabase(new stringstream(HbondangleDB,ios_base::in)) && "HBond angle entry of element initialization failed");
+  CPPUNIT_ASSERT(tafel->LoadHBondLengthsDatabase(new stringstream(HbonddistanceDB,ios_base::in)) && "HBond distance entry of element initialization failed");
+  // check presence of elements
+  atomicNumber_t Z = 1;
+  for(periodentafel::const_iterator ElementRunner = tafel->begin(); ElementRunner != tafel->end(); ++ElementRunner)
+    CPPUNIT_ASSERT( (ElementRunner->second->getNumber() == Z++) && "element is missing in sequence");
+};
Index: src/unittests/periodentafelTest.hpp
===================================================================
--- src/unittests/periodentafelTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/periodentafelTest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,39 @@
+/*
+ * periodentafelTest.hpp
+ *
+ *  Created on: May 18, 2010
+ *      Author: heber
+ */
+
+#ifndef ANALYSISBONDSUNITTEST_HPP_
+#define ANALYSISBONDSUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class element;
+class periodentafel;
+
+/********************************************** Test classes **************************************/
+
+class periodentafelTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( periodentafelTest) ;
+    CPPUNIT_TEST ( AddRemoveTest );
+    CPPUNIT_TEST ( LoadStoreTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+      void AddRemoveTest();
+      void LoadStoreTest();
+
+private:
+
+      element *hydrogen;
+      element *carbon;
+      periodentafel *tafel;
+
+};
+
+#endif /* ANALYSISBONDSUNITTEST_HPP_ */
Index: src/unittests/stackclassunittest.cpp
===================================================================
--- src/unittests/stackclassunittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/stackclassunittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,73 @@
+/*
+ * stackclassunittest.cpp
+ *
+ *  Created on: Oct 27, 2009
+ *      Author: heber
+ */
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "stackclassunittest.hpp"
+#include "log.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+enum { testdimension=3 };
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( StackClassTest );
+
+
+void StackClassTest::setUp()
+{
+  Stack = new StackClass<int *>(testdimension);
+};
+
+
+void StackClassTest::tearDown()
+{
+  Stack->ClearStack();
+  delete(Stack);
+  logger::purgeInstance();
+};
+
+/** UnitTest for StackClass<T> implementation
+ *
+ */
+
+void StackClassTest::TestImplementation()
+{
+  int testfield[testdimension] = {0,1,2};
+  //Log() << Verbose(1) << "Testing the snake stack..." << endl;
+  for (int i=0;i<testdimension;i++) {
+    //Log() << Verbose(2) << "Filling " << i << "th element of stack." << endl;
+    Stack->Push(&testfield[i]);
+  }
+  //Log() << Verbose(0) << endl;
+  //Output(out);
+  CPPUNIT_ASSERT_EQUAL(true, Stack->IsFull());
+  CPPUNIT_ASSERT_EQUAL(false, Stack->IsEmpty());
+  CPPUNIT_ASSERT_EQUAL((testdimension) % (int)testdimension, Stack->ItemCount());
+
+  CPPUNIT_ASSERT_EQUAL( true, Stack->RemoveItem(&testfield[1]) );
+  CPPUNIT_ASSERT_EQUAL((testdimension-1) % (int)testdimension, Stack->ItemCount());
+
+  CPPUNIT_ASSERT_EQUAL( true, Stack->RemoveItem(&testfield[2]) );
+  CPPUNIT_ASSERT_EQUAL((testdimension-2) % (int)testdimension, Stack->ItemCount());
+
+  CPPUNIT_ASSERT_EQUAL( true, Stack->RemoveItem(&testfield[0]) );
+  CPPUNIT_ASSERT_EQUAL((testdimension-3) % (int)testdimension, Stack->ItemCount());
+
+  Stack->ClearStack();
+  CPPUNIT_ASSERT_EQUAL(false, Stack->IsFull());
+  CPPUNIT_ASSERT_EQUAL(true, Stack->IsEmpty());
+  CPPUNIT_ASSERT_EQUAL(0, Stack->ItemCount());
+};
Index: src/unittests/stackclassunittest.hpp
===================================================================
--- src/unittests/stackclassunittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/stackclassunittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,36 @@
+/*
+ * stackclassunittest.hpp
+ *
+ *  Created on: Oct 27, 2009
+ *      Author: heber
+ */
+
+#ifndef STACKCLASSUNITTEST_HPP_
+#define STACKCLASSUNITTEST_HPP_
+
+/*********************************************** includes ***********************************/
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "stackclass.hpp"
+
+/********************************************** Test classes **************************************/
+
+class StackClassTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( StackClassTest) ;
+    CPPUNIT_TEST ( TestImplementation );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+      void TestImplementation();
+
+
+private:
+      StackClass<int *> *Stack;
+};
+
+
+#endif /* STACKCLASSUNITTEST_HPP_ */
Index: src/unittests/tesselation_boundarytriangleunittest.cpp
===================================================================
--- src/unittests/tesselation_boundarytriangleunittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/tesselation_boundarytriangleunittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,196 @@
+/*
+ * tesselation_boundarytriangleunittest.cpp
+ *
+ *  Created on: Jan 13, 2010
+ *      Author: heber
+ */
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <cstring>
+
+#include "defs.hpp"
+#include "tesselation.hpp"
+#include "tesselation_boundarytriangleunittest.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+#define SPHERERADIUS 2.
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( TesselationBoundaryTriangleTest );
+
+
+void TesselationBoundaryTriangleTest::setUp()
+{
+  setVerbosity(5);
+
+  // create nodes
+  tesselpoints[0] = new TesselPoint;
+  tesselpoints[0]->node = new 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]->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]->setName("3");
+  tesselpoints[2]->nr = 3;
+  points[2] = new BoundaryPointSet(tesselpoints[2] );
+
+  // create line
+  lines[0] = new BoundaryLineSet(points[0], points[1], 0);
+  lines[1] = new BoundaryLineSet(points[1], points[2], 1);
+  lines[2] = new BoundaryLineSet(points[0], points[2], 2);
+
+  // create triangle
+  triangle = new BoundaryTriangleSet(lines, 0);
+  triangle->GetNormalVector(Vector(0.,0.,1.));
+};
+
+
+void TesselationBoundaryTriangleTest::tearDown()
+{
+  delete(triangle);
+  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];
+  }
+  logger::purgeInstance();
+  errorLogger::purgeInstance();
+};
+
+/** UnitTest for Tesselation::IsInnerPoint()
+ */
+void TesselationBoundaryTriangleTest::GetClosestPointOnPlaneTest()
+{
+  Vector TestIntersection;
+  Vector Point;
+
+  // simple test on y line
+  Point = Vector(-1.,0.5,0.);
+  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) );
+  Point = Vector(0.,0.5,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on x line
+  Point = Vector(0.5,-1.,0.);
+  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) );
+  Point = Vector(0.5,0.,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on slanted line
+  Point = Vector(1.,1.,0.);
+  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) );
+  Point = Vector(0.5,0.5,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on first node
+  Point = Vector(-1.,-1.,0.);
+  CPPUNIT_ASSERT_EQUAL( 2., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  Point = Vector(0.,0.,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on second node
+  Point = Vector(0.,2.,0.);
+  CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  Point = Vector(0.,1.,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on third node
+  Point = Vector(2.,0.,0.);
+  CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  Point = Vector(1.,0.,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+};
+
+/** UnitTest for Tesselation::IsInnerPoint()
+ */
+void TesselationBoundaryTriangleTest::GetClosestPointOffPlaneTest()
+{
+  Vector TestIntersection;
+  Vector Point;
+
+  // straight down/up
+  Point = Vector(1./3.,1./3.,+5.);
+  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) );
+  Point = Vector(1./3.,1./3.,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on y line
+  Point = Vector(-1.,0.5,+2.);
+  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) );
+  Point = Vector(0.,0.5,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on x line
+  Point = Vector(0.5,-1.,+1.);
+  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) );
+  Point = Vector(0.5,0.,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on slanted line
+  Point = Vector(1.,1.,+3.);
+  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) );
+  Point = Vector(0.5,0.5,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on first node
+  Point = Vector(-1.,-1.,5.);
+  CPPUNIT_ASSERT_EQUAL( 27., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  Point = Vector(0.,0.,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on second node
+  Point = Vector(0.,2.,5.);
+  CPPUNIT_ASSERT_EQUAL( 26., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  Point = Vector(0.,1.,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on third node
+  Point = Vector(2.,0.,5.);
+  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 ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/tesselation_boundarytriangleunittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+/*
+ * tesselation_boundarytriangleunittest.hpp
+ *
+ *  Created on: Jan 13, 2010
+ *      Author: heber
+ */
+
+#ifndef TESSELATION_BOUNDARYTRIANGLEUNITTEST_HPP_
+#define TESSELATION_BOUNDARYTRIANGLEUNITTEST_HPP_
+
+/*********************************************** includes ***********************************/
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "linkedcell.hpp"
+#include "tesselation.hpp"
+
+/********************************************** Test classes **************************************/
+
+class TesselationBoundaryTriangleTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( TesselationBoundaryTriangleTest) ;
+    CPPUNIT_TEST ( GetClosestPointOnPlaneTest );
+    CPPUNIT_TEST ( GetClosestPointOffPlaneTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+      void GetClosestPointOnPlaneTest();
+      void GetClosestPointOffPlaneTest();
+
+private:
+      class BoundaryTriangleSet *triangle;
+      class BoundaryLineSet *lines[3];
+      class BoundaryPointSet *points[3];
+      class TesselPoint *tesselpoints[3];
+      LinkedCell::LinkedNodes Corners;
+};
+
+
+#endif /* TESSELATION_BOUNDARYTRIANGLEUNITTEST_HPP_ */
Index: src/unittests/tesselation_insideoutsideunittest.cpp
===================================================================
--- src/unittests/tesselation_insideoutsideunittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/tesselation_insideoutsideunittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,157 @@
+/*
+ * tesselation_insideoutsideunittest.cpp
+ *
+ *  Created on: Dec 28, 2009
+ *      Author: heber
+ */
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <cstring>
+
+#include "defs.hpp"
+#include "tesselation.hpp"
+#include "tesselation_insideoutsideunittest.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+#define SPHERERADIUS 2.
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( TesselationInOutsideTest );
+
+
+void TesselationInOutsideTest::setUp()
+{
+  setVerbosity(2);
+
+  // create corners
+  class TesselPoint *Walker;
+  Walker = new TesselPoint;
+  Walker->node = new 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->setName("2");
+  Walker->nr = 2;
+  Corners.push_back(Walker);
+  Walker = new TesselPoint;
+  Walker->node = new 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->setName("4");
+  Walker->nr = 4;
+  Corners.push_back(Walker);
+  Walker = new TesselPoint;
+  Walker->node = new 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->setName("6");
+  Walker->nr = 6;
+  Corners.push_back(Walker);
+  Walker = new TesselPoint;
+  Walker->node = new 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->setName("8");
+  Walker->nr = 8;
+  Corners.push_back(Walker);
+
+  // create linkedcell
+  LinkedList = new LinkedCell(&Corners, 2.*SPHERERADIUS);
+
+  // create tesselation
+  TesselStruct = new Tesselation;
+  TesselStruct->FindStartingTriangle(SPHERERADIUS, LinkedList);
+
+  CandidateForTesselation *baseline = NULL;
+  BoundaryTriangleSet *T = NULL;
+  bool OneLoopWithoutSuccessFlag = true;
+  bool TesselationFailFlag = false;
+  while ((!TesselStruct->OpenLines.empty()) && (OneLoopWithoutSuccessFlag)) {
+    // 2a. fill all new OpenLines
+    DoLog(1) && (Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for candidates:" << endl);
+    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++)
+      DoLog(2) && (Log() << Verbose(2) << *(Runner->second) << endl);
+
+    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) {
+      baseline = Runner->second;
+      if (baseline->pointlist.empty()) {
+        T = (((baseline->BaseLine->triangles.begin()))->second);
+        DoLog(1) && (Log() << Verbose(1) << "Finding best candidate for open line " << *baseline->BaseLine << " of triangle " << *T << endl);
+        TesselationFailFlag = TesselStruct->FindNextSuitableTriangle(*baseline, *T, SPHERERADIUS, LinkedList); //the line is there, so there is a triangle, but only one.
+      }
+    }
+
+    // 2b. search for smallest ShortestAngle among all candidates
+    double ShortestAngle = 4.*M_PI;
+    DoLog(1) && (Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for the best candidates:" << endl);
+    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++)
+      DoLog(2) && (Log() << Verbose(2) << *(Runner->second) << endl);
+
+    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) {
+      if (Runner->second->ShortestAngle < ShortestAngle) {
+        baseline = Runner->second;
+        ShortestAngle = baseline->ShortestAngle;
+        //Log() << Verbose(1) << "New best candidate is " << *baseline->BaseLine << " with point " << *baseline->point << " and angle " << baseline->ShortestAngle << endl;
+      }
+    }
+    if ((ShortestAngle == 4.*M_PI) || (baseline->pointlist.empty()))
+      OneLoopWithoutSuccessFlag = false;
+    else {
+      TesselStruct->AddCandidatePolygon(*baseline, SPHERERADIUS, LinkedList);
+    }
+  }
+};
+
+
+void TesselationInOutsideTest::tearDown()
+{
+  delete(LinkedList);
+  delete(TesselStruct);
+  for (LinkedCell::LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) {
+    delete((*Runner)->node);
+    delete(*Runner);
+  }
+  Corners.clear();
+  logger::purgeInstance();
+  errorLogger::purgeInstance();
+};
+
+/** UnitTest for Tesselation::IsInnerPoint()
+ */
+void TesselationInOutsideTest::IsInnerPointTest()
+{
+  double n[3];
+  const double boundary = 2.;
+  const double step = 1.;
+
+  // go through the mesh and check each point
+  for (n[0] = -boundary; n[0] <= boundary; n[0]+=step)
+    for (n[1] = -boundary; n[1] <= boundary; n[1]+=step)
+      for (n[2] = -boundary; n[2] <= boundary; n[2]+=step) {
+        if ( ((n[0] >= 0.) && (n[1] >= 0.) && (n[2] >= 0.)) && ((n[0] <= 1.) && (n[1] <= 1.) && (n[2] <= 1.)))
+          CPPUNIT_ASSERT_EQUAL( true , TesselStruct->IsInnerPoint(Vector(n[0], n[1], n[2]), LinkedList) );
+        else
+          CPPUNIT_ASSERT_EQUAL( false , TesselStruct->IsInnerPoint(Vector(n[0], n[1], n[2]), LinkedList) );
+      }
+};
Index: src/unittests/tesselation_insideoutsideunittest.hpp
===================================================================
--- src/unittests/tesselation_insideoutsideunittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/tesselation_insideoutsideunittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,38 @@
+/*
+ * tesselation_insideoutsideunittest.hpp
+ *
+ *  Created on: Dec 28, 2009
+ *      Author: heber
+ */
+
+#ifndef TESSELATION_INSIDEOUTSIDEUNITTEST_HPP_
+#define TESSELATION_INSIDEOUTSIDEUNITTEST_HPP_
+
+/*********************************************** includes ***********************************/
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "linkedcell.hpp"
+#include "tesselation.hpp"
+
+/********************************************** Test classes **************************************/
+
+class TesselationInOutsideTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( TesselationInOutsideTest) ;
+    CPPUNIT_TEST ( IsInnerPointTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+      void IsInnerPointTest();
+
+private:
+      class Tesselation *TesselStruct;
+      LinkedCell::LinkedNodes Corners;
+      class LinkedCell *LinkedList;
+};
+
+
+#endif /* TESSELATION_INSIDEOUTSIDEUNITTEST_HPP_ */
Index: src/unittests/tesselationunittest.cpp
===================================================================
--- src/unittests/tesselationunittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/tesselationunittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,177 @@
+/*
+ * tesselationunittest.cpp
+ *
+ *  Created on: Aug 26, 2009
+ *      Author: heber
+ */
+
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <cstring>
+
+#include "defs.hpp"
+#include "tesselation.hpp"
+#include "tesselationunittest.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+#define SPHERERADIUS 2.
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( TesselationTest );
+
+
+void TesselationTest::setUp()
+{
+  // create corners
+  class TesselPoint *Walker;
+  Walker = new TesselPoint;
+  Walker->node = new 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->setName("2");
+  Walker->nr = 2;
+  Corners.push_back(Walker);
+  Walker = new TesselPoint;
+  Walker->node = new 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->setName("4");
+  Walker->nr = 4;
+  Corners.push_back(Walker);
+
+  // create linkedcell
+  LinkedList = new LinkedCell(&Corners, 2.*SPHERERADIUS);
+
+  // create tesselation
+  TesselStruct = new Tesselation;
+  CPPUNIT_ASSERT_EQUAL( true, TesselStruct->PointsOnBoundary.empty() );
+  CPPUNIT_ASSERT_EQUAL( true, TesselStruct->LinesOnBoundary.empty() );
+  CPPUNIT_ASSERT_EQUAL( true, TesselStruct->TrianglesOnBoundary.empty() );
+  TesselStruct->FindStartingTriangle(SPHERERADIUS, LinkedList);
+
+  CandidateForTesselation *baseline = NULL;
+  BoundaryTriangleSet *T = NULL;
+  bool OneLoopWithoutSuccessFlag = true;
+  bool TesselationFailFlag = false;
+  while ((!TesselStruct->OpenLines.empty()) && (OneLoopWithoutSuccessFlag)) {
+    // 2a. fill all new OpenLines
+    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) {
+      baseline = Runner->second;
+      if (baseline->pointlist.empty()) {
+        T = (((baseline->BaseLine->triangles.begin()))->second);
+        TesselationFailFlag = TesselStruct->FindNextSuitableTriangle(*baseline, *T, SPHERERADIUS, LinkedList); //the line is there, so there is a triangle, but only one.
+      }
+    }
+
+    // 2b. search for smallest ShortestAngle among all candidates
+    double ShortestAngle = 4.*M_PI;
+    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) {
+      if (Runner->second->ShortestAngle < ShortestAngle) {
+        baseline = Runner->second;
+        ShortestAngle = baseline->ShortestAngle;
+      }
+    }
+    if ((ShortestAngle == 4.*M_PI) || (baseline->pointlist.empty()))
+      OneLoopWithoutSuccessFlag = false;
+    else {
+      TesselStruct->AddCandidatePolygon(*baseline, SPHERERADIUS, LinkedList);
+    }
+  }
+};
+
+
+void TesselationTest::tearDown()
+{
+  delete(LinkedList);
+  delete(TesselStruct);
+  for (LinkedCell::LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) {
+    delete((*Runner)->node);
+    delete(*Runner);
+  }
+  Corners.clear();
+  logger::purgeInstance();
+  errorLogger::purgeInstance();
+};
+
+/** UnitTest for Contains...()
+ *
+ */
+void TesselationTest::ContainmentTest()
+{
+  class BoundaryPointSet *point = NULL;
+  class BoundaryLineSet *line = NULL;
+
+  // check ContainsBoundaryPoint
+  for(LineMap::iterator Runner = TesselStruct->LinesOnBoundary.begin(); Runner != TesselStruct->LinesOnBoundary.end(); Runner++) {
+    CPPUNIT_ASSERT_EQUAL( true, (Runner->second)->ContainsBoundaryPoint((Runner->second)->endpoints[0]));
+    CPPUNIT_ASSERT_EQUAL( true, (Runner->second)->ContainsBoundaryPoint((Runner->second)->endpoints[1]));
+  }
+  for(TriangleMap::iterator Runner = TesselStruct->TrianglesOnBoundary.begin(); Runner != TesselStruct->TrianglesOnBoundary.end(); Runner++) {
+    for(PointMap::iterator PointRunner = TesselStruct->PointsOnBoundary.begin(); PointRunner != TesselStruct->PointsOnBoundary.end(); PointRunner++) {
+      point = PointRunner->second;
+      for (int i=0;i<3;i++)
+        if (point == (Runner->second)->endpoints[i])
+          point = NULL;
+      if (point != NULL)
+        break;
+    }
+    CPPUNIT_ASSERT_EQUAL( true, (Runner->second)->ContainsBoundaryPoint((Runner->second)->endpoints[0]));
+    CPPUNIT_ASSERT_EQUAL( true, (Runner->second)->ContainsBoundaryPoint((Runner->second)->endpoints[1]));
+    CPPUNIT_ASSERT_EQUAL( true, (Runner->second)->ContainsBoundaryPoint((Runner->second)->endpoints[2]));
+    CPPUNIT_ASSERT_EQUAL( false, (Runner->second)->ContainsBoundaryPoint(point));
+  }
+
+  // check ContainsBoundaryLine
+  for(TriangleMap::iterator Runner = TesselStruct->TrianglesOnBoundary.begin(); Runner != TesselStruct->TrianglesOnBoundary.end(); Runner++) {
+    for(LineMap::iterator LineRunner = TesselStruct->LinesOnBoundary.begin(); LineRunner != TesselStruct->LinesOnBoundary.end(); LineRunner++) {
+      line = LineRunner->second;
+      for (int i=0;i<3;i++)
+        if (line == (Runner->second)->lines[i])
+          line = NULL;
+      if (line != NULL)
+        break;
+    }
+    CPPUNIT_ASSERT_EQUAL( true, (Runner->second)->ContainsBoundaryLine((Runner->second)->lines[0]));
+    CPPUNIT_ASSERT_EQUAL( true, (Runner->second)->ContainsBoundaryLine((Runner->second)->lines[1]));
+    CPPUNIT_ASSERT_EQUAL( true, (Runner->second)->ContainsBoundaryLine((Runner->second)->lines[2]));
+    CPPUNIT_ASSERT_EQUAL( false, (Runner->second)->ContainsBoundaryLine(line));
+  }
+
+  // check IsPresentTupel
+  CPPUNIT_ASSERT_EQUAL( true, true );
+}
+
+/** UnitTest for Tesselation::GetAllTriangles()
+ *
+ */
+void TesselationTest::GetAllTrianglesTest()
+{
+  class BoundaryPointSet *Walker = NULL;
+
+  // check that there are three adjacent triangles for every boundary point
+  for (PointMap::iterator Runner = TesselStruct->PointsOnBoundary.begin(); Runner != TesselStruct->PointsOnBoundary.end(); Runner++) {
+    Walker = Runner->second;
+    set<BoundaryTriangleSet*> *triangles = TesselStruct->GetAllTriangles(Walker);
+    CPPUNIT_ASSERT_EQUAL( (size_t)3, triangles->size() );
+    // check that the returned triangle all contain the Walker
+    for (set<BoundaryTriangleSet*>::iterator TriangleRunner = triangles->begin(); TriangleRunner != triangles->end(); TriangleRunner++)
+      CPPUNIT_ASSERT_EQUAL( true, (*TriangleRunner)->ContainsBoundaryPoint(Walker) );
+    delete(triangles);
+  }
+}
Index: src/unittests/tesselationunittest.hpp
===================================================================
--- src/unittests/tesselationunittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/tesselationunittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+/*
+ * tesselationunittest.hpp
+ *
+ *  Created on: Aug 26, 2009
+ *      Author: heber
+ */
+
+#ifndef TESSELATIONUNITTEST_HPP_
+#define TESSELATIONUNITTEST_HPP_
+
+/*********************************************** includes ***********************************/
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "linkedcell.hpp"
+#include "tesselation.hpp"
+
+/********************************************** Test classes **************************************/
+
+class TesselationTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( TesselationTest) ;
+    CPPUNIT_TEST ( GetAllTrianglesTest );
+    CPPUNIT_TEST ( ContainmentTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+      void GetAllTrianglesTest();
+      void ContainmentTest();
+
+
+private:
+      class Tesselation *TesselStruct;
+      LinkedCell::LinkedNodes Corners;
+      class LinkedCell *LinkedList;
+};
+
+
+
+#endif /* TESSELATIONUNITTEST_HPP_ */
Index: src/unittests/vectorunittest.cpp
===================================================================
--- src/unittests/vectorunittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/vectorunittest.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,249 @@
+/*
+ * unittest.cpp
+ *
+ *  Created on: Aug 17, 2009
+ *      Author: heber
+ */
+
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "defs.hpp"
+#include "log.hpp"
+#include "memoryusageobserver.hpp"
+#include "vector.hpp"
+#include "vector_ops.hpp"
+#include "vectorunittest.hpp"
+#include "Plane.hpp"
+#include "Exceptions/LinearDependenceException.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+#include <iostream>
+
+using namespace std;
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( VectorTest );
+
+
+void VectorTest::setUp()
+{
+  zero  = Vector(0.,0.,0.);
+  unit = Vector(1.,0.,0.);
+  otherunit = Vector(0.,1.,0.);
+  notunit = Vector(0.,1.,1.);
+  two = Vector(2.,1.,0.);
+  three = Vector(1,2,3);
+};
+
+
+void VectorTest::tearDown()
+{
+  logger::purgeInstance();
+  errorLogger::purgeInstance();
+};
+
+/** UnitTest for Constructors and Vector::IsZero() and Vector::IsOne().
+ */
+void VectorTest::UnityTest()
+{
+  // unity and zero tests
+  CPPUNIT_ASSERT_EQUAL( true, zero.IsZero() );
+  CPPUNIT_ASSERT_EQUAL( false, zero.IsOne() );
+  CPPUNIT_ASSERT_EQUAL( false, unit.IsZero() );
+  CPPUNIT_ASSERT_EQUAL( true, unit.IsOne() );
+  CPPUNIT_ASSERT_EQUAL( false, notunit.IsOne() );
+  CPPUNIT_ASSERT_EQUAL( true, otherunit.IsOne() );
+  CPPUNIT_ASSERT_EQUAL( false, otherunit.IsZero() );
+};
+
+/** UnitTest for Vector::CopyVector(), Vector::AddVector, Vector::SubtractVector() and Vector::Scale()/
+ */
+void VectorTest::SimpleAlgebraTest()
+{
+  double factor;
+  // copy vector
+  fixture = Vector(2.,3.,4.);
+  CPPUNIT_ASSERT_EQUAL( Vector(2.,3.,4.), fixture );
+  // summation and scaling
+  fixture = zero + unit;
+  CPPUNIT_ASSERT_EQUAL( true, fixture.IsOne() );
+  fixture = zero - unit;
+  CPPUNIT_ASSERT_EQUAL( true, fixture.IsOne() );
+  CPPUNIT_ASSERT_EQUAL( false, fixture.IsZero() );
+  fixture = zero + zero;
+  CPPUNIT_ASSERT_EQUAL( true, fixture.IsZero() );
+  fixture = notunit - otherunit;
+  CPPUNIT_ASSERT_EQUAL( true, fixture.IsOne() );
+  fixture = unit - otherunit;
+  CPPUNIT_ASSERT_EQUAL( false, fixture.IsOne() );
+  fixture = notunit - unit - otherunit;
+  CPPUNIT_ASSERT_EQUAL( false, fixture.IsZero() );
+  fixture = 0.98 * unit;
+  CPPUNIT_ASSERT_EQUAL( false, fixture.IsOne() );
+  fixture = 1. * unit;
+  CPPUNIT_ASSERT_EQUAL( true, fixture.IsOne() );
+  factor = 0.98;
+  fixture = factor * unit;
+  CPPUNIT_ASSERT_EQUAL( false, fixture.IsOne() );
+  factor = 1.;
+  fixture = factor * unit;
+  CPPUNIT_ASSERT_EQUAL( true, fixture.IsOne() );
+};
+
+
+/** UnitTest for operator versions of Vector::CopyVector(), Vector::AddVector, Vector::SubtractVector() and Vector::Scale().
+ */
+void VectorTest::OperatorAlgebraTest()
+{
+  // summation and scaling
+  CPPUNIT_ASSERT_EQUAL( true, (zero+unit).IsOne() );
+  CPPUNIT_ASSERT_EQUAL( true, (zero+unit).IsOne() );
+  CPPUNIT_ASSERT_EQUAL( true, (zero-unit).IsOne() );
+  CPPUNIT_ASSERT_EQUAL( false, (zero-unit).IsZero() );
+  CPPUNIT_ASSERT_EQUAL( true, (zero+zero).IsZero() );
+  CPPUNIT_ASSERT_EQUAL( true, (notunit-otherunit).IsOne() );
+  CPPUNIT_ASSERT_EQUAL( false, (unit+otherunit).IsOne() );
+  CPPUNIT_ASSERT_EQUAL( false, (notunit-unit-otherunit).IsZero() );
+  CPPUNIT_ASSERT_EQUAL( false, (unit*0.98).IsOne() );
+  CPPUNIT_ASSERT_EQUAL( true, (unit*1.).IsOne() );
+
+  CPPUNIT_ASSERT_EQUAL( unit, (zero+unit) );
+  CPPUNIT_ASSERT_EQUAL( Vector(0.,0.,1.), (notunit-otherunit) );
+  CPPUNIT_ASSERT_EQUAL( Vector(-1, 0., 1.), (notunit-unit-otherunit) );
+};
+
+/** UnitTest for scalar products.
+ */
+void VectorTest::EuclidianScalarProductTest()
+{
+  CPPUNIT_ASSERT_EQUAL( 0., zero.ScalarProduct(zero) );
+  CPPUNIT_ASSERT_EQUAL( 0., zero.ScalarProduct(unit) );
+  CPPUNIT_ASSERT_EQUAL( 0., zero.ScalarProduct(otherunit) );
+  CPPUNIT_ASSERT_EQUAL( 0., zero.ScalarProduct(notunit) );
+  CPPUNIT_ASSERT_EQUAL( 1., unit.ScalarProduct(unit) );
+  CPPUNIT_ASSERT_EQUAL( 0., otherunit.ScalarProduct(unit) );
+  CPPUNIT_ASSERT_EQUAL( 0., otherunit.ScalarProduct(unit) );
+  CPPUNIT_ASSERT_EQUAL( 1., otherunit.ScalarProduct(notunit) );
+  CPPUNIT_ASSERT_EQUAL( 2., two.ScalarProduct(unit) );
+  CPPUNIT_ASSERT_EQUAL( 1., two.ScalarProduct(otherunit) );
+  CPPUNIT_ASSERT_EQUAL( 1., two.ScalarProduct(notunit) );
+}
+
+/** UnitTest for norms.
+ */
+void VectorTest::EuclidianNormTest()
+{
+  CPPUNIT_ASSERT_EQUAL( 0., zero.Norm() );
+  CPPUNIT_ASSERT_EQUAL( 0., zero.NormSquared() );
+  CPPUNIT_ASSERT_EQUAL( 1., unit.Norm() );
+  CPPUNIT_ASSERT_EQUAL( 1., unit.NormSquared() );
+  CPPUNIT_ASSERT_EQUAL( 1., otherunit.Norm() );
+  CPPUNIT_ASSERT_EQUAL( 1., otherunit.NormSquared() );
+  CPPUNIT_ASSERT_EQUAL( 2., notunit.NormSquared() );
+  CPPUNIT_ASSERT_EQUAL( sqrt(2.), notunit.Norm() );
+}
+
+/** UnitTest for distances.
+ */
+void VectorTest::EuclidianDistancesTest()
+{
+  CPPUNIT_ASSERT_EQUAL( 1., zero.distance(unit) );
+  CPPUNIT_ASSERT_EQUAL( sqrt(2.), otherunit.distance(unit) );
+  CPPUNIT_ASSERT_EQUAL( sqrt(2.), zero.distance(notunit) );
+  CPPUNIT_ASSERT_EQUAL( 1., otherunit.distance(notunit) );
+  CPPUNIT_ASSERT_EQUAL( sqrt(5.), two.distance(notunit) );
+}
+
+/** UnitTest for angles.
+ */
+void VectorTest::EuclidianAnglesTest()
+{
+  CPPUNIT_ASSERT_EQUAL( M_PI, zero.Angle(unit) );
+  CPPUNIT_ASSERT_EQUAL( 0., unit.Angle(unit) );
+  CPPUNIT_ASSERT_EQUAL( true, fabs(M_PI/2. - otherunit.Angle(unit)) < MYEPSILON );
+  CPPUNIT_ASSERT_EQUAL( true, fabs(M_PI/2. - unit.Angle(notunit)) < MYEPSILON );
+  CPPUNIT_ASSERT_EQUAL( true, fabs(M_PI/4. - otherunit.Angle(notunit)) < MYEPSILON );
+};
+
+/** UnitTest for projections.
+ */
+void VectorTest::ProjectionTest()
+{
+  CPPUNIT_ASSERT_EQUAL( zero, zero.Projection(unit) );
+  CPPUNIT_ASSERT_EQUAL( zero, otherunit.Projection(unit) );
+  CPPUNIT_ASSERT_EQUAL( Vector(0.4,0.2,0.),  otherunit.Projection(two) );
+  CPPUNIT_ASSERT_EQUAL( Vector(0.,1.,0.),  two.Projection(otherunit) );
+};
+
+/**
+ * Unittest for operation with normals
+ */
+void VectorTest::NormalsTest(){
+  Vector testVector;
+  // the zero Vector should produce an error
+  CPPUNIT_ASSERT(!testVector.GetOneNormalVector(zero));
+
+  // first one-component system
+  CPPUNIT_ASSERT(testVector.GetOneNormalVector(unit));
+  CPPUNIT_ASSERT(testVector.ScalarProduct(unit) < MYEPSILON);
+
+  // second one-component system
+  CPPUNIT_ASSERT(testVector.GetOneNormalVector(otherunit));
+  CPPUNIT_ASSERT(testVector.ScalarProduct(otherunit) < MYEPSILON);
+
+  // first two-component system
+  CPPUNIT_ASSERT(testVector.GetOneNormalVector(notunit));
+  CPPUNIT_ASSERT(testVector.ScalarProduct(notunit) < MYEPSILON);
+
+  // second two-component system
+  CPPUNIT_ASSERT(testVector.GetOneNormalVector(two));
+  CPPUNIT_ASSERT(testVector.ScalarProduct(two) < MYEPSILON);
+
+  // three component system
+  CPPUNIT_ASSERT(testVector.GetOneNormalVector(three));
+  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 ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/unittests/vectorunittest.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,62 @@
+/*
+ * cppunuit.hpp
+ *
+ *  Created on: Aug 17, 2009
+ *      Author: heber
+ */
+
+#ifndef VECTORUNITTEST_HPP_
+#define VECTORUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "vector.hpp"
+
+/********************************************** Test classes **************************************/
+
+class VectorTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( VectorTest) ;
+    CPPUNIT_TEST ( UnityTest );
+    CPPUNIT_TEST ( SimpleAlgebraTest );
+    CPPUNIT_TEST ( OperatorAlgebraTest );
+    CPPUNIT_TEST ( EuclidianScalarProductTest );
+    CPPUNIT_TEST ( EuclidianNormTest );
+    CPPUNIT_TEST ( EuclidianDistancesTest );
+    CPPUNIT_TEST ( EuclidianAnglesTest );
+    CPPUNIT_TEST ( ProjectionTest );
+    CPPUNIT_TEST ( NormalsTest );
+    CPPUNIT_TEST ( IsInParallelepipedTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+    void setUp();
+    void tearDown();
+
+    void UnityTest();
+    void OperatorAlgebraTest();
+    void SimpleAlgebraTest();
+    void EuclidianScalarProductTest();
+    void EuclidianNormTest();
+    void EuclidianDistancesTest();
+    void EuclidianAnglesTest();
+    void ProjectionTest();
+    void NormalsTest();
+    void LineIntersectionTest();
+    void VectorRotationTest();
+    void IsInParallelepipedTest();
+
+private:
+    // vector to execute tests on, may be modified during run
+    Vector fixture;
+    // never modify these during run, other tests might rely on them
+    Vector zero;
+    Vector unit;
+    Vector otherunit;
+    Vector notunit;
+    Vector two;
+    Vector three;
+};
+
+
+#endif /* VECTORUNITTEST_HPP_ */
Index: src/valence.db
===================================================================
--- src/valence.db	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/valence.db	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,66 @@
+#atomicnumber numberofvalenceorbitals
+1	0.10000000000000E+01
+2	0.20000000000000E+01
+3	0.10000000000000E+01
+4	0.20000000000000E+01
+5	0.30000000000000E+01
+6	0.40000000000000E+01
+7	0.50000000000000E+01
+8	0.60000000000000E+01
+9	0.70000000000000E+01
+10	0.80000000000000E+01
+11	0.10000000000000E+01
+12	0.40000000000000E+01
+13	.3000000000000000E+01
+14	0.40000000000000E+01
+15	0.50000000000000E+01
+16	0.60000000000000E+01
+17	0.70000000000000E+01
+18	0.80000000000000E+01
+19	0.30000000000000E+01
+20	0.40000000000000E+01
+21	0.30000000000000E+01
+22	0.40000000000000E+01
+23	0.50000000000000E+01
+24	0.60000000000000E+01
+25	0.70000000000000E+01
+26	0.80000000000000E+01
+27	0.90000000000000E+01
+28	0.10000000000000E+02
+29	0.11000000000000E+02
+30	0.12000000000000E+02
+31	3.00000000000000000
+32	0.40000000000000E+01
+33	5.00000000000000000
+34	0.60000000000000E+01
+35	0.70000000000000E+01
+36	0.80000000000000E+01
+37	0.10000000000000E+01
+38	0.20000000000000E+01
+39	0.30000000000000E+01
+40	0.40000000000000E+01
+41	0.50000000000000E+01
+42	0.60000000000000E+01
+43	0.70000000000000E+01
+44	0.80000000000000E+01
+45	0.90000000000000E+01
+46	0.10000000000000E+02
+47	0.11000000000000E+02
+48	0.12000000000000E+02
+49	0.30000000000000E+01
+50	0.40000000000000E+01
+51	0.50000000000000E+01
+52	0.60000000000000E+01
+53	0.70000000000000E+01
+54	0.80000000000000E+01
+55	0.10000000000000E+01
+56	0.20000000000000E+01
+72	0.40000000000000E+01
+73	0.50000000000000E+01
+74	0.60000000000000E+01
+75	0.70000000000000E+01
+76	0.80000000000000E+01
+77	0.90000000000000E+01
+78	0.10000000000000E+02
+79	0.11000000000000E+02
+80	0.12000000000000E+02
Index: src/vector.cpp
===================================================================
--- src/vector.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/vector.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,718 @@
+/** \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: src/vector.hpp
===================================================================
--- src/vector.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/vector.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,121 @@
+#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: src/vector_ops.cpp
===================================================================
--- src/vector_ops.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/vector_ops.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,114 @@
+/*
+ * 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: src/vector_ops.hpp
===================================================================
--- src/vector_ops.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/vector_ops.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -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/verbose.cpp
===================================================================
--- src/verbose.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/verbose.cpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,83 @@
+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: src/verbose.hpp
===================================================================
--- src/verbose.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/verbose.hpp	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -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 <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: src/version.h
===================================================================
--- src/version.h	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ src/version.h	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,6 @@
+#ifndef VERSION_H_
+#define VERSION_H_
+
+extern const char *ESPACKVersion;
+
+#endif /* VERSION_H_ */
Index: tests/Makefile.am
===================================================================
--- tests/Makefile.am	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Makefile.am	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,2 @@
+SUBDIRS = regression Tesselations
+
Index: tests/Tesselations/1_2-dimethoxyethane.test
===================================================================
--- tests/Tesselations/1_2-dimethoxyethane.test	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/1_2-dimethoxyethane.test	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,10 @@
+#! /bin/sh
+
+# Test a simple simulation: 
+
+. ./defs || exit 1
+set -e
+
+for radius in 1.5 2 2.5 3 3.5 4 25; do
+  Tesselation_run 0 $radius
+done
Index: tests/Tesselations/1_2-dimethoxyethane/1.5/NonConvexEnvelope-1_2-dimethoxyethane.dat
===================================================================
--- tests/Tesselations/1_2-dimethoxyethane/1.5/NonConvexEnvelope-1_2-dimethoxyethane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/1_2-dimethoxyethane/1.5/NonConvexEnvelope-1_2-dimethoxyethane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,64 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="1_2-dimethoxyethane", N=16, E=44, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0.7375 -0.7635 -0.2032 9
+-0.7375 -0.7635 0.2032 9
+1.3757 0.4033 0.3196 6
+-1.3757 0.4033 -0.3196 6
+2.743 0.3456 -0.0917 9
+-2.743 0.3456 0.0917 9
+1.2243 -1.6534 0.1956 4
+0.8147 -0.7635 -1.2905 3
+-1.2243 -1.6534 -0.1956 4
+-0.8147 -0.7635 1.2905 3
+3.2732 1.22 0.2858 5
+3.2041 -0.5585 0.3057 2
+2.7946 0.3315 -1.1804 4
+-3.2732 1.22 -0.2858 6
+-3.2041 -0.5585 -0.3057 3
+-2.7946 0.3315 1.1804 4
+
+5 11 12
+5 11 12
+5 11 13
+5 11 13
+5 12 13
+3 5 13
+3 5 11
+3 5 11
+3 5 12
+3 7 12
+1 3 7
+1 7 10
+1 3 10
+3 8 13
+1 3 8
+1 4 8
+1 3 4
+2 7 10
+2 9 10
+2 7 9
+1 7 9
+1 7 8
+1 8 9
+2 8 9
+2 4 9
+2 4 8
+4 9 15
+4 6 15
+6 14 15
+6 14 15
+6 14 16
+6 14 16
+6 15 16
+4 6 16
+4 6 14
+4 6 14
+4 10 16
+2 4 10
+2 3 10
+2 3 4
+7 12 13
+7 8 13
+9 15 16
+9 10 16
Index: tests/Tesselations/1_2-dimethoxyethane/1_2-dimethoxyethane.xyz
===================================================================
--- tests/Tesselations/1_2-dimethoxyethane/1_2-dimethoxyethane.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/1_2-dimethoxyethane/1_2-dimethoxyethane.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,18 @@
+16
+NCI NSC 60542 2,5-Dioxahexane
+C    0.7375   -0.7635   -0.2032
+C   -0.7375   -0.7635    0.2032
+O    1.3757    0.4033    0.3196
+O   -1.3757    0.4033   -0.3196
+C    2.7430    0.3456   -0.0917
+C   -2.7430    0.3456    0.0917
+H    1.2243   -1.6534    0.1956
+H    0.8147   -0.7635   -1.2905
+H   -1.2243   -1.6534   -0.1956
+H   -0.8147   -0.7635    1.2905
+H    3.2732    1.2200    0.2858
+H    3.2041   -0.5585    0.3057
+H    2.7946    0.3315   -1.1804
+H   -3.2732    1.2200   -0.2858
+H   -3.2041   -0.5585   -0.3057
+H   -2.7946    0.3315    1.1804
Index: tests/Tesselations/1_2-dimethoxyethane/2.5/NonConvexEnvelope-1_2-dimethoxyethane.dat
===================================================================
--- tests/Tesselations/1_2-dimethoxyethane/2.5/NonConvexEnvelope-1_2-dimethoxyethane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/1_2-dimethoxyethane/2.5/NonConvexEnvelope-1_2-dimethoxyethane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,36 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="1_2-dimethoxyethane", N=12, E=20, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+1.3757 0.4033 0.3196 2
+-1.3757 0.4033 -0.3196 2
+1.2243 -1.6534 0.1956 1
+0.8147 -0.7635 -1.2905 1
+-1.2243 -1.6534 -0.1956 1
+-0.8147 -0.7635 1.2905 1
+3.2732 1.22 0.2858 0
+3.2041 -0.5585 0.3057 0
+2.7946 0.3315 -1.1804 0
+-3.2732 1.22 -0.2858 0
+-3.2041 -0.5585 -0.3057 0
+-2.7946 0.3315 1.1804 0
+
+7 8 9
+4 8 9
+3 4 8
+3 4 5
+2 4 5
+2 5 11
+2 10 11
+3 5 6
+5 6 11
+6 11 12
+1 3 6
+1 3 8
+1 7 8
+10 11 12
+1 2 6
+2 6 12
+2 10 12
+1 2 4
+1 4 9
+1 7 9
Index: tests/Tesselations/1_2-dimethoxyethane/2/NonConvexEnvelope-1_2-dimethoxyethane.dat
===================================================================
--- tests/Tesselations/1_2-dimethoxyethane/2/NonConvexEnvelope-1_2-dimethoxyethane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/1_2-dimethoxyethane/2/NonConvexEnvelope-1_2-dimethoxyethane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,36 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="1_2-dimethoxyethane", N=12, E=20, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+1.3757 0.4033 0.3196 2
+-1.3757 0.4033 -0.3196 2
+1.2243 -1.6534 0.1956 1
+0.8147 -0.7635 -1.2905 1
+-1.2243 -1.6534 -0.1956 1
+-0.8147 -0.7635 1.2905 1
+3.2732 1.22 0.2858 0
+3.2041 -0.5585 0.3057 0
+2.7946 0.3315 -1.1804 0
+-3.2732 1.22 -0.2858 0
+-3.2041 -0.5585 -0.3057 0
+-2.7946 0.3315 1.1804 0
+
+7 8 9
+4 8 9
+3 4 8
+3 4 5
+3 5 6
+5 6 11
+6 11 12
+1 3 6
+1 3 8
+1 7 8
+2 4 5
+2 5 11
+2 10 11
+1 2 6
+2 6 12
+2 10 12
+1 2 4
+1 4 9
+1 7 9
+10 11 12
Index: tests/Tesselations/1_2-dimethoxyethane/25/NonConvexEnvelope-1_2-dimethoxyethane.dat
===================================================================
--- tests/Tesselations/1_2-dimethoxyethane/25/NonConvexEnvelope-1_2-dimethoxyethane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/1_2-dimethoxyethane/25/NonConvexEnvelope-1_2-dimethoxyethane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="1_2-dimethoxyethane", N=10, E=16, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+1.2243 -1.6534 0.1956 0
+0.8147 -0.7635 -1.2905 0
+-1.2243 -1.6534 -0.1956 0
+-0.8147 -0.7635 1.2905 0
+3.2732 1.22 0.2858 0
+3.2041 -0.5585 0.3057 0
+2.7946 0.3315 -1.1804 0
+-3.2732 1.22 -0.2858 0
+-3.2041 -0.5585 -0.3057 0
+-2.7946 0.3315 1.1804 0
+
+5 6 7
+2 6 7
+1 2 6
+1 2 3
+2 3 9
+2 8 9
+2 7 8
+5 7 8
+5 8 10
+4 5 10
+4 5 6
+1 4 6
+1 3 4
+3 4 9
+4 9 10
+8 9 10
Index: tests/Tesselations/1_2-dimethoxyethane/3.5/NonConvexEnvelope-1_2-dimethoxyethane.dat
===================================================================
--- tests/Tesselations/1_2-dimethoxyethane/3.5/NonConvexEnvelope-1_2-dimethoxyethane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/1_2-dimethoxyethane/3.5/NonConvexEnvelope-1_2-dimethoxyethane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,36 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="1_2-dimethoxyethane", N=12, E=20, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+1.3757 0.4033 0.3196 2
+-1.3757 0.4033 -0.3196 2
+1.2243 -1.6534 0.1956 1
+0.8147 -0.7635 -1.2905 0
+-1.2243 -1.6534 -0.1956 1
+-0.8147 -0.7635 1.2905 0
+3.2732 1.22 0.2858 0
+3.2041 -0.5585 0.3057 0
+2.7946 0.3315 -1.1804 1
+-3.2732 1.22 -0.2858 0
+-3.2041 -0.5585 -0.3057 0
+-2.7946 0.3315 1.1804 1
+
+7 8 9
+4 8 9
+3 4 8
+3 4 5
+2 4 5
+2 5 11
+2 10 11
+2 4 9
+1 2 9
+1 7 9
+3 5 6
+5 6 11
+6 11 12
+1 3 6
+1 3 8
+1 7 8
+1 6 12
+1 2 12
+2 10 12
+10 11 12
Index: tests/Tesselations/1_2-dimethoxyethane/3/NonConvexEnvelope-1_2-dimethoxyethane.dat
===================================================================
--- tests/Tesselations/1_2-dimethoxyethane/3/NonConvexEnvelope-1_2-dimethoxyethane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/1_2-dimethoxyethane/3/NonConvexEnvelope-1_2-dimethoxyethane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,36 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="1_2-dimethoxyethane", N=12, E=20, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+1.3757 0.4033 0.3196 2
+-1.3757 0.4033 -0.3196 2
+1.2243 -1.6534 0.1956 1
+0.8147 -0.7635 -1.2905 1
+-1.2243 -1.6534 -0.1956 1
+-0.8147 -0.7635 1.2905 1
+3.2732 1.22 0.2858 0
+3.2041 -0.5585 0.3057 0
+2.7946 0.3315 -1.1804 0
+-3.2732 1.22 -0.2858 0
+-3.2041 -0.5585 -0.3057 0
+-2.7946 0.3315 1.1804 0
+
+7 8 9
+4 8 9
+3 4 8
+3 4 5
+2 4 5
+2 5 11
+2 10 11
+3 5 6
+5 6 11
+6 11 12
+1 3 6
+1 3 8
+1 7 8
+10 11 12
+1 2 4
+1 4 9
+1 7 9
+1 2 6
+2 6 12
+2 10 12
Index: tests/Tesselations/1_2-dimethoxyethane/4/NonConvexEnvelope-1_2-dimethoxyethane.dat
===================================================================
--- tests/Tesselations/1_2-dimethoxyethane/4/NonConvexEnvelope-1_2-dimethoxyethane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/1_2-dimethoxyethane/4/NonConvexEnvelope-1_2-dimethoxyethane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,36 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="1_2-dimethoxyethane", N=12, E=20, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+1.3757 0.4033 0.3196 2
+-1.3757 0.4033 -0.3196 2
+1.2243 -1.6534 0.1956 0
+0.8147 -0.7635 -1.2905 0
+-1.2243 -1.6534 -0.1956 0
+-0.8147 -0.7635 1.2905 0
+3.2732 1.22 0.2858 0
+3.2041 -0.5585 0.3057 1
+2.7946 0.3315 -1.1804 1
+-3.2732 1.22 -0.2858 0
+-3.2041 -0.5585 -0.3057 1
+-2.7946 0.3315 1.1804 1
+
+7 8 9
+4 8 9
+3 4 8
+3 4 5
+4 5 11
+2 4 11
+2 10 11
+2 4 9
+1 2 9
+1 7 9
+1 2 12
+2 10 12
+1 6 12
+1 6 8
+3 6 8
+1 7 8
+3 5 6
+5 6 11
+6 11 12
+10 11 12
Index: tests/Tesselations/1_2-dimethylbenzene.test
===================================================================
--- tests/Tesselations/1_2-dimethylbenzene.test	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/1_2-dimethylbenzene.test	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,10 @@
+#! /bin/sh
+
+# Test a simple simulation: 
+
+. ./defs || exit 1
+set -e
+
+for radius in 1.5 2 2.5 3 3.5 4 25; do
+  Tesselation_run 0 $radius
+done
Index: tests/Tesselations/1_2-dimethylbenzene/1.5/NonConvexEnvelope-1_2-dimethylbenzene.dat
===================================================================
--- tests/Tesselations/1_2-dimethylbenzene/1.5/NonConvexEnvelope-1_2-dimethylbenzene.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/1_2-dimethylbenzene/1.5/NonConvexEnvelope-1_2-dimethylbenzene.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,74 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="1_2-dimethylbenzene", N=18, E=52, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+1.8161 -1.4446 0.0014 9
+0.511 -0.6911 0.0019 7
+0.511 0.6911 0.0003 8
+-0.6863 -1.3823 -0.0018 3
+1.8161 1.4446 -0.002 9
+-0.6863 1.3824 0.0003 5
+-1.8832 -0.6913 -0.0014 5
+-1.8832 0.6913 0.0023 5
+2.1318 -1.625 1.029 2
+1.6853 -2.3976 -0.5112 3
+2.5753 -0.8561 -0.5138 3
+-0.6863 -2.4623 -0.0054 4
+2.1297 1.625 -1.0302 2
+1.6864 2.3976 0.5109 4
+2.5763 0.8561 0.5118 4
+-0.6863 2.4624 -0.001 2
+-2.8186 -1.2313 -0.0047 2
+-2.8186 1.2313 0.0027 1
+
+11 13 15
+5 13 15
+5 14 15
+5 14 15
+5 13 14
+5 13 14
+5 14 16
+3 5 16
+3 5 13
+3 6 16
+3 5 15
+3 5 14
+2 3 15
+2 9 15
+3 6 14
+6 14 16
+6 16 18
+6 8 18
+6 8 16
+8 16 18
+8 17 18
+7 8 17
+7 12 17
+7 12 17
+4 7 12
+4 7 12
+4 10 12
+2 4 10
+1 2 10
+1 10 11
+1 10 11
+1 9 11
+1 9 10
+1 9 10
+1 10 12
+1 2 12
+1 2 9
+2 4 12
+1 2 11
+2 3 11
+3 11 13
+9 11 15
+7 17 18
+7 8 18
+2 3 4
+3 4 6
+4 6 7
+6 7 8
+3 6 8
+2 3 8
+2 7 8
+2 4 7
Index: tests/Tesselations/1_2-dimethylbenzene/1_2-dimethylbenzene.xyz
===================================================================
--- tests/Tesselations/1_2-dimethylbenzene/1_2-dimethylbenzene.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/1_2-dimethylbenzene/1_2-dimethylbenzene.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,20 @@
+18
+NCI NSC 60920 3, 4-Xylene
+C    1.8161   -1.4446    0.0014
+C    0.5110   -0.6911    0.0019
+C    0.5110    0.6911    0.0003
+C   -0.6863   -1.3823   -0.0018
+C    1.8161    1.4446   -0.0020
+C   -0.6863    1.3824    0.0003
+C   -1.8832   -0.6913   -0.0014
+C   -1.8832    0.6913    0.0023
+H    2.1318   -1.6250    1.0290
+H    1.6853   -2.3976   -0.5112
+H    2.5753   -0.8561   -0.5138
+H   -0.6863   -2.4623   -0.0054
+H    2.1297    1.6250   -1.0302
+H    1.6864    2.3976    0.5109
+H    2.5763    0.8561    0.5118
+H   -0.6863    2.4624   -0.0010
+H   -2.8186   -1.2313   -0.0047
+H   -2.8186    1.2313    0.0027
Index: tests/Tesselations/1_2-dimethylbenzene/2.5/NonConvexEnvelope-1_2-dimethylbenzene.dat
===================================================================
--- tests/Tesselations/1_2-dimethylbenzene/2.5/NonConvexEnvelope-1_2-dimethylbenzene.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/1_2-dimethylbenzene/2.5/NonConvexEnvelope-1_2-dimethylbenzene.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,60 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="1_2-dimethylbenzene", N=16, E=40, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0.511 -0.6911 0.0019 7
+0.511 0.6911 0.0003 7
+-0.6863 -1.3823 -0.0018 5
+-0.6863 1.3824 0.0003 6
+-1.8832 -0.6913 -0.0014 5
+-1.8832 0.6913 0.0023 5
+2.1318 -1.625 1.029 1
+1.6853 -2.3976 -0.5112 1
+2.5753 -0.8561 -0.5138 1
+-0.6863 -2.4623 -0.0054 4
+2.1297 1.625 -1.0302 1
+1.6864 2.3976 0.5109 1
+2.5763 0.8561 0.5118 1
+-0.6863 2.4624 -0.001 2
+-2.8186 -1.2313 -0.0047 2
+-2.8186 1.2313 0.0027 1
+
+9 11 13
+11 12 13
+7 9 13
+7 8 9
+11 12 14
+4 11 14
+2 4 11
+2 3 4
+3 4 5
+4 5 6
+1 2 3
+1 2 11
+1 9 11
+1 8 9
+1 3 8
+3 8 10
+4 6 14
+6 14 16
+3 5 10
+3 5 10
+5 10 15
+5 10 15
+3 7 10
+1 3 7
+1 3 5
+1 5 6
+1 2 6
+2 4 6
+1 2 7
+2 7 13
+2 12 13
+2 4 12
+4 12 14
+4 14 16
+4 6 16
+6 15 16
+5 6 15
+5 15 16
+5 6 16
+7 8 10
Index: tests/Tesselations/1_2-dimethylbenzene/2/NonConvexEnvelope-1_2-dimethylbenzene.dat
===================================================================
--- tests/Tesselations/1_2-dimethylbenzene/2/NonConvexEnvelope-1_2-dimethylbenzene.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/1_2-dimethylbenzene/2/NonConvexEnvelope-1_2-dimethylbenzene.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,60 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="1_2-dimethylbenzene", N=16, E=40, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0.511 -0.6911 0.0019 7
+0.511 0.6911 0.0003 7
+-0.6863 -1.3823 -0.0018 5
+-0.6863 1.3824 0.0003 6
+-1.8832 -0.6913 -0.0014 5
+-1.8832 0.6913 0.0023 5
+2.1318 -1.625 1.029 1
+1.6853 -2.3976 -0.5112 1
+2.5753 -0.8561 -0.5138 1
+-0.6863 -2.4623 -0.0054 4
+2.1297 1.625 -1.0302 1
+1.6864 2.3976 0.5109 1
+2.5763 0.8561 0.5118 1
+-0.6863 2.4624 -0.001 2
+-2.8186 -1.2313 -0.0047 2
+-2.8186 1.2313 0.0027 1
+
+9 11 13
+11 12 13
+7 9 13
+7 8 9
+11 12 14
+4 11 14
+2 4 11
+2 3 4
+3 4 5
+4 5 6
+1 2 3
+1 2 11
+1 9 11
+1 8 9
+1 3 8
+3 8 10
+3 5 10
+3 5 10
+5 10 15
+5 10 15
+4 6 14
+6 14 16
+3 7 10
+1 3 7
+1 3 5
+1 5 6
+1 2 6
+2 4 6
+1 2 7
+2 7 13
+2 12 13
+2 4 12
+4 12 14
+4 14 16
+4 6 16
+7 8 10
+6 15 16
+5 6 15
+5 15 16
+5 6 16
Index: tests/Tesselations/1_2-dimethylbenzene/25/NonConvexEnvelope-1_2-dimethylbenzene.dat
===================================================================
--- tests/Tesselations/1_2-dimethylbenzene/25/NonConvexEnvelope-1_2-dimethylbenzene.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/1_2-dimethylbenzene/25/NonConvexEnvelope-1_2-dimethylbenzene.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="1_2-dimethylbenzene", N=10, E=16, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+2.1318 -1.625 1.029 0
+1.6853 -2.3976 -0.5112 0
+2.5753 -0.8561 -0.5138 0
+-0.6863 -2.4623 -0.0054 0
+2.1297 1.625 -1.0302 0
+1.6864 2.3976 0.5109 0
+2.5763 0.8561 0.5118 0
+-0.6863 2.4624 -0.001 0
+-2.8186 -1.2313 -0.0047 0
+-2.8186 1.2313 0.0027 0
+
+3 5 7
+5 6 7
+1 3 7
+1 2 3
+5 6 8
+5 8 10
+5 9 10
+2 5 9
+2 4 9
+2 3 5
+1 2 4
+1 4 9
+1 9 10
+1 6 10
+6 8 10
+1 6 7
Index: tests/Tesselations/1_2-dimethylbenzene/3.5/NonConvexEnvelope-1_2-dimethylbenzene.dat
===================================================================
--- tests/Tesselations/1_2-dimethylbenzene/3.5/NonConvexEnvelope-1_2-dimethylbenzene.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/1_2-dimethylbenzene/3.5/NonConvexEnvelope-1_2-dimethylbenzene.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,60 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="1_2-dimethylbenzene", N=16, E=40, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0.511 -0.6911 0.0019 7
+0.511 0.6911 0.0003 7
+-0.6863 -1.3823 -0.0018 5
+-0.6863 1.3824 0.0003 6
+-1.8832 -0.6913 -0.0014 5
+-1.8832 0.6913 0.0023 5
+2.1318 -1.625 1.029 1
+1.6853 -2.3976 -0.5112 1
+2.5753 -0.8561 -0.5138 1
+-0.6863 -2.4623 -0.0054 4
+2.1297 1.625 -1.0302 1
+1.6864 2.3976 0.5109 1
+2.5763 0.8561 0.5118 1
+-0.6863 2.4624 -0.001 2
+-2.8186 -1.2313 -0.0047 2
+-2.8186 1.2313 0.0027 1
+
+9 11 13
+11 12 13
+7 9 13
+7 8 9
+11 12 14
+4 11 14
+2 4 11
+2 3 4
+3 4 5
+4 5 6
+1 2 3
+1 2 11
+1 9 11
+1 8 9
+1 3 8
+3 8 10
+4 6 14
+6 14 16
+3 5 10
+3 5 10
+5 10 15
+5 10 15
+3 7 10
+1 3 7
+1 3 5
+1 5 6
+1 2 6
+2 4 6
+1 2 7
+2 7 13
+2 12 13
+2 4 12
+4 12 14
+4 14 16
+4 6 16
+6 15 16
+5 6 15
+5 15 16
+5 6 16
+7 8 10
Index: tests/Tesselations/1_2-dimethylbenzene/3/NonConvexEnvelope-1_2-dimethylbenzene.dat
===================================================================
--- tests/Tesselations/1_2-dimethylbenzene/3/NonConvexEnvelope-1_2-dimethylbenzene.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/1_2-dimethylbenzene/3/NonConvexEnvelope-1_2-dimethylbenzene.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,60 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="1_2-dimethylbenzene", N=16, E=40, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0.511 -0.6911 0.0019 7
+0.511 0.6911 0.0003 7
+-0.6863 -1.3823 -0.0018 5
+-0.6863 1.3824 0.0003 6
+-1.8832 -0.6913 -0.0014 5
+-1.8832 0.6913 0.0023 5
+2.1318 -1.625 1.029 1
+1.6853 -2.3976 -0.5112 1
+2.5753 -0.8561 -0.5138 1
+-0.6863 -2.4623 -0.0054 4
+2.1297 1.625 -1.0302 1
+1.6864 2.3976 0.5109 1
+2.5763 0.8561 0.5118 1
+-0.6863 2.4624 -0.001 2
+-2.8186 -1.2313 -0.0047 2
+-2.8186 1.2313 0.0027 1
+
+9 11 13
+11 12 13
+7 9 13
+7 8 9
+11 12 14
+4 11 14
+2 4 11
+2 3 4
+3 4 5
+4 5 6
+1 2 3
+1 2 11
+1 9 11
+1 8 9
+1 3 8
+3 8 10
+4 6 14
+6 14 16
+3 5 10
+3 5 10
+5 10 15
+5 10 15
+3 7 10
+1 3 7
+1 3 5
+1 5 6
+1 2 6
+2 4 6
+1 2 7
+2 7 13
+2 12 13
+2 4 12
+4 12 14
+4 14 16
+4 6 16
+6 15 16
+5 6 15
+5 15 16
+5 6 16
+7 8 10
Index: tests/Tesselations/1_2-dimethylbenzene/4/NonConvexEnvelope-1_2-dimethylbenzene.dat
===================================================================
--- tests/Tesselations/1_2-dimethylbenzene/4/NonConvexEnvelope-1_2-dimethylbenzene.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/1_2-dimethylbenzene/4/NonConvexEnvelope-1_2-dimethylbenzene.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,60 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="1_2-dimethylbenzene", N=16, E=40, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0.511 -0.6911 0.0019 7
+0.511 0.6911 0.0003 7
+-0.6863 -1.3823 -0.0018 5
+-0.6863 1.3824 0.0003 6
+-1.8832 -0.6913 -0.0014 5
+-1.8832 0.6913 0.0023 5
+2.1318 -1.625 1.029 1
+1.6853 -2.3976 -0.5112 1
+2.5753 -0.8561 -0.5138 1
+-0.6863 -2.4623 -0.0054 4
+2.1297 1.625 -1.0302 1
+1.6864 2.3976 0.5109 1
+2.5763 0.8561 0.5118 1
+-0.6863 2.4624 -0.001 2
+-2.8186 -1.2313 -0.0047 2
+-2.8186 1.2313 0.0027 1
+
+9 11 13
+11 12 13
+7 9 13
+7 8 9
+11 12 14
+4 11 14
+4 6 14
+6 14 16
+2 4 11
+2 3 4
+3 4 5
+4 5 6
+1 2 3
+1 2 11
+1 9 11
+1 8 9
+1 3 8
+3 8 10
+3 5 10
+3 5 10
+5 10 15
+5 10 15
+3 7 10
+1 3 7
+1 3 5
+1 5 6
+1 2 6
+2 4 6
+1 2 7
+2 7 13
+2 12 13
+2 4 12
+4 12 14
+4 14 16
+4 6 16
+6 15 16
+5 6 15
+5 15 16
+5 6 16
+7 8 10
Index: tests/Tesselations/2-methylcyclohexanone.test
===================================================================
--- tests/Tesselations/2-methylcyclohexanone.test	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/2-methylcyclohexanone.test	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,10 @@
+#! /bin/sh
+
+# Test a simple simulation: 
+
+. ./defs || exit 1
+set -e
+
+for radius in 1.5 2 2.5 3 3.5 4 25; do
+  Tesselation_run 0 $radius
+done
Index: tests/Tesselations/2-methylcyclohexanone/1.5/NonConvexEnvelope-2-methylcyclohexanone.dat
===================================================================
--- tests/Tesselations/2-methylcyclohexanone/1.5/NonConvexEnvelope-2-methylcyclohexanone.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/2-methylcyclohexanone/1.5/NonConvexEnvelope-2-methylcyclohexanone.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,90 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="2-methylcyclohexanone", N=20, E=66, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+2.1538 -0.9828 -0.0592 9
+0.7532 -0.6233 0.4408 9
+0.4585 0.8269 0.1271 13
+-0.2867 -1.4963 -0.2695 10
+1.3238 1.5584 -0.2904 3
+-0.9481 1.3372 0.3495 12
+-1.6911 -1.0384 0.1276 9
+-1.9262 0.3931 -0.3574 9
+2.8899 -0.3488 0.435 3
+2.3635 -2.028 0.168 3
+2.2058 -0.8277 -1.1369 3
+0.6964 -0.7839 1.5174 5
+-0.1649 -1.4016 -1.3485 5
+-0.1477 -2.5373 0.0223 4
+-1.1657 1.3573 1.4173 5
+-1.0433 2.3407 -0.0654 6
+-2.4294 -1.7002 -0.3251 4
+-1.7907 -1.0743 1.2124 3
+-2.9493 0.6912 -0.128 4
+-1.7656 0.443 -1.4344 5
+
+1 9 10
+1 9 10
+1 10 12
+1 9 12
+1 9 11
+1 10 11
+1 10 11
+1 11 13
+1 4 10
+1 4 13
+4 13 14
+4 13 14
+4 14 17
+4 13 17
+4 10 14
+13 17 20
+8 17 20
+8 19 20
+8 19 20
+8 17 19
+8 16 20
+8 16 19
+6 16 19
+6 15 16
+6 15 16
+6 15 19
+3 6 16
+3 6 16
+3 5 16
+3 5 16
+6 16 20
+3 6 20
+3 6 15
+3 6 15
+3 12 15
+3 12 15
+2 3 12
+2 3 12
+2 3 6
+6 15 18
+2 12 18
+2 9 12
+6 7 18
+2 7 18
+2 6 7
+2 3 9
+3 5 9
+3 5 11
+2 3 11
+2 11 13
+2 3 13
+3 4 13
+4 13 20
+4 8 20
+3 8 20
+3 4 8
+5 9 11
+10 12 14
+12 14 18
+7 14 18
+7 17 18
+7 17 18
+7 14 17
+7 17 19
+7 18 19
+15 18 19
Index: tests/Tesselations/2-methylcyclohexanone/2-methylcyclohexanone.xyz
===================================================================
--- tests/Tesselations/2-methylcyclohexanone/2-methylcyclohexanone.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/2-methylcyclohexanone/2-methylcyclohexanone.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,22 @@
+20
+NCI NSC 524 2-Metilcicloesanone (ITALIAN)
+C    2.1538   -0.9828   -0.0592
+C    0.7532   -0.6233    0.4408
+C    0.4585    0.8269    0.1271
+C   -0.2867   -1.4963   -0.2695
+O    1.3238    1.5584   -0.2904
+C   -0.9481    1.3372    0.3495
+C   -1.6911   -1.0384    0.1276
+C   -1.9262    0.3931   -0.3574
+H    2.8899   -0.3488    0.4350
+H    2.3635   -2.0280    0.1680
+H    2.2058   -0.8277   -1.1369
+H    0.6964   -0.7839    1.5174
+H   -0.1649   -1.4016   -1.3485
+H   -0.1477   -2.5373    0.0223
+H   -1.1657    1.3573    1.4173
+H   -1.0433    2.3407   -0.0654
+H   -2.4294   -1.7002   -0.3251
+H   -1.7907   -1.0743    1.2124
+H   -2.9493    0.6912   -0.1280
+H   -1.7656    0.4430   -1.4344
Index: tests/Tesselations/2-methylcyclohexanone/2.5/NonConvexEnvelope-2-methylcyclohexanone.dat
===================================================================
--- tests/Tesselations/2-methylcyclohexanone/2.5/NonConvexEnvelope-2-methylcyclohexanone.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/2-methylcyclohexanone/2.5/NonConvexEnvelope-2-methylcyclohexanone.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="2-methylcyclohexanone", N=14, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0.4585 0.8269 0.1271 3
+1.3238 1.5584 -0.2904 2
+2.8899 -0.3488 0.435 0
+2.3635 -2.028 0.168 0
+2.2058 -0.8277 -1.1369 0
+0.6964 -0.7839 1.5174 1
+-0.1649 -1.4016 -1.3485 1
+-0.1477 -2.5373 0.0223 0
+-1.1657 1.3573 1.4173 1
+-1.0433 2.3407 -0.0654 0
+-2.4294 -1.7002 -0.3251 0
+-1.7907 -1.0743 1.2124 0
+-2.9493 0.6912 -0.128 0
+-1.7656 0.443 -1.4344 0
+
+3 4 5
+2 3 5
+2 5 7
+2 7 14
+2 10 14
+10 13 14
+9 10 13
+9 12 13
+11 12 13
+6 9 12
+6 8 12
+4 6 8
+8 11 12
+3 4 6
+1 6 9
+1 2 6
+2 3 6
+1 2 9
+2 9 10
+11 13 14
+7 11 14
+7 8 11
+4 7 8
+4 5 7
Index: tests/Tesselations/2-methylcyclohexanone/2/NonConvexEnvelope-2-methylcyclohexanone.dat
===================================================================
--- tests/Tesselations/2-methylcyclohexanone/2/NonConvexEnvelope-2-methylcyclohexanone.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/2-methylcyclohexanone/2/NonConvexEnvelope-2-methylcyclohexanone.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,44 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="2-methylcyclohexanone", N=14, E=26, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0.4585 0.8269 0.1271 8
+1.3238 1.5584 -0.2904 2
+2.8899 -0.3488 0.435 1
+2.3635 -2.028 0.168 0
+2.2058 -0.8277 -1.1369 1
+0.6964 -0.7839 1.5174 1
+-0.1649 -1.4016 -1.3485 1
+-0.1477 -2.5373 0.0223 0
+-1.1657 1.3573 1.4173 1
+-1.0433 2.3407 -0.0654 0
+-2.4294 -1.7002 -0.3251 0
+-1.7907 -1.0743 1.2124 0
+-2.9493 0.6912 -0.128 0
+-1.7656 0.443 -1.4344 1
+
+3 4 5
+2 3 5
+4 5 7
+4 7 8
+7 8 11
+7 11 14
+11 13 14
+11 12 13
+9 12 13
+9 10 13
+10 13 14
+6 9 12
+1 6 9
+1 3 6
+1 2 3
+1 2 9
+2 9 10
+6 8 12
+4 6 8
+8 11 12
+3 4 6
+2 10 14
+1 2 14
+1 7 14
+1 5 7
+1 2 5
Index: tests/Tesselations/2-methylcyclohexanone/25/NonConvexEnvelope-2-methylcyclohexanone.dat
===================================================================
--- tests/Tesselations/2-methylcyclohexanone/25/NonConvexEnvelope-2-methylcyclohexanone.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/2-methylcyclohexanone/25/NonConvexEnvelope-2-methylcyclohexanone.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,39 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="2-methylcyclohexanone", N=13, E=22, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+1.3238 1.5584 -0.2904 0
+2.8899 -0.3488 0.435 0
+2.3635 -2.028 0.168 0
+2.2058 -0.8277 -1.1369 0
+0.6964 -0.7839 1.5174 0
+-0.1649 -1.4016 -1.3485 0
+-0.1477 -2.5373 0.0223 0
+-1.1657 1.3573 1.4173 0
+-1.0433 2.3407 -0.0654 0
+-2.4294 -1.7002 -0.3251 0
+-1.7907 -1.0743 1.2124 0
+-2.9493 0.6912 -0.128 0
+-1.7656 0.443 -1.4344 0
+
+2 3 4
+1 2 4
+1 4 13
+1 9 13
+4 6 13
+6 10 13
+6 7 10
+3 6 7
+3 4 6
+10 12 13
+9 12 13
+8 9 12
+8 11 12
+10 11 12
+5 8 11
+5 7 11
+3 5 7
+7 10 11
+2 3 5
+2 5 8
+1 2 8
+1 8 9
Index: tests/Tesselations/2-methylcyclohexanone/3.5/NonConvexEnvelope-2-methylcyclohexanone.dat
===================================================================
--- tests/Tesselations/2-methylcyclohexanone/3.5/NonConvexEnvelope-2-methylcyclohexanone.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/2-methylcyclohexanone/3.5/NonConvexEnvelope-2-methylcyclohexanone.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,39 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="2-methylcyclohexanone", N=13, E=22, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+1.3238 1.5584 -0.2904 1
+2.8899 -0.3488 0.435 0
+2.3635 -2.028 0.168 0
+2.2058 -0.8277 -1.1369 0
+0.6964 -0.7839 1.5174 1
+-0.1649 -1.4016 -1.3485 0
+-0.1477 -2.5373 0.0223 0
+-1.1657 1.3573 1.4173 0
+-1.0433 2.3407 -0.0654 0
+-2.4294 -1.7002 -0.3251 0
+-1.7907 -1.0743 1.2124 0
+-2.9493 0.6912 -0.128 0
+-1.7656 0.443 -1.4344 0
+
+2 3 4
+1 2 4
+1 4 13
+4 6 13
+1 9 13
+9 12 13
+8 9 12
+8 11 12
+10 11 12
+5 8 11
+5 7 11
+3 5 7
+7 10 11
+2 3 5
+1 2 5
+1 5 8
+1 8 9
+10 12 13
+6 10 13
+6 7 10
+3 6 7
+3 4 6
Index: tests/Tesselations/2-methylcyclohexanone/3/NonConvexEnvelope-2-methylcyclohexanone.dat
===================================================================
--- tests/Tesselations/2-methylcyclohexanone/3/NonConvexEnvelope-2-methylcyclohexanone.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/2-methylcyclohexanone/3/NonConvexEnvelope-2-methylcyclohexanone.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="2-methylcyclohexanone", N=14, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0.4585 0.8269 0.1271 3
+1.3238 1.5584 -0.2904 2
+2.8899 -0.3488 0.435 0
+2.3635 -2.028 0.168 0
+2.2058 -0.8277 -1.1369 0
+0.6964 -0.7839 1.5174 1
+-0.1649 -1.4016 -1.3485 1
+-0.1477 -2.5373 0.0223 0
+-1.1657 1.3573 1.4173 1
+-1.0433 2.3407 -0.0654 0
+-2.4294 -1.7002 -0.3251 0
+-1.7907 -1.0743 1.2124 0
+-2.9493 0.6912 -0.128 0
+-1.7656 0.443 -1.4344 0
+
+3 4 5
+2 3 5
+2 5 7
+2 7 14
+2 10 14
+10 13 14
+9 10 13
+9 12 13
+11 12 13
+6 9 12
+6 8 12
+4 6 8
+8 11 12
+3 4 6
+1 6 9
+1 2 6
+1 2 9
+2 3 6
+2 9 10
+11 13 14
+7 11 14
+7 8 11
+4 7 8
+4 5 7
Index: tests/Tesselations/2-methylcyclohexanone/4/NonConvexEnvelope-2-methylcyclohexanone.dat
===================================================================
--- tests/Tesselations/2-methylcyclohexanone/4/NonConvexEnvelope-2-methylcyclohexanone.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/2-methylcyclohexanone/4/NonConvexEnvelope-2-methylcyclohexanone.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,39 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="2-methylcyclohexanone", N=13, E=22, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+1.3238 1.5584 -0.2904 1
+2.8899 -0.3488 0.435 0
+2.3635 -2.028 0.168 0
+2.2058 -0.8277 -1.1369 0
+0.6964 -0.7839 1.5174 1
+-0.1649 -1.4016 -1.3485 0
+-0.1477 -2.5373 0.0223 0
+-1.1657 1.3573 1.4173 0
+-1.0433 2.3407 -0.0654 0
+-2.4294 -1.7002 -0.3251 0
+-1.7907 -1.0743 1.2124 0
+-2.9493 0.6912 -0.128 0
+-1.7656 0.443 -1.4344 0
+
+2 3 4
+1 2 4
+1 4 13
+4 6 13
+1 9 13
+9 12 13
+8 9 12
+8 11 12
+10 11 12
+5 8 11
+5 7 11
+3 5 7
+7 10 11
+2 3 5
+1 2 5
+1 5 8
+1 8 9
+10 12 13
+6 10 13
+6 7 10
+3 6 7
+3 4 6
Index: tests/Tesselations/Makefile.am
===================================================================
--- tests/Tesselations/Makefile.am	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/Makefile.am	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,15 @@
+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
Index: tests/Tesselations/N_N-dimethylacetamide.test
===================================================================
--- tests/Tesselations/N_N-dimethylacetamide.test	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/N_N-dimethylacetamide.test	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,10 @@
+#! /bin/sh
+
+# Test a simple simulation: 
+
+. ./defs || exit 1
+set -e
+
+for radius in 1.5 2 2.5 3 3.5 4 25; do
+  Tesselation_run 0 $radius
+done
Index: tests/Tesselations/N_N-dimethylacetamide/1.5/NonConvexEnvelope-N_N-dimethylacetamide.dat
===================================================================
--- tests/Tesselations/N_N-dimethylacetamide/1.5/NonConvexEnvelope-N_N-dimethylacetamide.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/N_N-dimethylacetamide/1.5/NonConvexEnvelope-N_N-dimethylacetamide.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,63 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="N_N-dimethylacetamide", N=15, E=44, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0 0 0 9
+0.24 0.96 1.1 10
+0 0.58 2.38 7
+-0.5 -0.82 2.64 9
+0.76 2.3 0.78 12
+0.16 1.34 3.3 3
+0.6164 -0.8635 0.1393 3
+-1.0292 -0.2927 0.0002 3
+0.2393 0.4619 -0.9351 6
+-0.6555 -0.9539 3.6902 5
+0.2242 -1.5274 2.2936 2
+-1.4232 -0.9712 2.1206 2
+0.4218 2.999 1.5162 3
+0.4063 2.5988 -0.1847 4
+1.8297 2.2759 0.7759 4
+
+5 13 15
+5 13 15
+5 14 15
+5 14 15
+5 9 14
+5 13 14
+5 13 14
+5 6 13
+2 5 6
+2 3 6
+2 5 15
+2 5 15
+2 5 9
+2 5 14
+2 5 13
+1 2 9
+1 2 9
+2 9 14
+1 7 9
+1 7 9
+1 7 8
+1 8 9
+1 8 9
+1 2 7
+1 2 8
+2 3 13
+3 6 13
+2 3 8
+3 8 12
+3 4 12
+4 10 12
+4 10 12
+4 10 11
+4 10 11
+4 11 12
+3 4 11
+3 4 10
+3 4 10
+3 6 10
+3 6 10
+2 3 7
+3 7 11
+7 8 12
+7 11 12
Index: tests/Tesselations/N_N-dimethylacetamide/2.5/NonConvexEnvelope-N_N-dimethylacetamide.dat
===================================================================
--- tests/Tesselations/N_N-dimethylacetamide/2.5/NonConvexEnvelope-N_N-dimethylacetamide.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/N_N-dimethylacetamide/2.5/NonConvexEnvelope-N_N-dimethylacetamide.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,40 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="N_N-dimethylacetamide", N=12, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0.24 0.96 1.1 7
+0 0.58 2.38 7
+0.16 1.34 3.3 2
+0.6164 -0.8635 0.1393 2
+-1.0292 -0.2927 0.0002 1
+0.2393 0.4619 -0.9351 0
+-0.6555 -0.9539 3.6902 0
+0.2242 -1.5274 2.2936 1
+-1.4232 -0.9712 2.1206 1
+0.4218 2.999 1.5162 1
+0.4063 2.5988 -0.1847 1
+1.8297 2.2759 0.7759 1
+
+4 6 12
+6 11 12
+1 4 12
+1 2 4
+2 4 8
+1 2 12
+2 3 12
+2 3 8
+3 7 8
+3 10 12
+10 11 12
+4 5 6
+4 5 9
+4 8 9
+7 8 9
+5 6 11
+1 5 11
+1 10 11
+1 2 10
+2 3 10
+1 2 5
+2 5 9
+2 3 9
+3 7 9
Index: tests/Tesselations/N_N-dimethylacetamide/2/NonConvexEnvelope-N_N-dimethylacetamide.dat
===================================================================
--- tests/Tesselations/N_N-dimethylacetamide/2/NonConvexEnvelope-N_N-dimethylacetamide.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/N_N-dimethylacetamide/2/NonConvexEnvelope-N_N-dimethylacetamide.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,40 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="N_N-dimethylacetamide", N=12, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0.24 0.96 1.1 7
+0 0.58 2.38 7
+0.16 1.34 3.3 3
+0.6164 -0.8635 0.1393 2
+-1.0292 -0.2927 0.0002 1
+0.2393 0.4619 -0.9351 0
+-0.6555 -0.9539 3.6902 3
+0.2242 -1.5274 2.2936 0
+-1.4232 -0.9712 2.1206 0
+0.4218 2.999 1.5162 1
+0.4063 2.5988 -0.1847 1
+1.8297 2.2759 0.7759 1
+
+3 10 12
+2 3 12
+1 2 12
+1 2 4
+2 4 8
+1 4 12
+4 6 12
+2 3 7
+2 3 7
+2 7 8
+2 7 9
+2 3 10
+1 2 10
+1 10 11
+1 5 11
+5 6 11
+1 2 5
+2 5 9
+6 11 12
+10 11 12
+4 5 6
+4 5 9
+4 8 9
+7 8 9
Index: tests/Tesselations/N_N-dimethylacetamide/25/NonConvexEnvelope-N_N-dimethylacetamide.dat
===================================================================
--- tests/Tesselations/N_N-dimethylacetamide/25/NonConvexEnvelope-N_N-dimethylacetamide.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/N_N-dimethylacetamide/25/NonConvexEnvelope-N_N-dimethylacetamide.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="N_N-dimethylacetamide", N=10, E=16, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0.16 1.34 3.3 0
+0.6164 -0.8635 0.1393 0
+-1.0292 -0.2927 0.0002 0
+0.2393 0.4619 -0.9351 0
+-0.6555 -0.9539 3.6902 0
+0.2242 -1.5274 2.2936 0
+-1.4232 -0.9712 2.1206 0
+0.4218 2.999 1.5162 0
+0.4063 2.5988 -0.1847 0
+1.8297 2.2759 0.7759 0
+
+2 4 10
+4 9 10
+2 6 10
+1 6 10
+1 5 6
+1 8 10
+8 9 10
+2 3 4
+2 3 7
+2 6 7
+5 6 7
+3 4 9
+3 8 9
+3 7 8
+1 7 8
+1 5 7
Index: tests/Tesselations/N_N-dimethylacetamide/3.5/NonConvexEnvelope-N_N-dimethylacetamide.dat
===================================================================
--- tests/Tesselations/N_N-dimethylacetamide/3.5/NonConvexEnvelope-N_N-dimethylacetamide.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/N_N-dimethylacetamide/3.5/NonConvexEnvelope-N_N-dimethylacetamide.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,38 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="N_N-dimethylacetamide", N=12, E=22, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0.24 0.96 1.1 3
+0 0.58 2.38 6
+0.16 1.34 3.3 2
+0.6164 -0.8635 0.1393 0
+-1.0292 -0.2927 0.0002 1
+0.2393 0.4619 -0.9351 0
+-0.6555 -0.9539 3.6902 0
+0.2242 -1.5274 2.2936 1
+-1.4232 -0.9712 2.1206 1
+0.4218 2.999 1.5162 1
+0.4063 2.5988 -0.1847 0
+1.8297 2.2759 0.7759 1
+
+4 6 12
+6 11 12
+4 8 12
+2 8 12
+2 3 12
+2 3 8
+3 7 8
+3 10 12
+10 11 12
+4 5 6
+4 5 9
+4 8 9
+7 8 9
+5 6 11
+5 10 11
+1 5 10
+1 2 10
+1 2 5
+2 5 9
+2 3 10
+2 3 9
+3 7 9
Index: tests/Tesselations/N_N-dimethylacetamide/3/NonConvexEnvelope-N_N-dimethylacetamide.dat
===================================================================
--- tests/Tesselations/N_N-dimethylacetamide/3/NonConvexEnvelope-N_N-dimethylacetamide.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/N_N-dimethylacetamide/3/NonConvexEnvelope-N_N-dimethylacetamide.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,38 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="N_N-dimethylacetamide", N=12, E=22, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0.24 0.96 1.1 4
+0 0.58 2.38 6
+0.16 1.34 3.3 2
+0.6164 -0.8635 0.1393 0
+-1.0292 -0.2927 0.0002 1
+0.2393 0.4619 -0.9351 0
+-0.6555 -0.9539 3.6902 0
+0.2242 -1.5274 2.2936 1
+-1.4232 -0.9712 2.1206 1
+0.4218 2.999 1.5162 1
+0.4063 2.5988 -0.1847 1
+1.8297 2.2759 0.7759 1
+
+4 6 12
+6 11 12
+4 8 12
+2 8 12
+2 3 12
+2 3 8
+3 7 8
+3 10 12
+10 11 12
+4 5 6
+4 5 9
+4 8 9
+7 8 9
+5 6 11
+1 5 11
+1 10 11
+1 2 10
+1 2 5
+2 5 9
+2 3 10
+2 3 9
+3 7 9
Index: tests/Tesselations/N_N-dimethylacetamide/4/NonConvexEnvelope-N_N-dimethylacetamide.dat
===================================================================
--- tests/Tesselations/N_N-dimethylacetamide/4/NonConvexEnvelope-N_N-dimethylacetamide.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/N_N-dimethylacetamide/4/NonConvexEnvelope-N_N-dimethylacetamide.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,33 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="N_N-dimethylacetamide", N=11, E=18, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0 0.58 2.38 3
+0.16 1.34 3.3 1
+0.6164 -0.8635 0.1393 0
+-1.0292 -0.2927 0.0002 0
+0.2393 0.4619 -0.9351 0
+-0.6555 -0.9539 3.6902 0
+0.2242 -1.5274 2.2936 0
+-1.4232 -0.9712 2.1206 1
+0.4218 2.999 1.5162 1
+0.4063 2.5988 -0.1847 0
+1.8297 2.2759 0.7759 0
+
+3 5 11
+5 10 11
+3 7 11
+2 7 11
+2 6 7
+2 9 11
+9 10 11
+3 4 5
+3 4 8
+3 7 8
+6 7 8
+4 5 10
+4 9 10
+4 8 9
+1 8 9
+1 2 9
+1 2 8
+2 6 8
Index: tests/Tesselations/N_N-dimethylacetamide/N_N-dimethylacetamide.xyz
===================================================================
--- tests/Tesselations/N_N-dimethylacetamide/N_N-dimethylacetamide.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/N_N-dimethylacetamide/N_N-dimethylacetamide.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,17 @@
+15
+NCI NSC 3138 NSC3138 N,N-dimethylacetamide
+C    0.0000    0.0000    0.0000
+N    0.2400    0.9600    1.1000
+C    0.0000    0.5800    2.3800
+C   -0.5000   -0.8200    2.6400
+C    0.7600    2.3000    0.7800
+O    0.1600    1.3400    3.3000
+H    0.6164   -0.8635    0.1393
+H   -1.0292   -0.2927    0.0002
+H    0.2393    0.4619   -0.9351
+H   -0.6555   -0.9539    3.6902
+H    0.2242   -1.5274    2.2936
+H   -1.4232   -0.9712    2.1206
+H    0.4218    2.9990    1.5162
+H    0.4063    2.5988   -0.1847
+H    1.8297    2.2759    0.7759
Index: tests/Tesselations/benzene.test
===================================================================
--- tests/Tesselations/benzene.test	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/benzene.test	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,10 @@
+#! /bin/sh
+
+# Test a simple simulation: 
+
+. ./defs || exit 1
+set -e
+
+for radius in 1.5 2 2.5 3 3.5 4 25; do
+  Tesselation_run 0 $radius
+done
Index: tests/Tesselations/benzene/1.5/NonConvexEnvelope-benzene.dat
===================================================================
--- tests/Tesselations/benzene/1.5/NonConvexEnvelope-benzene.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/benzene/1.5/NonConvexEnvelope-benzene.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,48 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="benzene", N=12, E=32, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+-1.6271 0 -0.0007 2
+-0.5471 0.0001 -0.0015 7
+0.1541 1.2073 0.0011 4
+0.1544 -1.2075 0.001 4
+1.5338 1.2 0.0007 4
+1.5336 -1.2001 0.0007 5
+2.2223 0.0002 -0.0021 4
+-0.3822 2.1448 0.0029 3
+-0.3819 -2.1449 0.0036 3
+2.0775 2.1332 0.0024 4
+2.0774 -2.1333 0.0026 3
+3.3023 0.0002 -0.0027 5
+
+5 10 12
+5 10 12
+5 7 12
+5 7 12
+6 7 12
+6 7 12
+6 11 12
+6 11 12
+3 5 10
+3 5 10
+3 8 10
+3 8 10
+4 6 11
+4 6 11
+4 9 11
+4 9 11
+2 3 8
+2 3 8
+1 2 8
+1 2 8
+2 4 9
+2 4 9
+1 2 9
+1 2 9
+2 5 7
+2 3 5
+2 6 7
+2 6 7
+2 4 6
+2 4 6
+2 3 7
+3 5 7
Index: tests/Tesselations/benzene/2.5/NonConvexEnvelope-benzene.dat
===================================================================
--- tests/Tesselations/benzene/2.5/NonConvexEnvelope-benzene.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/benzene/2.5/NonConvexEnvelope-benzene.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,48 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="benzene", N=12, E=32, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+-1.6271 0 -0.0007 2
+-0.5471 0.0001 -0.0015 6
+0.1541 1.2073 0.0011 7
+0.1544 -1.2075 0.001 5
+1.5338 1.2 0.0007 6
+1.5336 -1.2001 0.0007 7
+2.2223 0.0002 -0.0021 5
+-0.3822 2.1448 0.0029 3
+-0.3819 -2.1449 0.0036 3
+2.0775 2.1332 0.0024 4
+2.0774 -2.1333 0.0026 3
+3.3023 0.0002 -0.0027 5
+
+5 10 12
+5 10 12
+5 7 12
+5 7 12
+6 7 12
+6 7 12
+6 11 12
+6 11 12
+3 5 10
+3 5 10
+3 8 10
+3 8 10
+4 6 11
+4 6 11
+4 9 11
+4 9 11
+2 3 8
+1 2 8
+2 4 9
+2 4 9
+1 2 9
+1 2 9
+1 3 8
+1 2 3
+5 6 7
+3 5 6
+3 4 6
+2 3 4
+2 6 7
+2 4 6
+2 5 7
+2 3 5
Index: tests/Tesselations/benzene/2/NonConvexEnvelope-benzene.dat
===================================================================
--- tests/Tesselations/benzene/2/NonConvexEnvelope-benzene.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/benzene/2/NonConvexEnvelope-benzene.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,48 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="benzene", N=12, E=32, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+-1.6271 0 -0.0007 2
+-0.5471 0.0001 -0.0015 6
+0.1541 1.2073 0.0011 7
+0.1544 -1.2075 0.001 5
+1.5338 1.2 0.0007 6
+1.5336 -1.2001 0.0007 7
+2.2223 0.0002 -0.0021 5
+-0.3822 2.1448 0.0029 3
+-0.3819 -2.1449 0.0036 3
+2.0775 2.1332 0.0024 4
+2.0774 -2.1333 0.0026 3
+3.3023 0.0002 -0.0027 5
+
+5 10 12
+5 10 12
+5 7 12
+5 7 12
+6 7 12
+6 7 12
+6 11 12
+6 11 12
+3 5 10
+3 5 10
+3 8 10
+3 8 10
+4 6 11
+4 6 11
+4 9 11
+4 9 11
+2 3 8
+1 2 8
+2 4 9
+2 4 9
+1 2 9
+1 2 9
+1 3 8
+1 2 3
+2 5 7
+2 3 5
+2 6 7
+2 4 6
+5 6 7
+3 5 6
+3 4 6
+2 3 4
Index: tests/Tesselations/benzene/25/NonConvexEnvelope-benzene.dat
===================================================================
--- tests/Tesselations/benzene/25/NonConvexEnvelope-benzene.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/benzene/25/NonConvexEnvelope-benzene.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,48 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="benzene", N=12, E=32, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+-1.6271 0 -0.0007 1
+-0.5471 0.0001 -0.0015 4
+0.1541 1.2073 0.0011 6
+0.1544 -1.2075 0.001 4
+1.5338 1.2 0.0007 5
+1.5336 -1.2001 0.0007 6
+2.2223 0.0002 -0.0021 5
+-0.3822 2.1448 0.0029 2
+-0.3819 -2.1449 0.0036 1
+2.0775 2.1332 0.0024 1
+2.0774 -2.1333 0.0026 2
+3.3023 0.0002 -0.0027 1
+
+6 11 12
+6 7 12
+4 6 7
+2 4 7
+2 5 7
+2 3 5
+4 6 11
+4 9 11
+5 7 12
+5 10 12
+5 8 10
+3 5 8
+2 3 8
+1 2 8
+2 4 9
+1 2 9
+1 3 8
+1 2 3
+2 3 4
+3 4 6
+3 5 6
+5 6 7
+1 2 4
+1 4 9
+6 7 11
+7 11 12
+7 10 12
+5 7 10
+4 6 9
+6 9 11
+3 5 10
+3 8 10
Index: tests/Tesselations/benzene/3.5/NonConvexEnvelope-benzene.dat
===================================================================
--- tests/Tesselations/benzene/3.5/NonConvexEnvelope-benzene.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/benzene/3.5/NonConvexEnvelope-benzene.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,48 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="benzene", N=12, E=32, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+-1.6271 0 -0.0007 2
+-0.5471 0.0001 -0.0015 6
+0.1541 1.2073 0.0011 7
+0.1544 -1.2075 0.001 5
+1.5338 1.2 0.0007 6
+1.5336 -1.2001 0.0007 7
+2.2223 0.0002 -0.0021 5
+-0.3822 2.1448 0.0029 3
+-0.3819 -2.1449 0.0036 3
+2.0775 2.1332 0.0024 4
+2.0774 -2.1333 0.0026 3
+3.3023 0.0002 -0.0027 5
+
+5 10 12
+5 10 12
+5 7 12
+5 7 12
+6 7 12
+6 7 12
+6 11 12
+6 11 12
+3 5 10
+3 5 10
+3 8 10
+3 8 10
+4 6 11
+4 6 11
+4 9 11
+4 9 11
+2 3 8
+1 2 8
+2 4 9
+2 4 9
+1 2 9
+1 2 9
+1 2 3
+1 3 8
+5 6 7
+3 5 6
+3 4 6
+2 3 4
+2 6 7
+2 4 6
+2 5 7
+2 3 5
Index: tests/Tesselations/benzene/3/NonConvexEnvelope-benzene.dat
===================================================================
--- tests/Tesselations/benzene/3/NonConvexEnvelope-benzene.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/benzene/3/NonConvexEnvelope-benzene.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,48 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="benzene", N=12, E=32, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+-1.6271 0 -0.0007 2
+-0.5471 0.0001 -0.0015 6
+0.1541 1.2073 0.0011 7
+0.1544 -1.2075 0.001 5
+1.5338 1.2 0.0007 6
+1.5336 -1.2001 0.0007 7
+2.2223 0.0002 -0.0021 5
+-0.3822 2.1448 0.0029 3
+-0.3819 -2.1449 0.0036 3
+2.0775 2.1332 0.0024 4
+2.0774 -2.1333 0.0026 3
+3.3023 0.0002 -0.0027 5
+
+5 10 12
+5 10 12
+5 7 12
+5 7 12
+6 7 12
+6 7 12
+6 11 12
+6 11 12
+3 5 10
+3 5 10
+3 8 10
+3 8 10
+4 6 11
+4 6 11
+4 9 11
+4 9 11
+2 3 8
+1 2 8
+2 4 9
+2 4 9
+1 2 9
+1 2 9
+1 2 3
+1 3 8
+5 6 7
+3 5 6
+3 4 6
+2 3 4
+2 6 7
+2 4 6
+2 5 7
+2 3 5
Index: tests/Tesselations/benzene/4/NonConvexEnvelope-benzene.dat
===================================================================
--- tests/Tesselations/benzene/4/NonConvexEnvelope-benzene.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/benzene/4/NonConvexEnvelope-benzene.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,48 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="benzene", N=12, E=32, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+-1.6271 0 -0.0007 2
+-0.5471 0.0001 -0.0015 6
+0.1541 1.2073 0.0011 7
+0.1544 -1.2075 0.001 5
+1.5338 1.2 0.0007 6
+1.5336 -1.2001 0.0007 7
+2.2223 0.0002 -0.0021 5
+-0.3822 2.1448 0.0029 3
+-0.3819 -2.1449 0.0036 3
+2.0775 2.1332 0.0024 4
+2.0774 -2.1333 0.0026 2
+3.3023 0.0002 -0.0027 4
+
+6 11 12
+6 11 12
+6 7 12
+6 7 12
+5 7 12
+5 7 12
+5 10 12
+5 10 12
+3 5 10
+3 5 10
+3 8 10
+3 8 10
+4 6 11
+4 6 11
+4 9 11
+4 9 11
+5 6 7
+3 5 6
+3 4 6
+2 3 4
+2 3 8
+1 2 8
+2 4 9
+2 4 9
+1 2 9
+1 2 9
+1 2 3
+1 3 8
+2 6 7
+2 4 6
+2 5 7
+2 3 5
Index: tests/Tesselations/benzene/benzene.xyz
===================================================================
--- tests/Tesselations/benzene/benzene.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/benzene/benzene.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,14 @@
+12
+Benzene molecule
+H   -1.6271    0.0000   -0.0007
+C   -0.5471    0.0001   -0.0015
+C    0.1541    1.2073    0.0011
+C    0.1544   -1.2075    0.0010
+C    1.5338    1.2000    0.0007
+C    1.5336   -1.2001    0.0007
+C    2.2223    0.0002   -0.0021
+H   -0.3822    2.1448    0.0029
+H   -0.3819   -2.1449    0.0036
+H    2.0775    2.1332    0.0024
+H    2.0774   -2.1333    0.0026
+H    3.3023    0.0002   -0.0027
Index: tests/Tesselations/cholesterol.test
===================================================================
--- tests/Tesselations/cholesterol.test	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/cholesterol.test	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,10 @@
+#! /bin/sh
+
+# Test a simple simulation: 
+
+. ./defs || exit 1
+set -e
+
+for radius in 1.5 2 2.5 3 3.5 4 25; do
+  Tesselation_run 0 $radius
+done
Index: tests/Tesselations/cholesterol/1.5/NonConvexEnvelope-cholesterol.dat
===================================================================
--- tests/Tesselations/cholesterol/1.5/NonConvexEnvelope-cholesterol.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/cholesterol/1.5/NonConvexEnvelope-cholesterol.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,298 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="cholesterol", N=74, E=220, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0.5233 -2.9918 0.4529 3
+-0.5691 -1.9223 0.3925 3
+-0.3504 -1.0089 -0.8425 7
+-1.9207 -2.5721 0.1108 9
+-0.4881 -1.0286 1.6162 6
+1.1055 -0.5783 -0.8354 9
+-0.7624 -1.9351 -1.9917 9
+-3.0507 -1.716 0.6863 3
+-2.03 -2.6378 -1.4329 9
+0.9499 -0.4944 1.6888 3
+1.3301 0.2716 0.4281 6
+1.3697 0.3126 -2.0561 12
+-3.0696 -0.3571 -0.0164 3
+-4.3894 -2.4231 0.4654 9
+2.8009 0.66 0.5172 7
+2.7188 0.956 -1.9356 7
+-4.2243 0.4842 0.5311 6
+2.931 1.8358 1.4876 9
+3.3535 1.0837 -0.8167 13
+3.6417 -0.4977 1.0504 7
+-4.2432 1.8431 -0.1716 11
+4.7486 1.6873 -0.8101 3
+5.0694 -0.398 0.5148 9
+-5.3979 2.6844 0.3759 3
+5.5016 1.0566 0.3701 6
+-5.4168 4.0434 -0.3268 12
+-6.7216 1.9604 0.1218 12
+6.9077 1.1106 0.1214 3
+0.3612 -3.628 1.323 2
+0.4884 -3.5983 -0.4521 3
+1.4985 -2.5112 0.5308 3
+-1.0035 -0.1376 -0.792 7
+-1.9534 -3.5752 0.5362 3
+-1.1883 -0.199 1.5176 5
+-0.7165 -1.6046 2.5129 3
+1.7627 -1.4479 -0.8349 6
+-1.003 -1.3584 -2.8848 4
+0.0217 -2.6629 -2.2008 2
+-2.8885 -1.5706 1.7543 4
+-2.0579 -3.6765 -1.7622 4
+-2.9259 -2.1146 -1.7672 6
+1.0353 0.1785 2.542 6
+1.6325 -1.3323 1.8306 3
+0.7271 1.177 0.3594 10
+1.3374 -0.2942 -2.961 7
+0.6036 1.0859 -2.1126 4
+-2.1265 0.1587 0.1647 3
+-3.2034 -0.5041 -1.0881 5
+-5.1809 -1.8679 0.9687 5
+-4.6025 -2.4721 -0.6025 3
+-4.3385 -3.4329 0.8725 4
+3.191 1.3217 -2.8354 3
+-5.1673 -0.0316 0.3501 4
+-4.0905 0.6312 1.6028 5
+2.8131 1.4776 2.5103 3
+3.9137 2.2936 1.3739 6
+2.159 2.5738 1.2698 6
+3.6606 -0.4593 2.1396 3
+3.2007 -1.4419 0.7311 5
+-3.3002 2.3589 0.0094 3
+-4.377 1.6962 -1.2433 3
+5.2593 1.4547 -1.7445 3
+4.6863 2.7674 -0.6775 2
+5.746 -0.9031 1.204 6
+5.1212 -0.8867 -0.4582 5
+-5.2641 2.8314 1.4476 3
+5.2727 1.6068 1.2828 5
+-6.2394 4.6427 0.0632 5
+-4.4738 4.5591 -0.1458 6
+-5.5506 3.8964 -1.3985 5
+-6.7081 0.9923 0.6224 5
+-7.5442 2.5597 0.5118 5
+-6.8554 1.8134 -0.9499 4
+7.1391 2.0447 0.0264 0
+
+28 62 74
+25 28 62
+25 28 65
+25 62 65
+23 28 65
+23 64 65
+23 64 65
+23 28 64
+23 59 65
+23 59 64
+20 59 64
+20 58 59
+20 58 64
+43 58 59
+31 43 59
+29 31 43
+29 35 43
+1 29 31
+1 29 30
+1 30 31
+30 31 36
+30 36 38
+31 36 59
+62 63 74
+42 43 58
+42 55 58
+10 42 43
+10 35 43
+10 35 42
+5 35 42
+5 34 35
+5 34 42
+34 35 39
+34 39 47
+39 47 54
+47 54 60
+54 60 66
+60 66 69
+26 66 69
+26 68 69
+26 68 69
+26 66 68
+26 69 70
+26 69 70
+26 61 70
+21 26 61
+21 60 61
+21 60 61
+21 60 69
+21 26 69
+13 21 60
+13 47 60
+21 48 61
+13 21 48
+13 47 48
+26 68 70
+26 68 70
+26 68 72
+26 27 72
+27 72 73
+27 72 73
+27 70 73
+26 27 70
+27 71 73
+27 71 72
+27 71 72
+27 66 71
+27 66 72
+32 47 48
+53 71 73
+27 53 73
+21 27 73
+21 61 73
+21 53 61
+21 27 53
+32 34 47
+32 34 44
+32 34 44
+11 32 44
+11 34 44
+5 32 34
+5 11 34
+3 5 32
+3 11 32
+3 5 11
+32 44 46
+7 32 48
+7 41 48
+7 37 41
+7 32 37
+37 41 48
+37 41 48
+48 53 61
+48 50 53
+41 48 50
+49 50 53
+14 49 50
+14 49 51
+14 49 51
+14 39 49
+14 39 51
+14 50 51
+14 50 51
+4 14 51
+4 33 51
+4 14 50
+4 9 33
+9 33 40
+9 40 41
+9 40 41
+9 37 41
+9 41 50
+4 9 50
+7 9 40
+7 9 37
+7 37 38
+7 38 40
+33 39 51
+4 33 39
+4 35 39
+2 4 33
+2 4 35
+2 29 33
+2 29 35
+37 38 45
+66 68 72
+29 30 33
+4 30 33
+4 33 40
+4 9 40
+9 30 40
+4 9 30
+34 42 44
+42 44 57
+42 44 57
+18 44 57
+18 42 57
+18 42 44
+42 55 57
+18 55 57
+18 56 57
+18 56 57
+18 19 56
+18 55 56
+18 19 57
+19 56 63
+15 19 57
+15 44 57
+15 19 44
+11 19 44
+11 16 19
+11 12 44
+11 12 16
+12 16 46
+12 44 46
+19 22 63
+19 22 52
+16 19 52
+22 62 63
+22 52 62
+16 46 52
+12 46 52
+12 45 46
+12 45 46
+3 12 46
+3 12 45
+12 45 52
+3 37 45
+3 32 46
+3 32 37
+55 56 67
+55 56 67
+55 56 58
+56 58 67
+24 66 71
+24 54 66
+17 24 54
+17 24 71
+17 54 71
+53 54 71
+49 53 54
+17 49 54
+8 17 54
+8 17 49
+8 39 49
+8 39 54
+15 36 59
+15 20 59
+15 19 20
+20 59 65
+19 20 65
+6 15 19
+6 15 36
+6 19 36
+6 19 36
+6 16 36
+6 16 19
+16 19 62
+16 52 62
+19 62 65
+16 45 52
+12 16 45
+12 36 45
+12 16 36
+23 58 67
+23 58 64
+23 64 67
+25 64 67
+25 28 67
+25 28 64
+28 67 74
+63 67 74
+56 63 67
+30 38 40
+6 36 38
+6 36 45
+6 7 45
+6 7 38
+7 38 45
+61 70 73
Index: tests/Tesselations/cholesterol/2.5/NonConvexEnvelope-cholesterol.dat
===================================================================
--- tests/Tesselations/cholesterol/2.5/NonConvexEnvelope-cholesterol.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/cholesterol/2.5/NonConvexEnvelope-cholesterol.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,146 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="cholesterol", N=48, E=94, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+2.7188 0.956 -1.9356 7
+3.3535 1.0837 -0.8167 3
+6.9077 1.1106 0.1214 1
+0.3612 -3.628 1.323 0
+0.4884 -3.5983 -0.4521 1
+1.4985 -2.5112 0.5308 2
+-1.0035 -0.1376 -0.792 4
+-1.9534 -3.5752 0.5362 2
+-1.1883 -0.199 1.5176 4
+-0.7165 -1.6046 2.5129 1
+1.7627 -1.4479 -0.8349 4
+-1.003 -1.3584 -2.8848 1
+0.0217 -2.6629 -2.2008 1
+-2.8885 -1.5706 1.7543 2
+-2.0579 -3.6765 -1.7622 0
+-2.9259 -2.1146 -1.7672 0
+1.0353 0.1785 2.542 2
+1.6325 -1.3323 1.8306 3
+0.7271 1.177 0.3594 3
+1.3374 -0.2942 -2.961 2
+0.6036 1.0859 -2.1126 4
+-3.2034 -0.5041 -1.0881 3
+-5.1809 -1.8679 0.9687 1
+-4.6025 -2.4721 -0.6025 1
+-4.3385 -3.4329 0.8725 0
+3.191 1.3217 -2.8354 2
+-5.1673 -0.0316 0.3501 4
+-4.0905 0.6312 1.6028 2
+2.8131 1.4776 2.5103 0
+3.9137 2.2936 1.3739 0
+2.159 2.5738 1.2698 1
+3.6606 -0.4593 2.1396 2
+3.2007 -1.4419 0.7311 3
+-3.3002 2.3589 0.0094 4
+-4.377 1.6962 -1.2433 2
+5.2593 1.4547 -1.7445 0
+4.6863 2.7674 -0.6775 2
+5.746 -0.9031 1.204 0
+5.1212 -0.8867 -0.4582 1
+-5.2641 2.8314 1.4476 0
+5.2727 1.6068 1.2828 3
+-6.2394 4.6427 0.0632 0
+-4.4738 4.5591 -0.1458 0
+-5.5506 3.8964 -1.3985 0
+-6.7081 0.9923 0.6224 2
+-7.5442 2.5597 0.5118 0
+-6.8554 1.8134 -0.9499 0
+7.1391 2.0447 0.0264 0
+
+3 36 48
+3 36 39
+3 38 39
+36 37 48
+26 36 37
+26 36 39
+1 26 39
+1 20 26
+1 11 20
+1 11 39
+11 13 20
+5 11 13
+5 6 11
+6 11 33
+11 33 39
+4 5 6
+33 38 39
+32 33 38
+18 32 33
+6 18 33
+4 6 18
+4 10 18
+10 17 18
+17 18 32
+17 29 32
+12 13 20
+12 13 15
+12 15 16
+15 16 24
+15 24 25
+8 15 25
+5 8 15
+4 5 8
+5 13 15
+29 32 41
+32 38 41
+29 30 41
+3 38 41
+3 41 48
+29 30 31
+30 31 37
+30 37 41
+37 41 48
+12 16 22
+16 22 24
+22 24 27
+22 27 35
+27 35 47
+27 45 47
+23 27 45
+23 24 27
+7 12 22
+7 12 21
+7 22 35
+7 34 35
+7 21 34
+12 20 21
+20 21 26
+34 35 43
+35 43 44
+23 24 25
+45 46 47
+17 29 31
+17 19 31
+9 17 19
+9 19 34
+9 28 34
+28 34 40
+34 40 43
+40 42 43
+40 42 46
+40 45 46
+28 40 45
+23 28 45
+14 23 28
+14 23 25
+8 14 25
+8 10 14
+4 8 10
+9 10 17
+9 10 14
+9 14 28
+35 44 47
+2 31 37
+1 2 37
+1 2 31
+1 26 37
+1 21 31
+19 21 31
+1 21 26
+19 21 34
+44 46 47
+42 44 46
+42 43 44
Index: tests/Tesselations/cholesterol/2/NonConvexEnvelope-cholesterol.dat
===================================================================
--- tests/Tesselations/cholesterol/2/NonConvexEnvelope-cholesterol.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/cholesterol/2/NonConvexEnvelope-cholesterol.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,153 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="cholesterol", N=49, E=100, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+2.7188 0.956 -1.9356 9
+3.3535 1.0837 -0.8167 4
+6.9077 1.1106 0.1214 1
+0.3612 -3.628 1.323 0
+0.4884 -3.5983 -0.4521 1
+1.4985 -2.5112 0.5308 2
+-1.0035 -0.1376 -0.792 5
+-1.9534 -3.5752 0.5362 2
+-1.1883 -0.199 1.5176 4
+-0.7165 -1.6046 2.5129 1
+1.7627 -1.4479 -0.8349 4
+-1.003 -1.3584 -2.8848 1
+0.0217 -2.6629 -2.2008 1
+-2.8885 -1.5706 1.7543 2
+-2.0579 -3.6765 -1.7622 0
+-2.9259 -2.1146 -1.7672 0
+1.0353 0.1785 2.542 2
+1.6325 -1.3323 1.8306 3
+0.7271 1.177 0.3594 5
+1.3374 -0.2942 -2.961 2
+0.6036 1.0859 -2.1126 2
+-2.1265 0.1587 0.1647 6
+-3.2034 -0.5041 -1.0881 4
+-5.1809 -1.8679 0.9687 2
+-4.6025 -2.4721 -0.6025 1
+-4.3385 -3.4329 0.8725 0
+3.191 1.3217 -2.8354 2
+-5.1673 -0.0316 0.3501 7
+-4.0905 0.6312 1.6028 3
+2.8131 1.4776 2.5103 0
+3.9137 2.2936 1.3739 0
+2.159 2.5738 1.2698 1
+3.6606 -0.4593 2.1396 2
+3.2007 -1.4419 0.7311 3
+-3.3002 2.3589 0.0094 4
+-4.377 1.6962 -1.2433 1
+5.2593 1.4547 -1.7445 1
+4.6863 2.7674 -0.6775 2
+5.746 -0.9031 1.204 0
+5.1212 -0.8867 -0.4582 1
+-5.2641 2.8314 1.4476 0
+5.2727 1.6068 1.2828 3
+-6.2394 4.6427 0.0632 0
+-4.4738 4.5591 -0.1458 0
+-5.5506 3.8964 -1.3985 0
+-6.7081 0.9923 0.6224 2
+-7.5442 2.5597 0.5118 0
+-6.8554 1.8134 -0.9499 0
+7.1391 2.0447 0.0264 0
+
+3 37 49
+3 37 40
+3 39 40
+37 38 49
+27 37 38
+1 27 38
+1 2 38
+2 32 38
+2 19 32
+1 2 19
+1 19 21
+1 21 27
+31 32 38
+20 21 27
+12 20 21
+7 12 21
+7 12 23
+7 22 23
+22 23 35
+23 35 36
+7 22 35
+7 22 35
+7 19 22
+7 19 21
+9 19 22
+9 22 29
+22 29 35
+9 17 19
+17 19 32
+17 30 32
+29 35 41
+35 41 44
+12 16 23
+16 23 25
+23 25 28
+23 28 36
+28 36 48
+28 46 48
+24 28 46
+24 28 46
+24 28 29
+28 29 46
+24 25 28
+29 41 46
+41 46 47
+14 24 29
+14 24 26
+8 14 26
+8 10 14
+4 8 10
+24 25 26
+41 43 44
+41 43 47
+9 10 17
+9 10 14
+9 14 29
+46 47 48
+31 38 42
+38 42 49
+35 36 44
+36 44 45
+30 31 32
+30 31 42
+30 33 42
+33 39 42
+3 39 42
+3 42 49
+12 15 16
+12 13 15
+12 13 20
+11 13 20
+5 11 13
+5 6 11
+6 11 34
+11 34 40
+1 11 20
+1 20 27
+1 11 40
+1 27 37
+1 37 40
+4 5 6
+4 6 18
+6 18 34
+18 33 34
+33 34 39
+34 39 40
+4 10 18
+10 17 18
+17 18 33
+17 30 33
+15 16 25
+15 25 26
+8 15 26
+36 45 48
+5 13 15
+5 8 15
+4 5 8
+43 44 45
+45 47 48
+43 45 47
Index: tests/Tesselations/cholesterol/25/NonConvexEnvelope-cholesterol.dat
===================================================================
--- tests/Tesselations/cholesterol/25/NonConvexEnvelope-cholesterol.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/cholesterol/25/NonConvexEnvelope-cholesterol.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,102 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="cholesterol", N=34, E=64, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+6.9077 1.1106 0.1214 0
+0.3612 -3.628 1.323 0
+0.4884 -3.5983 -0.4521 0
+-1.9534 -3.5752 0.5362 0
+-0.7165 -1.6046 2.5129 0
+-1.003 -1.3584 -2.8848 1
+0.0217 -2.6629 -2.2008 0
+-2.8885 -1.5706 1.7543 2
+-2.0579 -3.6765 -1.7622 0
+-2.9259 -2.1146 -1.7672 2
+1.0353 0.1785 2.542 1
+1.3374 -0.2942 -2.961 0
+-5.1809 -1.8679 0.9687 1
+-4.6025 -2.4721 -0.6025 2
+-4.3385 -3.4329 0.8725 1
+3.191 1.3217 -2.8354 2
+-4.0905 0.6312 1.6028 2
+2.8131 1.4776 2.5103 1
+3.9137 2.2936 1.3739 0
+2.159 2.5738 1.2698 2
+3.6606 -0.4593 2.1396 2
+5.2593 1.4547 -1.7445 0
+4.6863 2.7674 -0.6775 1
+5.746 -0.9031 1.204 0
+5.1212 -0.8867 -0.4582 1
+-5.2641 2.8314 1.4476 1
+5.2727 1.6068 1.2828 1
+-6.2394 4.6427 0.0632 0
+-4.4738 4.5591 -0.1458 2
+-5.5506 3.8964 -1.3985 0
+-6.7081 0.9923 0.6224 2
+-7.5442 2.5597 0.5118 0
+-6.8554 1.8134 -0.9499 1
+7.1391 2.0447 0.0264 0
+
+1 22 34
+1 22 25
+16 22 25
+12 16 25
+7 12 25
+3 7 25
+3 7 9
+3 24 25
+2 3 24
+6 7 12
+6 7 9
+1 24 25
+6 9 10
+6 10 33
+9 10 14
+10 14 33
+6 30 33
+6 12 30
+12 16 30
+2 3 9
+2 4 9
+4 9 15
+2 4 15
+9 14 15
+13 14 15
+13 14 31
+14 31 33
+31 32 33
+16 29 30
+16 23 29
+16 22 23
+22 23 34
+28 29 30
+2 5 15
+5 8 15
+8 13 15
+8 13 17
+5 8 17
+13 17 31
+17 26 31
+26 31 32
+5 17 26
+5 11 26
+11 18 26
+2 5 21
+2 21 24
+5 11 21
+11 18 21
+18 21 27
+21 24 27
+24 27 34
+1 24 34
+18 26 29
+18 20 29
+26 28 29
+18 19 20
+18 19 27
+19 27 34
+19 20 23
+20 23 29
+19 23 34
+26 28 32
+30 32 33
+28 30 32
Index: tests/Tesselations/cholesterol/3.5/NonConvexEnvelope-cholesterol.dat
===================================================================
--- tests/Tesselations/cholesterol/3.5/NonConvexEnvelope-cholesterol.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/cholesterol/3.5/NonConvexEnvelope-cholesterol.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,134 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="cholesterol", N=44, E=86, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+6.9077 1.1106 0.1214 1
+0.3612 -3.628 1.323 0
+0.4884 -3.5983 -0.4521 1
+1.4985 -2.5112 0.5308 2
+-1.9534 -3.5752 0.5362 2
+-1.1883 -0.199 1.5176 3
+-0.7165 -1.6046 2.5129 1
+1.7627 -1.4479 -0.8349 4
+-1.003 -1.3584 -2.8848 2
+0.0217 -2.6629 -2.2008 1
+-2.8885 -1.5706 1.7543 2
+-2.0579 -3.6765 -1.7622 0
+-2.9259 -2.1146 -1.7672 0
+1.0353 0.1785 2.542 1
+1.6325 -1.3323 1.8306 3
+0.7271 1.177 0.3594 6
+1.3374 -0.2942 -2.961 2
+0.6036 1.0859 -2.1126 3
+-3.2034 -0.5041 -1.0881 3
+-5.1809 -1.8679 0.9687 1
+-4.6025 -2.4721 -0.6025 3
+-4.3385 -3.4329 0.8725 0
+3.191 1.3217 -2.8354 1
+-4.0905 0.6312 1.6028 3
+2.8131 1.4776 2.5103 0
+3.9137 2.2936 1.3739 0
+2.159 2.5738 1.2698 2
+3.6606 -0.4593 2.1396 2
+3.2007 -1.4419 0.7311 3
+-3.3002 2.3589 0.0094 5
+-4.377 1.6962 -1.2433 3
+5.2593 1.4547 -1.7445 0
+4.6863 2.7674 -0.6775 0
+5.746 -0.9031 1.204 0
+5.1212 -0.8867 -0.4582 1
+-5.2641 2.8314 1.4476 0
+5.2727 1.6068 1.2828 2
+-6.2394 4.6427 0.0632 0
+-4.4738 4.5591 -0.1458 0
+-5.5506 3.8964 -1.3985 0
+-6.7081 0.9923 0.6224 2
+-7.5442 2.5597 0.5118 0
+-6.8554 1.8134 -0.9499 1
+7.1391 2.0447 0.0264 0
+
+1 32 44
+1 32 35
+1 34 35
+23 32 35
+17 23 35
+8 17 35
+8 10 17
+3 8 10
+3 4 8
+4 8 29
+8 29 35
+29 34 35
+2 3 4
+28 29 34
+15 28 29
+4 15 29
+2 4 15
+2 7 15
+7 14 15
+14 15 28
+14 25 28
+25 28 37
+28 34 37
+25 26 37
+1 34 37
+1 37 44
+25 26 27
+26 27 33
+26 33 44
+26 37 44
+14 25 27
+6 14 27
+6 16 27
+6 16 30
+16 27 30
+16 27 30
+16 18 30
+16 18 27
+6 24 30
+24 30 36
+30 36 39
+18 27 33
+18 23 33
+36 38 39
+36 38 42
+36 41 42
+24 36 41
+20 24 41
+11 20 24
+11 20 22
+5 11 22
+5 7 11
+2 5 7
+7 11 24
+6 7 24
+6 7 14
+18 30 31
+30 31 39
+31 39 40
+9 18 31
+9 17 18
+17 18 23
+9 19 31
+9 13 19
+13 19 21
+19 21 31
+21 31 43
+31 40 43
+9 12 13
+9 10 12
+9 10 17
+12 13 21
+12 21 22
+5 12 22
+3 5 12
+2 3 5
+3 10 12
+21 41 43
+20 21 41
+20 21 22
+41 42 43
+32 33 44
+23 32 33
+40 42 43
+38 40 42
+38 39 40
Index: tests/Tesselations/cholesterol/3/NonConvexEnvelope-cholesterol.dat
===================================================================
--- tests/Tesselations/cholesterol/3/NonConvexEnvelope-cholesterol.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/cholesterol/3/NonConvexEnvelope-cholesterol.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,138 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="cholesterol", N=46, E=88, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+2.7188 0.956 -1.9356 4
+6.9077 1.1106 0.1214 1
+0.3612 -3.628 1.323 0
+0.4884 -3.5983 -0.4521 1
+1.4985 -2.5112 0.5308 2
+-1.9534 -3.5752 0.5362 2
+-1.1883 -0.199 1.5176 4
+-0.7165 -1.6046 2.5129 1
+1.7627 -1.4479 -0.8349 4
+-1.003 -1.3584 -2.8848 2
+0.0217 -2.6629 -2.2008 1
+-2.8885 -1.5706 1.7543 2
+-2.0579 -3.6765 -1.7622 0
+-2.9259 -2.1146 -1.7672 0
+1.0353 0.1785 2.542 2
+1.6325 -1.3323 1.8306 3
+0.7271 1.177 0.3594 3
+1.3374 -0.2942 -2.961 2
+0.6036 1.0859 -2.1126 4
+-3.2034 -0.5041 -1.0881 3
+-5.1809 -1.8679 0.9687 1
+-4.6025 -2.4721 -0.6025 3
+-4.3385 -3.4329 0.8725 0
+3.191 1.3217 -2.8354 2
+-5.1673 -0.0316 0.3501 4
+-4.0905 0.6312 1.6028 2
+2.8131 1.4776 2.5103 0
+3.9137 2.2936 1.3739 0
+2.159 2.5738 1.2698 1
+3.6606 -0.4593 2.1396 2
+3.2007 -1.4419 0.7311 3
+-3.3002 2.3589 0.0094 3
+-4.377 1.6962 -1.2433 3
+5.2593 1.4547 -1.7445 0
+4.6863 2.7674 -0.6775 2
+5.746 -0.9031 1.204 0
+5.1212 -0.8867 -0.4582 1
+-5.2641 2.8314 1.4476 0
+5.2727 1.6068 1.2828 3
+-6.2394 4.6427 0.0632 0
+-4.4738 4.5591 -0.1458 0
+-5.5506 3.8964 -1.3985 0
+-6.7081 0.9923 0.6224 2
+-7.5442 2.5597 0.5118 0
+-6.8554 1.8134 -0.9499 1
+7.1391 2.0447 0.0264 0
+
+2 34 46
+2 34 37
+2 36 37
+24 34 37
+18 24 37
+9 18 37
+9 11 18
+4 9 11
+4 5 9
+5 9 31
+9 31 37
+31 36 37
+3 4 5
+30 31 36
+16 30 31
+5 16 31
+3 5 16
+3 8 16
+8 15 16
+15 16 30
+15 27 30
+27 30 39
+30 36 39
+27 28 39
+2 36 39
+2 39 46
+27 28 29
+28 29 35
+28 35 39
+35 39 46
+10 11 18
+10 11 13
+10 13 14
+13 14 22
+13 22 23
+6 13 23
+4 6 13
+3 4 6
+4 11 13
+10 14 20
+10 20 33
+10 19 33
+14 20 22
+20 22 33
+22 33 45
+22 25 45
+25 43 45
+21 25 43
+21 22 25
+10 18 19
+18 19 24
+19 32 33
+32 33 41
+33 41 42
+21 22 23
+43 44 45
+15 27 29
+15 17 29
+7 15 17
+7 17 32
+7 26 32
+26 32 38
+32 38 41
+38 40 41
+38 40 44
+38 43 44
+26 38 43
+21 26 43
+12 21 26
+12 21 23
+6 12 23
+6 8 12
+3 6 8
+7 8 15
+7 8 12
+7 12 26
+33 42 45
+34 35 46
+24 34 35
+1 29 35
+1 19 29
+1 24 35
+1 19 24
+17 19 29
+17 19 32
+42 44 45
+40 42 44
+40 41 42
Index: tests/Tesselations/cholesterol/4/NonConvexEnvelope-cholesterol.dat
===================================================================
--- tests/Tesselations/cholesterol/4/NonConvexEnvelope-cholesterol.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/cholesterol/4/NonConvexEnvelope-cholesterol.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,134 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="cholesterol", N=44, E=86, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+6.9077 1.1106 0.1214 1
+0.3612 -3.628 1.323 1
+0.4884 -3.5983 -0.4521 3
+1.4985 -2.5112 0.5308 4
+-1.9534 -3.5752 0.5362 2
+-1.1883 -0.199 1.5176 3
+-0.7165 -1.6046 2.5129 1
+1.7627 -1.4479 -0.8349 4
+-1.003 -1.3584 -2.8848 2
+0.0217 -2.6629 -2.2008 1
+-2.8885 -1.5706 1.7543 2
+-2.0579 -3.6765 -1.7622 0
+-2.9259 -2.1146 -1.7672 1
+1.0353 0.1785 2.542 3
+1.6325 -1.3323 1.8306 2
+0.7271 1.177 0.3594 3
+1.3374 -0.2942 -2.961 2
+0.6036 1.0859 -2.1126 3
+-3.2034 -0.5041 -1.0881 3
+-5.1809 -1.8679 0.9687 1
+-4.6025 -2.4721 -0.6025 2
+-4.3385 -3.4329 0.8725 0
+3.191 1.3217 -2.8354 1
+-4.0905 0.6312 1.6028 3
+2.8131 1.4776 2.5103 0
+3.9137 2.2936 1.3739 0
+2.159 2.5738 1.2698 5
+3.6606 -0.4593 2.1396 2
+3.2007 -1.4419 0.7311 4
+-3.3002 2.3589 0.0094 8
+-4.377 1.6962 -1.2433 3
+5.2593 1.4547 -1.7445 0
+4.6863 2.7674 -0.6775 0
+5.746 -0.9031 1.204 0
+5.1212 -0.8867 -0.4582 4
+-5.2641 2.8314 1.4476 0
+5.2727 1.6068 1.2828 2
+-6.2394 4.6427 0.0632 0
+-4.4738 4.5591 -0.1458 3
+-5.5506 3.8964 -1.3985 0
+-6.7081 0.9923 0.6224 2
+-7.5442 2.5597 0.5118 0
+-6.8554 1.8134 -0.9499 1
+7.1391 2.0447 0.0264 0
+
+1 32 44
+1 32 35
+1 34 35
+23 32 35
+17 23 35
+8 17 35
+8 10 17
+3 8 10
+3 8 35
+3 4 35
+4 29 35
+29 34 35
+2 3 4
+2 4 29
+2 15 29
+15 28 29
+28 29 34
+2 7 15
+7 14 15
+14 15 28
+14 25 28
+25 28 37
+28 34 37
+1 34 37
+1 37 44
+25 26 37
+25 26 27
+26 27 33
+26 33 44
+26 37 44
+14 25 27
+14 27 30
+6 14 30
+6 24 30
+24 30 36
+30 36 39
+27 30 39
+27 30 39
+16 27 30
+16 18 30
+16 18 27
+18 27 33
+18 23 33
+6 7 24
+6 7 14
+7 11 24
+11 20 24
+20 24 41
+24 36 41
+36 41 42
+11 20 22
+5 11 22
+5 7 11
+2 5 7
+36 38 39
+36 38 42
+18 30 31
+30 31 39
+31 39 40
+9 18 31
+9 17 18
+17 18 23
+9 19 31
+9 13 19
+13 19 31
+13 21 31
+21 31 43
+31 40 43
+9 12 13
+9 10 12
+9 10 17
+12 13 21
+12 21 22
+5 12 22
+3 5 12
+2 3 5
+3 10 12
+20 21 22
+20 21 41
+21 41 43
+41 42 43
+23 32 33
+32 33 44
+40 42 43
+38 40 42
+38 39 40
Index: tests/Tesselations/cholesterol/cholesterol.xyz
===================================================================
--- tests/Tesselations/cholesterol/cholesterol.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/cholesterol/cholesterol.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,76 @@
+74
+NCI NSC 8798 5:6-Cholesten-3-ol
+C    0.5233   -2.9918    0.4529
+C   -0.5691   -1.9223    0.3925
+C   -0.3504   -1.0089   -0.8425
+C   -1.9207   -2.5721    0.1108
+C   -0.4881   -1.0286    1.6162
+C    1.1055   -0.5783   -0.8354
+C   -0.7624   -1.9351   -1.9917
+C   -3.0507   -1.7160    0.6863
+C   -2.0300   -2.6378   -1.4329
+C    0.9499   -0.4944    1.6888
+C    1.3301    0.2716    0.4281
+C    1.3697    0.3126   -2.0561
+C   -3.0696   -0.3571   -0.0164
+C   -4.3894   -2.4231    0.4654
+C    2.8009    0.6600    0.5172
+C    2.7188    0.9560   -1.9356
+C   -4.2243    0.4842    0.5311
+C    2.9310    1.8358    1.4876
+C    3.3535    1.0837   -0.8167
+C    3.6417   -0.4977    1.0504
+C   -4.2432    1.8431   -0.1716
+C    4.7486    1.6873   -0.8101
+C    5.0694   -0.3980    0.5148
+C   -5.3979    2.6844    0.3759
+C    5.5016    1.0566    0.3701
+C   -5.4168    4.0434   -0.3268
+C   -6.7216    1.9604    0.1218
+O    6.9077    1.1106    0.1214
+H    0.3612   -3.6280    1.3230
+H    0.4884   -3.5983   -0.4521
+H    1.4985   -2.5112    0.5308
+H   -1.0035   -0.1376   -0.7920
+H   -1.9534   -3.5752    0.5362
+H   -1.1883   -0.1990    1.5176
+H   -0.7165   -1.6046    2.5129
+H    1.7627   -1.4479   -0.8349
+H   -1.0030   -1.3584   -2.8848
+H    0.0217   -2.6629   -2.2008
+H   -2.8885   -1.5706    1.7543
+H   -2.0579   -3.6765   -1.7622
+H   -2.9259   -2.1146   -1.7672
+H    1.0353    0.1785    2.5420
+H    1.6325   -1.3323    1.8306
+H    0.7271    1.1770    0.3594
+H    1.3374   -0.2942   -2.9610
+H    0.6036    1.0859   -2.1126
+H   -2.1265    0.1587    0.1647
+H   -3.2034   -0.5041   -1.0881
+H   -5.1809   -1.8679    0.9687
+H   -4.6025   -2.4721   -0.6025
+H   -4.3385   -3.4329    0.8725
+H    3.1910    1.3217   -2.8354
+H   -5.1673   -0.0316    0.3501
+H   -4.0905    0.6312    1.6028
+H    2.8131    1.4776    2.5103
+H    3.9137    2.2936    1.3739
+H    2.1590    2.5738    1.2698
+H    3.6606   -0.4593    2.1396
+H    3.2007   -1.4419    0.7311
+H   -3.3002    2.3589    0.0094
+H   -4.3770    1.6962   -1.2433
+H    5.2593    1.4547   -1.7445
+H    4.6863    2.7674   -0.6775
+H    5.7460   -0.9031    1.2040
+H    5.1212   -0.8867   -0.4582
+H   -5.2641    2.8314    1.4476
+H    5.2727    1.6068    1.2828
+H   -6.2394    4.6427    0.0632
+H   -4.4738    4.5591   -0.1458
+H   -5.5506    3.8964   -1.3985
+H   -6.7081    0.9923    0.6224
+H   -7.5442    2.5597    0.5118
+H   -6.8554    1.8134   -0.9499
+H    7.1391    2.0447    0.0264
Index: tests/Tesselations/cycloheptane.test
===================================================================
--- tests/Tesselations/cycloheptane.test	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/cycloheptane.test	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,10 @@
+#! /bin/sh
+
+# Test a simple simulation: 
+
+. ./defs || exit 1
+set -e
+
+for radius in 1.5 2 2.5 3 3.5 4 25; do
+  Tesselation_run 0 $radius
+done
Index: tests/Tesselations/cycloheptane/1.5/NonConvexEnvelope-cycloheptane.dat
===================================================================
--- tests/Tesselations/cycloheptane/1.5/NonConvexEnvelope-cycloheptane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/cycloheptane/1.5/NonConvexEnvelope-cycloheptane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,85 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="cycloheptane", N=21, E=60, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+-1.5167 0.7428 0.1234 6
+-1.5167 -0.7429 -0.1234 6
+-0.2715 1.41 -0.4687 9
+-0.2715 -1.41 0.4688 9
+0.9161 1.188 0.4734 9
+0.9162 -1.1879 -0.4734 9
+1.741 0 0 6
+-2.4055 1.1795 -0.332 3
+-1.542 0.9255 1.1977 3
+-2.4055 -1.1797 0.332 3
+-1.5419 -0.9255 -1.1977 3
+-0.0513 0.9711 -1.4419 5
+-0.4508 2.4791 -0.5829 6
+-0.0512 -0.9711 1.4419 5
+-0.4507 -2.4791 0.5829 6
+1.541 2.081 0.4843 5
+0.5475 0.994 1.4806 3
+1.5411 -2.0809 -0.4843 5
+0.5475 -0.994 -1.4806 3
+2.3793 0.3271 -0.8208 4
+2.3793 -0.327 0.8208 4
+
+7 20 21
+7 20 21
+7 16 20
+7 18 21
+7 16 21
+7 18 20
+6 18 20
+6 18 19
+6 18 19
+6 19 20
+6 15 18
+6 15 19
+4 15 19
+4 11 15
+4 11 19
+2 11 15
+2 10 11
+2 10 15
+5 16 21
+5 16 17
+5 16 17
+5 17 21
+5 13 16
+5 13 17
+3 13 17
+3 9 13
+3 9 17
+1 9 13
+1 8 9
+1 8 13
+12 19 20
+14 17 21
+11 12 19
+1 11 12
+1 8 11
+1 8 12
+3 8 12
+3 12 13
+3 12 13
+3 8 13
+3 13 16
+3 12 16
+5 12 16
+5 16 20
+5 12 20
+9 14 17
+2 9 14
+2 9 10
+2 10 14
+4 10 14
+4 14 15
+4 14 15
+4 10 15
+4 15 18
+4 14 18
+6 14 18
+6 18 21
+6 14 21
+8 9 10
+8 10 11
Index: tests/Tesselations/cycloheptane/2.5/NonConvexEnvelope-cycloheptane.dat
===================================================================
--- tests/Tesselations/cycloheptane/2.5/NonConvexEnvelope-cycloheptane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/cycloheptane/2.5/NonConvexEnvelope-cycloheptane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="cycloheptane", N=14, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+-2.4055 1.1795 -0.332 0
+-1.542 0.9255 1.1977 0
+-2.4055 -1.1797 0.332 0
+-1.5419 -0.9255 -1.1977 0
+-0.0513 0.9711 -1.4419 1
+-0.4508 2.4791 -0.5829 1
+-0.0512 -0.9711 1.4419 1
+-0.4507 -2.4791 0.5829 1
+1.541 2.081 0.4843 1
+0.5475 0.994 1.4806 1
+1.5411 -2.0809 -0.4843 1
+0.5475 -0.994 -1.4806 1
+2.3793 0.3271 -0.8208 0
+2.3793 -0.327 0.8208 0
+
+11 13 14
+11 12 13
+5 12 13
+4 5 12
+1 4 5
+1 5 6
+5 9 13
+5 6 9
+1 3 4
+1 2 3
+2 3 7
+3 7 8
+2 7 10
+7 10 14
+9 10 14
+9 13 14
+7 11 14
+7 8 11
+3 4 8
+4 8 12
+8 11 12
+1 2 6
+2 6 10
+6 9 10
Index: tests/Tesselations/cycloheptane/2/NonConvexEnvelope-cycloheptane.dat
===================================================================
--- tests/Tesselations/cycloheptane/2/NonConvexEnvelope-cycloheptane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/cycloheptane/2/NonConvexEnvelope-cycloheptane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="cycloheptane", N=14, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+-2.4055 1.1795 -0.332 0
+-1.542 0.9255 1.1977 0
+-2.4055 -1.1797 0.332 0
+-1.5419 -0.9255 -1.1977 0
+-0.0513 0.9711 -1.4419 1
+-0.4508 2.4791 -0.5829 1
+-0.0512 -0.9711 1.4419 1
+-0.4507 -2.4791 0.5829 1
+1.541 2.081 0.4843 1
+0.5475 0.994 1.4806 1
+1.5411 -2.0809 -0.4843 1
+0.5475 -0.994 -1.4806 1
+2.3793 0.3271 -0.8208 0
+2.3793 -0.327 0.8208 0
+
+11 13 14
+11 12 13
+5 12 13
+5 9 13
+5 6 9
+4 5 12
+1 4 5
+1 5 6
+1 3 4
+1 2 3
+2 3 7
+3 7 8
+2 7 10
+7 10 14
+9 10 14
+9 13 14
+7 11 14
+7 8 11
+3 4 8
+4 8 12
+8 11 12
+1 2 6
+2 6 10
+6 9 10
Index: tests/Tesselations/cycloheptane/25/NonConvexEnvelope-cycloheptane.dat
===================================================================
--- tests/Tesselations/cycloheptane/25/NonConvexEnvelope-cycloheptane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/cycloheptane/25/NonConvexEnvelope-cycloheptane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="cycloheptane", N=14, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+-2.4055 1.1795 -0.332 0
+-1.542 0.9255 1.1977 0
+-2.4055 -1.1797 0.332 0
+-1.5419 -0.9255 -1.1977 0
+-0.0513 0.9711 -1.4419 0
+-0.4508 2.4791 -0.5829 0
+-0.0512 -0.9711 1.4419 0
+-0.4507 -2.4791 0.5829 0
+1.541 2.081 0.4843 0
+0.5475 0.994 1.4806 0
+1.5411 -2.0809 -0.4843 0
+0.5475 -0.994 -1.4806 0
+2.3793 0.3271 -0.8208 0
+2.3793 -0.327 0.8208 0
+
+11 13 14
+9 13 14
+9 10 14
+7 10 14
+2 7 10
+2 3 7
+3 7 8
+7 8 14
+8 11 14
+1 2 3
+11 12 13
+5 12 13
+4 5 12
+1 4 5
+1 5 6
+5 6 13
+6 9 13
+1 3 4
+1 2 6
+2 6 9
+2 9 10
+3 4 8
+4 8 11
+4 11 12
Index: tests/Tesselations/cycloheptane/3.5/NonConvexEnvelope-cycloheptane.dat
===================================================================
--- tests/Tesselations/cycloheptane/3.5/NonConvexEnvelope-cycloheptane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/cycloheptane/3.5/NonConvexEnvelope-cycloheptane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="cycloheptane", N=14, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+-2.4055 1.1795 -0.332 0
+-1.542 0.9255 1.1977 0
+-2.4055 -1.1797 0.332 0
+-1.5419 -0.9255 -1.1977 0
+-0.0513 0.9711 -1.4419 1
+-0.4508 2.4791 -0.5829 1
+-0.0512 -0.9711 1.4419 1
+-0.4507 -2.4791 0.5829 1
+1.541 2.081 0.4843 1
+0.5475 0.994 1.4806 1
+1.5411 -2.0809 -0.4843 1
+0.5475 -0.994 -1.4806 1
+2.3793 0.3271 -0.8208 0
+2.3793 -0.327 0.8208 0
+
+11 13 14
+11 12 13
+5 12 13
+4 5 12
+1 4 5
+1 5 6
+5 9 13
+5 6 9
+1 3 4
+9 13 14
+9 10 14
+7 10 14
+2 7 10
+2 3 7
+3 7 8
+7 11 14
+7 8 11
+1 2 3
+1 2 6
+2 6 10
+6 9 10
+3 4 8
+4 8 12
+8 11 12
Index: tests/Tesselations/cycloheptane/3/NonConvexEnvelope-cycloheptane.dat
===================================================================
--- tests/Tesselations/cycloheptane/3/NonConvexEnvelope-cycloheptane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/cycloheptane/3/NonConvexEnvelope-cycloheptane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="cycloheptane", N=14, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+-2.4055 1.1795 -0.332 0
+-1.542 0.9255 1.1977 0
+-2.4055 -1.1797 0.332 0
+-1.5419 -0.9255 -1.1977 0
+-0.0513 0.9711 -1.4419 1
+-0.4508 2.4791 -0.5829 1
+-0.0512 -0.9711 1.4419 1
+-0.4507 -2.4791 0.5829 1
+1.541 2.081 0.4843 1
+0.5475 0.994 1.4806 1
+1.5411 -2.0809 -0.4843 1
+0.5475 -0.994 -1.4806 1
+2.3793 0.3271 -0.8208 0
+2.3793 -0.327 0.8208 0
+
+11 13 14
+11 12 13
+5 12 13
+4 5 12
+1 4 5
+1 5 6
+5 9 13
+5 6 9
+1 3 4
+1 2 3
+2 3 7
+3 7 8
+2 7 10
+7 10 14
+9 10 14
+9 13 14
+7 11 14
+7 8 11
+1 2 6
+2 6 10
+6 9 10
+3 4 8
+4 8 12
+8 11 12
Index: tests/Tesselations/cycloheptane/4/NonConvexEnvelope-cycloheptane.dat
===================================================================
--- tests/Tesselations/cycloheptane/4/NonConvexEnvelope-cycloheptane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/cycloheptane/4/NonConvexEnvelope-cycloheptane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="cycloheptane", N=14, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+-2.4055 1.1795 -0.332 0
+-1.542 0.9255 1.1977 0
+-2.4055 -1.1797 0.332 0
+-1.5419 -0.9255 -1.1977 0
+-0.0513 0.9711 -1.4419 1
+-0.4508 2.4791 -0.5829 1
+-0.0512 -0.9711 1.4419 1
+-0.4507 -2.4791 0.5829 1
+1.541 2.081 0.4843 1
+0.5475 0.994 1.4806 1
+1.5411 -2.0809 -0.4843 1
+0.5475 -0.994 -1.4806 1
+2.3793 0.3271 -0.8208 0
+2.3793 -0.327 0.8208 0
+
+11 13 14
+11 12 13
+5 12 13
+4 5 12
+1 4 5
+1 5 6
+5 9 13
+5 6 9
+1 3 4
+9 13 14
+9 10 14
+7 10 14
+2 7 10
+2 3 7
+3 7 8
+7 11 14
+7 8 11
+1 2 3
+1 2 6
+2 6 10
+6 9 10
+3 4 8
+4 8 12
+8 11 12
Index: tests/Tesselations/cycloheptane/cycloheptane.xyz
===================================================================
--- tests/Tesselations/cycloheptane/cycloheptane.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/cycloheptane/cycloheptane.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,23 @@
+21
+NCI NSC 5164 Cycloheptane (8CI9CI)
+C   -1.5167    0.7428    0.1234
+C   -1.5167   -0.7429   -0.1234
+C   -0.2715    1.4100   -0.4687
+C   -0.2715   -1.4100    0.4688
+C    0.9161    1.1880    0.4734
+C    0.9162   -1.1879   -0.4734
+C    1.7410    0.0000    0.0000
+H   -2.4055    1.1795   -0.3320
+H   -1.5420    0.9255    1.1977
+H   -2.4055   -1.1797    0.3320
+H   -1.5419   -0.9255   -1.1977
+H   -0.0513    0.9711   -1.4419
+H   -0.4508    2.4791   -0.5829
+H   -0.0512   -0.9711    1.4419
+H   -0.4507   -2.4791    0.5829
+H    1.5410    2.0810    0.4843
+H    0.5475    0.9940    1.4806
+H    1.5411   -2.0809   -0.4843
+H    0.5475   -0.9940   -1.4806
+H    2.3793    0.3271   -0.8208
+H    2.3793   -0.3270    0.8208
Index: tests/Tesselations/defs.in
===================================================================
--- tests/Tesselations/defs.in	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/defs.in	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,75 @@
+# -*- shell-script -*-
+# @configure_input@
+# Set variables and functions to use in tests.
+# This is copied from the TREMOLO project, credits Ralf Wildenhues, modified Frederik Heber.
+#
+case $VERBOSE in
+	x*) set -x ;;
+esac
+
+pathname=$0
+# next two lines not portable
+basename=${pathname##*/}
+#testdir=${basename%.test}
+testdir=${basename%%.*}
+need_testdir="test -d @srcdir@/$testdir"
+testdir_exists="test -d $testdir"
+EXEEXT=@EXEEXT@
+# next 2 lines not portable
+MOLECUILDER=${MOLECUILDER-"@abs_top_builddir@/src/molecuilder$EXEEXT"}
+exec_prefix="@prefix@/bin"
+DEBUG=${DEBUG-false}
+CLEANUP='rm -f stderr stdout'
+
+if $need_testdir
+then
+	if $testdir_exists; then
+		rm -rf $testdir
+	fi
+	mkdir $testdir
+	CLEANUP="$CLEANUP; rm -rf $testdir"
+	cp -r @srcdir@/$testdir/* $testdir/
+	CLEANUP="rm -f stderr stdout diffstderr diffstdout; cd ..; $CLEANUP"
+	CLEANUP="rm -f *.conf*; rm -f NonConvexEnvelope*; rm -f ${testdir}.xyz; rm -f ${testdir}.dbond; $CLEANUP"
+fi
+
+# debug runs should keep results
+if $DEBUG; then :; else
+	trap "eval \"$CLEANUP\"" 0 1 2 13 15
+fi
+
+# TREMOLO_run status [options...]
+# Run tremolo with OPTIONS, fail if it does not exit with STATUS.
+Tesselation_run ()
+{
+	# $1 is exit code
+	# $2 is RADIUS
+	
+	expected_exitcode=$1
+	mol=$testdir
+	RADIUS=$2
+	FILENAME="NonConvexEnvelope"
+	exitcode=0
+	cd $testdir/$RADIUS
+	#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=$?
+	else
+		$MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -N 0 --sphere-radius $RADIUS --nonconvex-file $FILENAME 2>stderr >stdout || exitcode=$?
+	fi
+	#echo "Molecuilder done with exitcode $exitcode."
+	#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=$?
+	#echo "Diff done with exitcode $exitcode."
+	#cat diffstderr
+	#cat diffstdout
+	cd ../..
+	test $exitcode = $expected_exitcode || exit 1
+}
+
+# can use $LN_S
+
+# vim:set ft=sh:
Index: tests/Tesselations/dimethyl_bromomalonate.test
===================================================================
--- tests/Tesselations/dimethyl_bromomalonate.test	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/dimethyl_bromomalonate.test	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,10 @@
+#! /bin/sh
+
+# Test a simple simulation: 
+
+. ./defs || exit 1
+set -e
+
+for radius in 1.5 2 2.5 3 3.5 4 25; do
+  Tesselation_run 0 $radius
+done
Index: tests/Tesselations/dimethyl_bromomalonate/1.5/NonConvexEnvelope-dimethyl_bromomalonate.dat
===================================================================
--- tests/Tesselations/dimethyl_bromomalonate/1.5/NonConvexEnvelope-dimethyl_bromomalonate.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/dimethyl_bromomalonate/1.5/NonConvexEnvelope-dimethyl_bromomalonate.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,67 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="dimethyl_bromomalonate", N=17, E=46, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0.1684 0.0862 -0.6343 9
+-0.782 1.223 -0.3596 7
+1.4571 0.3173 0.1119 7
+-0.6406 -1.6032 -0.0372 2
+-1.9718 0.9798 0.2121 6
+-0.4729 2.3533 -0.654 3
+2.6131 0.4236 -0.5619 6
+1.4498 0.407 1.3168 2
+-2.8875 2.0751 0.4768 9
+3.8548 0.6463 0.1571 9
+0.3723 0.0334 -1.7037 5
+-3.142 2.5705 -0.4602 2
+-3.7944 1.6866 0.9403 4
+-2.4137 2.7904 1.149 3
+3.7888 1.58 0.7156 3
+4.0276 -0.1788 0.8479 3
+4.6801 0.705 -0.5526 6
+
+10 16 17
+10 16 17
+10 15 16
+10 15 17
+10 15 17
+7 10 15
+7 10 17
+7 10 17
+7 10 16
+3 7 16
+3 8 16
+3 7 15
+3 8 15
+2 3 8
+2 3 6
+1 2 8
+1 2 5
+1 2 5
+1 4 5
+1 4 5
+1 2 11
+1 4 11
+1 4 11
+1 3 11
+1 3 11
+3 7 11
+3 7 11
+1 6 11
+1 3 6
+1 3 8
+2 6 11
+2 6 12
+2 5 12
+5 9 12
+9 12 13
+9 12 13
+9 13 14
+9 13 14
+9 12 14
+5 9 13
+5 9 13
+5 9 14
+2 5 14
+2 6 14
+8 15 16
+6 12 14
Index: tests/Tesselations/dimethyl_bromomalonate/2.5/NonConvexEnvelope-dimethyl_bromomalonate.dat
===================================================================
--- tests/Tesselations/dimethyl_bromomalonate/2.5/NonConvexEnvelope-dimethyl_bromomalonate.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/dimethyl_bromomalonate/2.5/NonConvexEnvelope-dimethyl_bromomalonate.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="dimethyl_bromomalonate", N=14, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+-0.782 1.223 -0.3596 3
+1.4571 0.3173 0.1119 3
+-0.6406 -1.6032 -0.0372 0
+-1.9718 0.9798 0.2121 3
+-0.4729 2.3533 -0.654 2
+2.6131 0.4236 -0.5619 2
+1.4498 0.407 1.3168 3
+0.3723 0.0334 -1.7037 2
+-3.142 2.5705 -0.4602 0
+-3.7944 1.6866 0.9403 0
+-2.4137 2.7904 1.149 1
+3.7888 1.58 0.7156 1
+4.0276 -0.1788 0.8479 0
+4.6801 0.705 -0.5526 0
+
+6 13 14
+2 6 13
+2 7 13
+2 3 7
+2 6 8
+2 3 8
+7 12 13
+12 13 14
+5 7 12
+5 6 12
+6 12 14
+5 6 8
+5 7 11
+4 7 11
+4 10 11
+3 4 7
+1 5 8
+1 5 9
+1 4 9
+1 4 8
+3 4 8
+4 9 10
+5 9 11
+9 10 11
Index: tests/Tesselations/dimethyl_bromomalonate/2/NonConvexEnvelope-dimethyl_bromomalonate.dat
===================================================================
--- tests/Tesselations/dimethyl_bromomalonate/2/NonConvexEnvelope-dimethyl_bromomalonate.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/dimethyl_bromomalonate/2/NonConvexEnvelope-dimethyl_bromomalonate.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,55 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="dimethyl_bromomalonate", N=15, E=36, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0.1684 0.0862 -0.6343 10
+-0.782 1.223 -0.3596 9
+1.4571 0.3173 0.1119 6
+-0.6406 -1.6032 -0.0372 5
+-1.9718 0.9798 0.2121 6
+-0.4729 2.3533 -0.654 3
+2.6131 0.4236 -0.5619 2
+1.4498 0.407 1.3168 6
+0.3723 0.0334 -1.7037 3
+-3.142 2.5705 -0.4602 0
+-3.7944 1.6866 0.9403 0
+-2.4137 2.7904 1.149 0
+3.7888 1.58 0.7156 0
+4.0276 -0.1788 0.8479 0
+4.6801 0.705 -0.5526 0
+
+7 14 15
+3 7 14
+3 8 14
+3 4 8
+3 7 9
+1 3 9
+1 4 9
+1 4 9
+1 2 9
+1 2 5
+1 2 5
+1 2 8
+2 5 8
+2 5 8
+1 4 5
+1 4 5
+1 4 8
+1 3 4
+2 5 12
+2 6 12
+2 6 8
+2 5 10
+2 6 10
+2 6 9
+3 6 8
+3 8 13
+3 7 13
+3 6 7
+6 7 9
+5 10 11
+5 11 12
+7 13 15
+6 10 12
+10 11 12
+8 13 14
+13 14 15
Index: tests/Tesselations/dimethyl_bromomalonate/25/NonConvexEnvelope-dimethyl_bromomalonate.dat
===================================================================
--- tests/Tesselations/dimethyl_bromomalonate/25/NonConvexEnvelope-dimethyl_bromomalonate.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/dimethyl_bromomalonate/25/NonConvexEnvelope-dimethyl_bromomalonate.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="dimethyl_bromomalonate", N=10, E=16, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+-0.6406 -1.6032 -0.0372 0
+-0.4729 2.3533 -0.654 0
+1.4498 0.407 1.3168 0
+0.3723 0.0334 -1.7037 0
+-3.142 2.5705 -0.4602 0
+-3.7944 1.6866 0.9403 0
+-2.4137 2.7904 1.149 0
+3.7888 1.58 0.7156 0
+4.0276 -0.1788 0.8479 0
+4.6801 0.705 -0.5526 0
+
+1 9 10
+1 4 10
+1 4 5
+1 5 6
+2 4 5
+2 4 10
+2 8 10
+2 7 8
+2 5 7
+5 6 7
+3 7 8
+3 8 9
+3 6 7
+1 3 6
+1 3 9
+8 9 10
Index: tests/Tesselations/dimethyl_bromomalonate/3.5/NonConvexEnvelope-dimethyl_bromomalonate.dat
===================================================================
--- tests/Tesselations/dimethyl_bromomalonate/3.5/NonConvexEnvelope-dimethyl_bromomalonate.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/dimethyl_bromomalonate/3.5/NonConvexEnvelope-dimethyl_bromomalonate.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,38 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="dimethyl_bromomalonate", N=12, E=22, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+-0.6406 -1.6032 -0.0372 4
+-1.9718 0.9798 0.2121 8
+-0.4729 2.3533 -0.654 1
+2.6131 0.4236 -0.5619 3
+1.4498 0.407 1.3168 2
+0.3723 0.0334 -1.7037 1
+-3.142 2.5705 -0.4602 1
+-3.7944 1.6866 0.9403 3
+-2.4137 2.7904 1.149 1
+3.7888 1.58 0.7156 1
+4.0276 -0.1788 0.8479 1
+4.6801 0.705 -0.5526 0
+
+4 11 12
+1 4 11
+1 4 6
+1 5 11
+1 2 5
+2 5 9
+2 8 9
+1 2 8
+1 2 8
+2 7 8
+2 6 7
+1 2 6
+3 6 7
+3 4 6
+3 4 10
+4 10 12
+3 5 10
+3 5 9
+3 7 9
+7 8 9
+5 10 11
+10 11 12
Index: tests/Tesselations/dimethyl_bromomalonate/3/NonConvexEnvelope-dimethyl_bromomalonate.dat
===================================================================
--- tests/Tesselations/dimethyl_bromomalonate/3/NonConvexEnvelope-dimethyl_bromomalonate.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/dimethyl_bromomalonate/3/NonConvexEnvelope-dimethyl_bromomalonate.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="dimethyl_bromomalonate", N=14, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+-0.782 1.223 -0.3596 3
+1.4571 0.3173 0.1119 3
+-0.6406 -1.6032 -0.0372 1
+-1.9718 0.9798 0.2121 3
+-0.4729 2.3533 -0.654 2
+2.6131 0.4236 -0.5619 2
+1.4498 0.407 1.3168 3
+0.3723 0.0334 -1.7037 1
+-3.142 2.5705 -0.4602 0
+-3.7944 1.6866 0.9403 0
+-2.4137 2.7904 1.149 1
+3.7888 1.58 0.7156 1
+4.0276 -0.1788 0.8479 0
+4.6801 0.705 -0.5526 0
+
+6 13 14
+2 6 13
+2 3 6
+3 6 8
+2 7 13
+2 3 7
+3 4 7
+4 7 11
+4 10 11
+5 7 11
+5 7 12
+5 6 12
+6 12 14
+5 6 8
+1 5 8
+1 5 9
+1 4 9
+1 4 8
+3 4 8
+4 9 10
+5 9 11
+9 10 11
+7 12 13
+12 13 14
Index: tests/Tesselations/dimethyl_bromomalonate/4/NonConvexEnvelope-dimethyl_bromomalonate.dat
===================================================================
--- tests/Tesselations/dimethyl_bromomalonate/4/NonConvexEnvelope-dimethyl_bromomalonate.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/dimethyl_bromomalonate/4/NonConvexEnvelope-dimethyl_bromomalonate.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,38 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="dimethyl_bromomalonate", N=12, E=22, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+-0.6406 -1.6032 -0.0372 4
+-1.9718 0.9798 0.2121 8
+-0.4729 2.3533 -0.654 1
+2.6131 0.4236 -0.5619 3
+1.4498 0.407 1.3168 2
+0.3723 0.0334 -1.7037 1
+-3.142 2.5705 -0.4602 1
+-3.7944 1.6866 0.9403 3
+-2.4137 2.7904 1.149 1
+3.7888 1.58 0.7156 1
+4.0276 -0.1788 0.8479 1
+4.6801 0.705 -0.5526 0
+
+4 11 12
+1 4 11
+1 4 6
+1 5 11
+1 2 5
+2 5 9
+2 8 9
+1 2 8
+1 2 8
+2 7 8
+2 6 7
+1 2 6
+3 6 7
+3 4 6
+3 4 10
+4 10 12
+5 10 11
+10 11 12
+3 5 10
+3 5 9
+3 7 9
+7 8 9
Index: tests/Tesselations/dimethyl_bromomalonate/dimethyl_bromomalonate.xyz
===================================================================
--- tests/Tesselations/dimethyl_bromomalonate/dimethyl_bromomalonate.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/dimethyl_bromomalonate/dimethyl_bromomalonate.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,19 @@
+17
+NCI NSC 175888 No Name
+C    0.1684    0.0862   -0.6343
+C   -0.7820    1.2230   -0.3596
+C    1.4571    0.3173    0.1119
+Br   -0.6406   -1.6032   -0.0372
+O   -1.9718    0.9798    0.2121
+O   -0.4729    2.3533   -0.6540
+O    2.6131    0.4236   -0.5619
+O    1.4498    0.4070    1.3168
+C   -2.8875    2.0751    0.4768
+C    3.8548    0.6463    0.1571
+H    0.3723    0.0334   -1.7037
+H   -3.1420    2.5705   -0.4602
+H   -3.7944    1.6866    0.9403
+H   -2.4137    2.7904    1.1490
+H    3.7888    1.5800    0.7156
+H    4.0276   -0.1788    0.8479
+H    4.6801    0.7050   -0.5526
Index: tests/Tesselations/glucose.test
===================================================================
--- tests/Tesselations/glucose.test	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/glucose.test	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,10 @@
+#! /bin/sh
+
+# Test a simple simulation: 
+
+. ./defs || exit 1
+set -e
+
+for radius in 1.5 2 2.5 3 3.5 4 25; do
+  Tesselation_run 0 $radius
+done
Index: tests/Tesselations/glucose/1.5/NonConvexEnvelope-glucose.dat
===================================================================
--- tests/Tesselations/glucose/1.5/NonConvexEnvelope-glucose.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/glucose/1.5/NonConvexEnvelope-glucose.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,92 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="glucose", N=24, E=64, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0.5323 -0.5022 -0.1225 8
+-0.6882 0.3464 0.2398 6
+1.805 0.3228 0.079 6
+0.5755 -1.6575 0.7174 2
+-1.9609 -0.4786 0.0383 14
+-0.5962 0.7541 1.6063 6
+3.0255 -0.5258 -0.2833 10
+1.7617 1.4781 -0.7609 3
+-3.163 0.3572 0.3952 7
+-2.0529 -0.8863 -1.3282 4
+4.2142 0.2447 -0.0951 3
+-4.0111 0.5807 -0.435 2
+0.4621 -0.8131 -1.1648 4
+-0.7212 1.2276 -0.4008 5
+1.8752 0.6338 1.1213 3
+0.6373 -1.3387 1.6282 0
+-1.9279 -1.3598 0.679 5
+-0.5696 -0.0534 2.1377 2
+3.0584 -1.407 0.3573 2
+2.9553 -0.8367 -1.3257 3
+1.7 1.1593 -1.6717 1
+-3.2661 0.7564 1.3934 5
+-2.0795 -0.0788 -1.8596 1
+4.9576 -0.3256 -0.3339 0
+
+11 19 24
+7 11 19
+7 15 19
+7 11 15
+15 16 19
+4 16 19
+15 16 18
+6 15 18
+19 20 24
+11 20 24
+7 11 20
+7 20 21
+7 8 21
+7 8 11
+3 11 15
+3 8 15
+3 8 15
+3 8 14
+2 3 15
+2 3 14
+2 6 14
+2 6 14
+2 6 15
+2 9 14
+3 8 11
+2 6 22
+2 9 22
+9 12 22
+9 12 22
+9 17 22
+5 9 17
+5 10 17
+5 10 17
+5 10 13
+1 5 17
+1 5 13
+1 4 13
+1 4 13
+1 4 19
+1 4 17
+1 13 20
+1 7 20
+7 19 20
+1 7 19
+5 9 10
+9 10 12
+10 12 23
+9 12 23
+5 9 23
+5 14 23
+5 9 14
+5 17 22
+5 17 18
+5 6 18
+6 18 22
+6 18 22
+5 6 22
+4 16 17
+16 17 18
+10 13 23
+13 14 23
+13 14 21
+8 14 21
+13 20 21
Index: tests/Tesselations/glucose/2.5/NonConvexEnvelope-glucose.dat
===================================================================
--- tests/Tesselations/glucose/2.5/NonConvexEnvelope-glucose.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/glucose/2.5/NonConvexEnvelope-glucose.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,59 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="glucose", N=19, E=36, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0.5755 -1.6575 0.7174 1
+-0.5962 0.7541 1.6063 1
+1.7617 1.4781 -0.7609 0
+-3.163 0.3572 0.3952 6
+-2.0529 -0.8863 -1.3282 0
+4.2142 0.2447 -0.0951 2
+-4.0111 0.5807 -0.435 3
+0.4621 -0.8131 -1.1648 2
+-0.7212 1.2276 -0.4008 3
+1.8752 0.6338 1.1213 1
+0.6373 -1.3387 1.6282 0
+-1.9279 -1.3598 0.679 1
+-0.5696 -0.0534 2.1377 0
+3.0584 -1.407 0.3573 2
+2.9553 -0.8367 -1.3257 1
+1.7 1.1593 -1.6717 1
+-3.2661 0.7564 1.3934 3
+-2.0795 -0.0788 -1.8596 1
+4.9576 -0.3256 -0.3339 0
+
+6 14 19
+6 10 14
+10 11 14
+10 11 13
+2 10 13
+2 3 10
+2 3 9
+2 9 17
+4 9 17
+4 7 17
+4 7 17
+4 7 9
+4 12 17
+4 7 12
+5 7 12
+7 9 18
+5 7 18
+12 13 17
+11 12 13
+1 11 12
+9 16 18
+8 16 18
+8 15 16
+3 9 16
+5 8 18
+2 13 17
+3 6 10
+3 6 16
+6 15 16
+6 15 19
+1 11 14
+1 5 8
+1 5 12
+1 8 15
+1 14 15
+14 15 19
Index: tests/Tesselations/glucose/2/NonConvexEnvelope-glucose.dat
===================================================================
--- tests/Tesselations/glucose/2/NonConvexEnvelope-glucose.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/glucose/2/NonConvexEnvelope-glucose.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,62 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="glucose", N=20, E=38, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0.5755 -1.6575 0.7174 0
+-1.9609 -0.4786 0.0383 3
+-0.5962 0.7541 1.6063 0
+1.7617 1.4781 -0.7609 0
+-3.163 0.3572 0.3952 6
+-2.0529 -0.8863 -1.3282 2
+4.2142 0.2447 -0.0951 2
+-4.0111 0.5807 -0.435 2
+0.4621 -0.8131 -1.1648 3
+-0.7212 1.2276 -0.4008 3
+1.8752 0.6338 1.1213 2
+0.6373 -1.3387 1.6282 0
+-1.9279 -1.3598 0.679 2
+-0.5696 -0.0534 2.1377 0
+3.0584 -1.407 0.3573 3
+2.9553 -0.8367 -1.3257 1
+1.7 1.1593 -1.6717 0
+-3.2661 0.7564 1.3934 3
+-2.0795 -0.0788 -1.8596 0
+4.9576 -0.3256 -0.3339 0
+
+7 15 20
+7 11 15
+11 12 15
+11 12 14
+3 11 14
+1 12 15
+1 12 13
+12 13 14
+13 14 18
+5 13 18
+5 8 18
+5 8 18
+5 10 18
+3 10 18
+5 8 10
+8 10 19
+2 5 13
+2 6 13
+2 5 6
+5 6 8
+6 8 19
+3 14 18
+3 10 11
+4 10 11
+1 9 15
+9 15 16
+1 9 13
+6 9 13
+15 16 20
+6 9 19
+9 10 19
+9 10 17
+4 10 17
+9 16 17
+4 7 11
+4 7 17
+7 16 17
+7 16 20
Index: tests/Tesselations/glucose/25/NonConvexEnvelope-glucose.dat
===================================================================
--- tests/Tesselations/glucose/25/NonConvexEnvelope-glucose.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/glucose/25/NonConvexEnvelope-glucose.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,54 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="glucose", N=18, E=32, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0.5755 -1.6575 0.7174 1
+-0.5962 0.7541 1.6063 1
+1.7617 1.4781 -0.7609 0
+-2.0529 -0.8863 -1.3282 1
+4.2142 0.2447 -0.0951 0
+-4.0111 0.5807 -0.435 0
+0.4621 -0.8131 -1.1648 3
+-0.7212 1.2276 -0.4008 1
+1.8752 0.6338 1.1213 0
+0.6373 -1.3387 1.6282 0
+-1.9279 -1.3598 0.679 0
+-0.5696 -0.0534 2.1377 0
+3.0584 -1.407 0.3573 0
+2.9553 -0.8367 -1.3257 1
+1.7 1.1593 -1.6717 0
+-3.2661 0.7564 1.3934 0
+-2.0795 -0.0788 -1.8596 0
+4.9576 -0.3256 -0.3339 0
+
+5 9 18
+9 10 18
+10 13 18
+9 10 12
+2 9 12
+2 12 16
+2 3 9
+2 3 8
+2 8 16
+3 5 9
+6 8 16
+6 8 15
+6 15 17
+3 8 15
+3 5 15
+5 15 18
+14 15 18
+14 15 17
+4 14 17
+4 7 14
+1 7 14
+1 4 7
+1 13 14
+1 4 11
+13 14 18
+1 10 11
+1 10 13
+10 11 12
+11 12 16
+6 11 16
+4 6 11
+4 6 17
Index: tests/Tesselations/glucose/3.5/NonConvexEnvelope-glucose.dat
===================================================================
--- tests/Tesselations/glucose/3.5/NonConvexEnvelope-glucose.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/glucose/3.5/NonConvexEnvelope-glucose.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,57 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="glucose", N=19, E=34, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0.5755 -1.6575 0.7174 1
+-0.5962 0.7541 1.6063 1
+1.7617 1.4781 -0.7609 0
+-3.163 0.3572 0.3952 3
+-2.0529 -0.8863 -1.3282 0
+4.2142 0.2447 -0.0951 1
+-4.0111 0.5807 -0.435 1
+0.4621 -0.8131 -1.1648 2
+-0.7212 1.2276 -0.4008 2
+1.8752 0.6338 1.1213 1
+0.6373 -1.3387 1.6282 0
+-1.9279 -1.3598 0.679 1
+-0.5696 -0.0534 2.1377 0
+3.0584 -1.407 0.3573 2
+2.9553 -0.8367 -1.3257 0
+1.7 1.1593 -1.6717 1
+-3.2661 0.7564 1.3934 1
+-2.0795 -0.0788 -1.8596 1
+4.9576 -0.3256 -0.3339 0
+
+6 14 19
+6 10 14
+10 11 14
+10 11 13
+2 10 13
+2 13 17
+2 3 10
+2 3 9
+2 9 17
+7 9 17
+7 9 18
+9 16 18
+3 9 16
+3 6 10
+3 6 16
+6 16 19
+15 16 19
+8 16 18
+8 15 16
+5 8 18
+1 5 8
+1 5 12
+1 8 15
+1 14 15
+14 15 19
+1 11 12
+11 12 13
+12 13 17
+4 12 17
+4 7 17
+4 7 12
+5 7 12
+5 7 18
+1 11 14
Index: tests/Tesselations/glucose/3/NonConvexEnvelope-glucose.dat
===================================================================
--- tests/Tesselations/glucose/3/NonConvexEnvelope-glucose.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/glucose/3/NonConvexEnvelope-glucose.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,57 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="glucose", N=19, E=34, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0.5755 -1.6575 0.7174 1
+-0.5962 0.7541 1.6063 1
+1.7617 1.4781 -0.7609 0
+-3.163 0.3572 0.3952 3
+-2.0529 -0.8863 -1.3282 0
+4.2142 0.2447 -0.0951 2
+-4.0111 0.5807 -0.435 1
+0.4621 -0.8131 -1.1648 2
+-0.7212 1.2276 -0.4008 2
+1.8752 0.6338 1.1213 1
+0.6373 -1.3387 1.6282 0
+-1.9279 -1.3598 0.679 1
+-0.5696 -0.0534 2.1377 0
+3.0584 -1.407 0.3573 2
+2.9553 -0.8367 -1.3257 1
+1.7 1.1593 -1.6717 1
+-3.2661 0.7564 1.3934 1
+-2.0795 -0.0788 -1.8596 1
+4.9576 -0.3256 -0.3339 0
+
+6 14 19
+6 10 14
+10 11 14
+10 11 13
+2 10 13
+2 13 17
+2 3 10
+2 3 9
+2 9 17
+7 9 17
+7 9 18
+9 16 18
+3 9 16
+8 16 18
+8 15 16
+5 8 18
+3 6 10
+3 6 16
+6 15 16
+6 15 19
+1 5 8
+1 5 12
+1 8 15
+1 14 15
+14 15 19
+1 11 12
+11 12 13
+12 13 17
+4 12 17
+4 7 17
+4 7 12
+5 7 12
+5 7 18
+1 11 14
Index: tests/Tesselations/glucose/4/NonConvexEnvelope-glucose.dat
===================================================================
--- tests/Tesselations/glucose/4/NonConvexEnvelope-glucose.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/glucose/4/NonConvexEnvelope-glucose.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,57 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="glucose", N=19, E=34, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0.5755 -1.6575 0.7174 1
+-0.5962 0.7541 1.6063 1
+1.7617 1.4781 -0.7609 0
+-3.163 0.3572 0.3952 3
+-2.0529 -0.8863 -1.3282 0
+4.2142 0.2447 -0.0951 1
+-4.0111 0.5807 -0.435 1
+0.4621 -0.8131 -1.1648 2
+-0.7212 1.2276 -0.4008 2
+1.8752 0.6338 1.1213 1
+0.6373 -1.3387 1.6282 0
+-1.9279 -1.3598 0.679 1
+-0.5696 -0.0534 2.1377 0
+3.0584 -1.407 0.3573 2
+2.9553 -0.8367 -1.3257 0
+1.7 1.1593 -1.6717 1
+-3.2661 0.7564 1.3934 1
+-2.0795 -0.0788 -1.8596 1
+4.9576 -0.3256 -0.3339 0
+
+6 14 19
+6 10 14
+10 11 14
+10 11 13
+2 10 13
+2 13 17
+2 3 10
+2 3 9
+2 9 17
+7 9 17
+7 9 18
+9 16 18
+3 9 16
+3 6 10
+3 6 16
+6 16 19
+15 16 19
+8 16 18
+8 15 16
+5 8 18
+1 5 8
+1 5 12
+1 8 15
+1 14 15
+14 15 19
+1 11 12
+11 12 13
+12 13 17
+1 11 14
+4 12 17
+4 7 17
+4 7 12
+5 7 12
+5 7 18
Index: tests/Tesselations/glucose/glucose.xyz
===================================================================
--- tests/Tesselations/glucose/glucose.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/glucose/glucose.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,26 @@
+24
+NCI NSC 406891 Sugar, grape
+C    0.5323   -0.5022   -0.1225
+C   -0.6882    0.3464    0.2398
+C    1.8050    0.3228    0.0790
+O    0.5755   -1.6575    0.7174
+C   -1.9609   -0.4786    0.0383
+O   -0.5962    0.7541    1.6063
+C    3.0255   -0.5258   -0.2833
+O    1.7617    1.4781   -0.7609
+C   -3.1630    0.3572    0.3952
+O   -2.0529   -0.8863   -1.3282
+O    4.2142    0.2447   -0.0951
+O   -4.0111    0.5807   -0.4350
+H    0.4621   -0.8131   -1.1648
+H   -0.7212    1.2276   -0.4008
+H    1.8752    0.6338    1.1213
+H    0.6373   -1.3387    1.6282
+H   -1.9279   -1.3598    0.6790
+H   -0.5696   -0.0534    2.1377
+H    3.0584   -1.4070    0.3573
+H    2.9553   -0.8367   -1.3257
+H    1.7000    1.1593   -1.6717
+H   -3.2661    0.7564    1.3934
+H   -2.0795   -0.0788   -1.8596
+H    4.9576   -0.3256   -0.3339
Index: tests/Tesselations/heptan.test
===================================================================
--- tests/Tesselations/heptan.test	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/heptan.test	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,10 @@
+#! /bin/sh
+
+# Test a simple simulation: 
+
+. ./defs || exit 1
+set -e
+
+for radius in 1.5 2 2.5 3 3.5 4 25; do
+  Tesselation_run 0 $radius
+done
Index: tests/Tesselations/heptan/1.5/NonConvexEnvelope-heptan.dat
===================================================================
--- tests/Tesselations/heptan/1.5/NonConvexEnvelope-heptan.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/heptan/1.5/NonConvexEnvelope-heptan.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,91 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="heptan", 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
+-1.2492 0.921941 0.930455 18.7227
+-1.2492 0.921941 -0.849545 18.7227
+1.2492 0.921941 -0.849545 18.7222
+1.2492 0.921941 0.930455 27.0641
+-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.849545 27.4727
+-4.6377 -0.336759 0.0404545 21.541
+-3.7477 0.921941 0.930455 18.8853
+-3.7477 0.921941 -0.849545 18.8853
+4.6377 -0.336759 0.0404545 10.6618
+3.7477 0.921941 -0.849545 18.5406
+3.7477 0.921941 0.930455 12.1988
+-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
+-3.7477 0.292641 0.0404545 39.5267
+3.7477 0.292641 0.0404545 23.2512
+
+14 15 23
+14 15 23
+10 14 23
+10 15 23
+15 16 23
+15 16 23
+15 19 23
+5 15 19
+5 6 19
+5 6 19
+5 18 19
+4 5 18
+6 18 19
+3 6 18
+3 4 18
+3 4 18
+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 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
+9 14 23
+9 16 23
+3 8 12
+1 3 8
+1 3 6
+1 6 9
+6 9 16
+4 7 13
+2 4 7
+2 4 5
+2 5 10
+5 10 15
+10 14 21
+9 10 21
+9 10 21
+9 14 21
+10 17 21
+2 10 17
+1 2 17
+1 2 17
+1 17 21
+1 9 21
+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/Tesselations/heptan/2.5/NonConvexEnvelope-heptan.dat
===================================================================
--- tests/Tesselations/heptan/2.5/NonConvexEnvelope-heptan.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/heptan/2.5/NonConvexEnvelope-heptan.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,48 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="heptan", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+-7.27e-07 -1.22006 0.930455 -17.4952
+-7.27e-07 -1.22006 -0.849545 -17.4952
+-1.2492 0.921941 0.930455 -19.6818
+-1.2492 0.921941 -0.849545 -15.323
+1.2492 0.921941 -0.849545 -17.495
+1.2492 0.921941 0.930455 -17.4951
+-2.4985 -1.22006 -0.849545 -13.1263
+-2.4985 -1.22006 0.930455 -10.8961
+2.4985 -1.22006 0.930455 -13.1263
+2.4985 -1.22006 -0.849545 -10.8961
+-4.6377 -0.336759 0.0404545 -9.35471
+-3.7477 0.921941 0.930455 -9.24444
+-3.7477 0.921941 -0.849545 -11.4805
+4.6377 -0.336759 0.0404545 -9.35473
+3.7477 0.921941 -0.849545 -11.4805
+3.7477 0.921941 0.930455 -9.24445
+
+14 15 16
+6 15 16
+5 6 15
+3 5 6
+3 4 5
+3 4 13
+3 12 13
+11 12 13
+7 11 13
+4 7 13
+2 4 7
+2 4 5
+2 5 10
+5 10 15
+10 14 15
+9 10 14
+2 9 10
+1 2 9
+1 2 7
+1 7 8
+7 8 11
+9 14 16
+6 9 16
+1 6 9
+1 3 6
+1 3 8
+3 8 12
+8 11 12
Index: tests/Tesselations/heptan/2/NonConvexEnvelope-heptan.dat
===================================================================
--- tests/Tesselations/heptan/2/NonConvexEnvelope-heptan.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/heptan/2/NonConvexEnvelope-heptan.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,48 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="heptan", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+-7.27e-07 -1.22006 0.930455 -17.4952
+-7.27e-07 -1.22006 -0.849545 -17.4952
+-1.2492 0.921941 0.930455 -19.6818
+-1.2492 0.921941 -0.849545 -15.323
+1.2492 0.921941 -0.849545 -17.495
+1.2492 0.921941 0.930455 -17.4951
+-2.4985 -1.22006 -0.849545 -13.1263
+-2.4985 -1.22006 0.930455 -10.8961
+2.4985 -1.22006 0.930455 -13.1263
+2.4985 -1.22006 -0.849545 -10.8961
+-4.6377 -0.336759 0.0404545 -9.35471
+-3.7477 0.921941 0.930455 -9.24444
+-3.7477 0.921941 -0.849545 -11.4805
+4.6377 -0.336759 0.0404545 -9.35473
+3.7477 0.921941 -0.849545 -11.4805
+3.7477 0.921941 0.930455 -9.24445
+
+14 15 16
+6 15 16
+5 6 15
+3 5 6
+3 4 5
+3 4 13
+3 12 13
+11 12 13
+7 11 13
+4 7 13
+2 4 7
+2 4 5
+2 5 10
+5 10 15
+10 14 15
+9 10 14
+2 9 10
+1 2 9
+1 2 7
+1 7 8
+7 8 11
+9 14 16
+6 9 16
+1 6 9
+1 3 6
+1 3 8
+3 8 12
+8 11 12
Index: tests/Tesselations/heptan/25/NonConvexEnvelope-heptan.dat
===================================================================
--- tests/Tesselations/heptan/25/NonConvexEnvelope-heptan.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/heptan/25/NonConvexEnvelope-heptan.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,48 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="heptan", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+-7.27e-07 -1.22006 0.930455 -17.4952
+-7.27e-07 -1.22006 -0.849545 -17.4952
+-1.2492 0.921941 0.930455 -19.6818
+-1.2492 0.921941 -0.849545 -15.323
+1.2492 0.921941 -0.849545 -17.495
+1.2492 0.921941 0.930455 -17.4951
+-2.4985 -1.22006 -0.849545 -13.1263
+-2.4985 -1.22006 0.930455 -10.8961
+2.4985 -1.22006 0.930455 -13.1263
+2.4985 -1.22006 -0.849545 -10.8961
+-4.6377 -0.336759 0.0404545 -9.35471
+-3.7477 0.921941 0.930455 -9.24444
+-3.7477 0.921941 -0.849545 -11.4805
+4.6377 -0.336759 0.0404545 -9.35473
+3.7477 0.921941 -0.849545 -11.4805
+3.7477 0.921941 0.930455 -9.24445
+
+14 15 16
+6 15 16
+5 6 15
+3 5 6
+3 4 5
+3 4 13
+3 12 13
+11 12 13
+7 11 13
+4 7 13
+2 4 7
+2 4 5
+2 5 10
+5 10 15
+10 14 15
+9 10 14
+2 9 10
+1 2 9
+1 2 7
+1 7 8
+7 8 11
+9 14 16
+6 9 16
+1 6 9
+1 3 6
+1 3 8
+3 8 12
+8 11 12
Index: tests/Tesselations/heptan/3.5/NonConvexEnvelope-heptan.dat
===================================================================
--- tests/Tesselations/heptan/3.5/NonConvexEnvelope-heptan.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/heptan/3.5/NonConvexEnvelope-heptan.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,48 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="heptan", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+-7.27e-07 -1.22006 0.930455 -17.4952
+-7.27e-07 -1.22006 -0.849545 -17.4952
+-1.2492 0.921941 0.930455 -19.6818
+-1.2492 0.921941 -0.849545 -15.323
+1.2492 0.921941 -0.849545 -17.495
+1.2492 0.921941 0.930455 -17.4951
+-2.4985 -1.22006 -0.849545 -13.1263
+-2.4985 -1.22006 0.930455 -10.8961
+2.4985 -1.22006 0.930455 -13.1263
+2.4985 -1.22006 -0.849545 -10.8961
+-4.6377 -0.336759 0.0404545 -9.35471
+-3.7477 0.921941 0.930455 -9.24444
+-3.7477 0.921941 -0.849545 -11.4805
+4.6377 -0.336759 0.0404545 -9.35473
+3.7477 0.921941 -0.849545 -11.4805
+3.7477 0.921941 0.930455 -9.24445
+
+14 15 16
+6 15 16
+5 6 15
+3 5 6
+3 4 5
+3 4 13
+3 12 13
+11 12 13
+7 11 13
+4 7 13
+2 4 7
+2 4 5
+2 5 10
+5 10 15
+10 14 15
+9 10 14
+2 9 10
+1 2 9
+1 2 7
+1 7 8
+7 8 11
+9 14 16
+6 9 16
+1 6 9
+1 3 6
+1 3 8
+3 8 12
+8 11 12
Index: tests/Tesselations/heptan/3/NonConvexEnvelope-heptan.dat
===================================================================
--- tests/Tesselations/heptan/3/NonConvexEnvelope-heptan.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/heptan/3/NonConvexEnvelope-heptan.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,48 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="heptan", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+-7.27e-07 -1.22006 0.930455 -17.4952
+-7.27e-07 -1.22006 -0.849545 -17.4952
+-1.2492 0.921941 0.930455 -19.6818
+-1.2492 0.921941 -0.849545 -15.323
+1.2492 0.921941 -0.849545 -17.495
+1.2492 0.921941 0.930455 -17.4951
+-2.4985 -1.22006 -0.849545 -13.1263
+-2.4985 -1.22006 0.930455 -10.8961
+2.4985 -1.22006 0.930455 -13.1263
+2.4985 -1.22006 -0.849545 -10.8961
+-4.6377 -0.336759 0.0404545 -9.35471
+-3.7477 0.921941 0.930455 -9.24444
+-3.7477 0.921941 -0.849545 -11.4805
+4.6377 -0.336759 0.0404545 -9.35473
+3.7477 0.921941 -0.849545 -11.4805
+3.7477 0.921941 0.930455 -9.24445
+
+14 15 16
+6 15 16
+5 6 15
+3 5 6
+3 4 5
+3 4 13
+3 12 13
+11 12 13
+7 11 13
+4 7 13
+2 4 7
+2 4 5
+2 5 10
+5 10 15
+10 14 15
+9 10 14
+2 9 10
+1 2 9
+1 2 7
+1 7 8
+7 8 11
+9 14 16
+6 9 16
+1 6 9
+1 3 6
+1 3 8
+3 8 12
+8 11 12
Index: tests/Tesselations/heptan/4/NonConvexEnvelope-heptan.dat
===================================================================
--- tests/Tesselations/heptan/4/NonConvexEnvelope-heptan.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/heptan/4/NonConvexEnvelope-heptan.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,48 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="heptan", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+-7.27e-07 -1.22006 0.930455 -17.4952
+-7.27e-07 -1.22006 -0.849545 -17.4952
+-1.2492 0.921941 0.930455 -19.6818
+-1.2492 0.921941 -0.849545 -15.323
+1.2492 0.921941 -0.849545 -17.495
+1.2492 0.921941 0.930455 -17.4951
+-2.4985 -1.22006 -0.849545 -13.1263
+-2.4985 -1.22006 0.930455 -10.8961
+2.4985 -1.22006 0.930455 -13.1263
+2.4985 -1.22006 -0.849545 -10.8961
+-4.6377 -0.336759 0.0404545 -9.35471
+-3.7477 0.921941 0.930455 -9.24444
+-3.7477 0.921941 -0.849545 -11.4805
+4.6377 -0.336759 0.0404545 -9.35473
+3.7477 0.921941 -0.849545 -11.4805
+3.7477 0.921941 0.930455 -9.24445
+
+14 15 16
+6 15 16
+5 6 15
+3 5 6
+3 4 5
+3 4 13
+3 12 13
+11 12 13
+7 11 13
+4 7 13
+2 4 7
+2 4 5
+2 5 10
+5 10 15
+10 14 15
+9 10 14
+2 9 10
+1 2 9
+1 2 7
+1 7 8
+7 8 11
+9 14 16
+6 9 16
+1 6 9
+1 3 6
+1 3 8
+3 8 12
+8 11 12
Index: tests/Tesselations/heptan/heptan.xyz
===================================================================
--- tests/Tesselations/heptan/heptan.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/heptan/heptan.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,25 @@
+23
+	Created by molecuilder on Mon Jul 28 11:56:27 2008
+H	-0.000000727	-1.220059091	0.930454545	
+H	-0.000000727	-1.220059091	-0.849545455	
+H	-1.249200727	0.921940909	0.930454545	
+H	-1.249200727	0.921940909	-0.849545455	
+H	1.249199273	0.921940909	-0.849545455	
+H	1.249199273	0.921940909	0.930454545	
+H	-2.498500727	-1.220059091	-0.849545455	
+H	-2.498500727	-1.220059091	0.930454545	
+H	2.498499273	-1.220059091	0.930454545	
+H	2.498499273	-1.220059091	-0.849545455	
+H	-4.637700727	-0.336759091	0.040454545	
+H	-3.747700727	0.921940909	0.930454545	
+H	-3.747700727	0.921940909	-0.849545455	
+H	4.637703273	-0.336759091	0.040454545	
+H	3.747703273	0.921940909	-0.849545455	
+H	3.747703273	0.921940909	0.930454545	
+C	-0.000000727	-0.590759091	0.040454545	
+C	-1.249200727	0.292640909	0.040454545	
+C	1.249199273	0.292640909	0.040454545	
+C	-2.498500727	-0.590759091	0.040454545	
+C	2.498499273	-0.590759091	0.040454545	
+C	-3.747700727	0.292640909	0.040454545	
+C	3.747703273	0.292640909	0.040454545	
Index: tests/Tesselations/isoleucine.test
===================================================================
--- tests/Tesselations/isoleucine.test	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/isoleucine.test	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,10 @@
+#! /bin/sh
+
+# Test a simple simulation: 
+
+. ./defs || exit 1
+set -e
+
+for radius in 1.5 2 2.5 3 3.5 4 25; do
+  Tesselation_run 0 $radius
+done
Index: tests/Tesselations/isoleucine/1.5/NonConvexEnvelope-isoleucine.dat
===================================================================
--- tests/Tesselations/isoleucine/1.5/NonConvexEnvelope-isoleucine.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/isoleucine/1.5/NonConvexEnvelope-isoleucine.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,90 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="isoleucine", N=22, E=64, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0.3772 -0.3291 -0.6807 9
+-0.7998 0.4009 -0.0307 6
+1.6687 0.1728 -0.0881 12
+0.2541 -1.7722 -0.4353 1
+-2.111 -0.1087 -0.6323 7
+-0.7939 0.1376 1.4765 9
+2.1353 -0.3658 0.8877 5
+2.3008 1.2182 -0.6443 2
+-3.2881 0.6214 0.0177 12
+0.373 -0.1415 -1.7544 2
+-0.7085 1.4717 -0.2128 4
+0.2625 -1.8979 0.5658 5
+-0.6641 -2.0432 -0.7539 0
+-2.1153 0.079 -1.706 2
+-2.2024 -1.1795 -0.4502 3
+0.1403 0.5006 1.9051 8
+-1.6324 0.6577 1.9395 4
+-0.8852 -0.9332 1.6585 3
+3.1295 1.5403 -0.2641 1
+-3.2838 0.4338 1.0914 5
+-3.1968 1.6922 -0.1644 3
+-4.2222 0.2583 -0.4109 5
+
+3 8 19
+3 8 19
+3 7 19
+3 7 19
+3 7 16
+3 7 16
+3 7 12
+1 3 12
+1 3 16
+1 12 16
+7 12 16
+7 12 16
+12 16 18
+3 8 10
+1 3 10
+1 4 10
+1 3 4
+3 4 7
+4 7 12
+4 10 13
+2 3 16
+2 11 16
+2 3 11
+10 13 14
+13 14 15
+6 16 18
+6 16 17
+6 16 17
+6 11 17
+6 11 16
+6 17 18
+4 12 13
+12 13 18
+13 15 18
+5 14 15
+5 15 22
+5 14 22
+1 3 8
+1 8 10
+1 10 11
+1 3 11
+17 18 20
+6 18 20
+5 6 18
+5 15 18
+5 15 20
+5 6 20
+10 11 14
+11 14 21
+9 14 21
+9 21 22
+9 21 22
+9 14 22
+9 20 21
+9 20 22
+9 20 22
+9 15 22
+9 15 20
+17 20 21
+9 17 21
+9 11 21
+2 9 11
+2 11 17
+2 9 17
Index: tests/Tesselations/isoleucine/2.5/NonConvexEnvelope-isoleucine.dat
===================================================================
--- tests/Tesselations/isoleucine/2.5/NonConvexEnvelope-isoleucine.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/isoleucine/2.5/NonConvexEnvelope-isoleucine.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,51 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="isoleucine", N=17, E=30, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+1.6687 0.1728 -0.0881 5
+0.2541 -1.7722 -0.4353 1
+2.1353 -0.3658 0.8877 1
+2.3008 1.2182 -0.6443 2
+0.373 -0.1415 -1.7544 2
+-0.7085 1.4717 -0.2128 2
+0.2625 -1.8979 0.5658 0
+-0.6641 -2.0432 -0.7539 0
+-2.1153 0.079 -1.706 1
+-2.2024 -1.1795 -0.4502 2
+0.1403 0.5006 1.9051 1
+-1.6324 0.6577 1.9395 1
+-0.8852 -0.9332 1.6585 0
+3.1295 1.5403 -0.2641 1
+-3.2838 0.4338 1.0914 1
+-3.1968 1.6922 -0.1644 0
+-4.2222 0.2583 -0.4109 0
+
+1 3 14
+1 4 14
+1 4 5
+1 2 5
+1 2 3
+2 3 7
+2 5 8
+5 8 9
+8 9 10
+9 10 17
+2 7 8
+7 8 13
+8 10 13
+10 13 15
+10 15 17
+12 13 15
+11 12 13
+3 11 13
+3 7 13
+9 16 17
+6 9 16
+5 6 9
+4 5 6
+6 12 16
+6 11 12
+12 15 16
+4 6 11
+4 11 14
+3 11 14
+15 16 17
Index: tests/Tesselations/isoleucine/2/NonConvexEnvelope-isoleucine.dat
===================================================================
--- tests/Tesselations/isoleucine/2/NonConvexEnvelope-isoleucine.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/isoleucine/2/NonConvexEnvelope-isoleucine.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,58 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="isoleucine", N=18, E=36, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0.3772 -0.3291 -0.6807 3
+1.6687 0.1728 -0.0881 10
+0.2541 -1.7722 -0.4353 1
+2.1353 -0.3658 0.8877 2
+2.3008 1.2182 -0.6443 5
+0.373 -0.1415 -1.7544 2
+-0.7085 1.4717 -0.2128 3
+0.2625 -1.8979 0.5658 1
+-0.6641 -2.0432 -0.7539 0
+-2.1153 0.079 -1.706 1
+-2.2024 -1.1795 -0.4502 2
+0.1403 0.5006 1.9051 4
+-1.6324 0.6577 1.9395 1
+-0.8852 -0.9332 1.6585 0
+3.1295 1.5403 -0.2641 2
+-3.2838 0.4338 1.0914 1
+-3.1968 1.6922 -0.1644 0
+-4.2222 0.2583 -0.4109 0
+
+2 4 15
+2 4 15
+2 5 15
+2 5 15
+2 4 12
+2 5 12
+2 5 12
+2 5 7
+2 7 12
+2 5 6
+1 2 6
+1 3 6
+1 2 3
+2 3 4
+3 4 8
+3 6 9
+6 9 10
+9 10 11
+10 11 18
+7 12 13
+7 13 17
+13 16 17
+16 17 18
+3 8 9
+8 9 14
+9 11 14
+11 14 16
+13 14 16
+11 16 18
+12 13 14
+8 12 14
+4 8 12
+10 17 18
+7 10 17
+6 7 10
+5 6 7
Index: tests/Tesselations/isoleucine/25/NonConvexEnvelope-isoleucine.dat
===================================================================
--- tests/Tesselations/isoleucine/25/NonConvexEnvelope-isoleucine.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/isoleucine/25/NonConvexEnvelope-isoleucine.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,48 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="isoleucine", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0.2541 -1.7722 -0.4353 0
+2.1353 -0.3658 0.8877 0
+2.3008 1.2182 -0.6443 0
+0.373 -0.1415 -1.7544 0
+-0.7085 1.4717 -0.2128 2
+0.2625 -1.8979 0.5658 0
+-0.6641 -2.0432 -0.7539 0
+-2.1153 0.079 -1.706 2
+-2.2024 -1.1795 -0.4502 2
+0.1403 0.5006 1.9051 0
+-1.6324 0.6577 1.9395 1
+-0.8852 -0.9332 1.6585 0
+3.1295 1.5403 -0.2641 0
+-3.2838 0.4338 1.0914 1
+-3.1968 1.6922 -0.1644 0
+-4.2222 0.2583 -0.4109 0
+
+1 2 13
+1 4 13
+1 4 7
+1 2 6
+1 6 7
+4 7 8
+7 8 9
+8 9 16
+3 4 13
+3 4 8
+3 5 8
+5 8 15
+3 5 13
+8 15 16
+6 7 12
+7 9 12
+9 12 14
+9 14 16
+11 12 14
+10 11 12
+2 10 12
+2 6 12
+2 10 13
+10 11 13
+5 11 13
+5 11 15
+11 14 15
+14 15 16
Index: tests/Tesselations/isoleucine/3.5/NonConvexEnvelope-isoleucine.dat
===================================================================
--- tests/Tesselations/isoleucine/3.5/NonConvexEnvelope-isoleucine.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/isoleucine/3.5/NonConvexEnvelope-isoleucine.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,51 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="isoleucine", N=17, E=30, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+1.6687 0.1728 -0.0881 5
+0.2541 -1.7722 -0.4353 1
+2.1353 -0.3658 0.8877 1
+2.3008 1.2182 -0.6443 1
+0.373 -0.1415 -1.7544 2
+-0.7085 1.4717 -0.2128 3
+0.2625 -1.8979 0.5658 0
+-0.6641 -2.0432 -0.7539 0
+-2.1153 0.079 -1.706 1
+-2.2024 -1.1795 -0.4502 2
+0.1403 0.5006 1.9051 1
+-1.6324 0.6577 1.9395 1
+-0.8852 -0.9332 1.6585 0
+3.1295 1.5403 -0.2641 1
+-3.2838 0.4338 1.0914 1
+-3.1968 1.6922 -0.1644 0
+-4.2222 0.2583 -0.4109 0
+
+1 3 14
+1 4 14
+1 4 5
+1 2 5
+1 2 3
+2 3 7
+2 5 8
+5 8 9
+8 9 10
+9 10 17
+2 7 8
+7 8 13
+8 10 13
+10 13 15
+10 15 17
+12 13 15
+11 12 13
+3 11 13
+3 7 13
+9 16 17
+6 9 16
+5 6 9
+4 5 6
+4 6 14
+6 11 14
+6 11 12
+6 12 16
+12 15 16
+15 16 17
+3 11 14
Index: tests/Tesselations/isoleucine/3/NonConvexEnvelope-isoleucine.dat
===================================================================
--- tests/Tesselations/isoleucine/3/NonConvexEnvelope-isoleucine.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/isoleucine/3/NonConvexEnvelope-isoleucine.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,51 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="isoleucine", N=17, E=30, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+1.6687 0.1728 -0.0881 5
+0.2541 -1.7722 -0.4353 1
+2.1353 -0.3658 0.8877 1
+2.3008 1.2182 -0.6443 1
+0.373 -0.1415 -1.7544 2
+-0.7085 1.4717 -0.2128 3
+0.2625 -1.8979 0.5658 0
+-0.6641 -2.0432 -0.7539 0
+-2.1153 0.079 -1.706 1
+-2.2024 -1.1795 -0.4502 2
+0.1403 0.5006 1.9051 1
+-1.6324 0.6577 1.9395 1
+-0.8852 -0.9332 1.6585 0
+3.1295 1.5403 -0.2641 1
+-3.2838 0.4338 1.0914 1
+-3.1968 1.6922 -0.1644 0
+-4.2222 0.2583 -0.4109 0
+
+1 3 14
+1 4 14
+1 4 5
+1 2 5
+1 2 3
+2 3 7
+2 5 8
+5 8 9
+8 9 10
+9 10 17
+2 7 8
+7 8 13
+8 10 13
+10 13 15
+10 15 17
+12 13 15
+11 12 13
+3 11 13
+3 7 13
+9 16 17
+6 9 16
+5 6 9
+4 5 6
+3 11 14
+6 11 14
+4 6 14
+6 11 12
+6 12 16
+12 15 16
+15 16 17
Index: tests/Tesselations/isoleucine/4/NonConvexEnvelope-isoleucine.dat
===================================================================
--- tests/Tesselations/isoleucine/4/NonConvexEnvelope-isoleucine.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/isoleucine/4/NonConvexEnvelope-isoleucine.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,51 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="isoleucine", N=17, E=30, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+1.6687 0.1728 -0.0881 5
+0.2541 -1.7722 -0.4353 1
+2.1353 -0.3658 0.8877 1
+2.3008 1.2182 -0.6443 1
+0.373 -0.1415 -1.7544 2
+-0.7085 1.4717 -0.2128 3
+0.2625 -1.8979 0.5658 0
+-0.6641 -2.0432 -0.7539 0
+-2.1153 0.079 -1.706 1
+-2.2024 -1.1795 -0.4502 2
+0.1403 0.5006 1.9051 1
+-1.6324 0.6577 1.9395 1
+-0.8852 -0.9332 1.6585 0
+3.1295 1.5403 -0.2641 1
+-3.2838 0.4338 1.0914 1
+-3.1968 1.6922 -0.1644 0
+-4.2222 0.2583 -0.4109 0
+
+1 3 14
+1 4 14
+1 4 5
+1 2 5
+1 2 3
+2 3 7
+2 5 8
+5 8 9
+8 9 10
+9 10 17
+2 7 8
+7 8 13
+8 10 13
+10 13 15
+10 15 17
+12 13 15
+11 12 13
+3 11 13
+3 7 13
+3 11 14
+6 11 14
+6 11 12
+6 12 16
+4 6 14
+12 15 16
+15 16 17
+4 5 6
+5 6 9
+6 9 16
+9 16 17
Index: tests/Tesselations/isoleucine/isoleucine.xyz
===================================================================
--- tests/Tesselations/isoleucine/isoleucine.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/isoleucine/isoleucine.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,24 @@
+22
+NCI NSC 46708 2-Amino-3-methylvaleric acid
+C    0.3772   -0.3291   -0.6807
+C   -0.7998    0.4009   -0.0307
+C    1.6687    0.1728   -0.0881
+N    0.2541   -1.7722   -0.4353
+C   -2.1110   -0.1087   -0.6323
+C   -0.7939    0.1376    1.4765
+O    2.1353   -0.3658    0.8877
+O    2.3008    1.2182   -0.6443
+C   -3.2881    0.6214    0.0177
+H    0.3730   -0.1415   -1.7544
+H   -0.7085    1.4717   -0.2128
+H    0.2625   -1.8979    0.5658
+H   -0.6641   -2.0432   -0.7539
+H   -2.1153    0.0790   -1.7060
+H   -2.2024   -1.1795   -0.4502
+H    0.1403    0.5006    1.9051
+H   -1.6324    0.6577    1.9395
+H   -0.8852   -0.9332    1.6585
+H    3.1295    1.5403   -0.2641
+H   -3.2838    0.4338    1.0914
+H   -3.1968    1.6922   -0.1644
+H   -4.2222    0.2583   -0.4109
Index: tests/Tesselations/neohexane.test
===================================================================
--- tests/Tesselations/neohexane.test	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/neohexane.test	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,10 @@
+#! /bin/sh
+
+# Test a simple simulation: 
+
+. ./defs || exit 1
+set -e
+
+for radius in 1.5 2 2.5 3 3.5 4 25; do
+  Tesselation_run 0 $radius
+done
Index: tests/Tesselations/neohexane/1.5/NonConvexEnvelope-neohexane.dat
===================================================================
--- tests/Tesselations/neohexane/1.5/NonConvexEnvelope-neohexane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/neohexane/1.5/NonConvexEnvelope-neohexane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,85 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="neohexane", N=19, E=62, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+-0.8142 0.0005 0.9062 12
+0.4079 1.2487 -0.8801 13
+1.684 0.0005 0.8681 12
+0.4079 -1.2498 -0.8786 12
+-2.0768 0 0.0421 9
+-0.8046 -0.8891 1.536 4
+-0.8046 0.8909 1.5349 4
+1.2882 1.2483 -1.5229 3
+-0.4916 1.2484 -1.4957 2
+0.4175 2.1391 -0.2514 3
+1.6936 0.8909 1.4968 3
+1.6936 -0.8891 1.4978 4
+2.5642 0.0001 0.2252 5
+-0.4916 -1.2501 -1.4943 2
+1.2882 -1.2501 -1.5214 4
+0.4175 -2.1394 -0.2488 4
+-2.0864 -0.8903 -0.5867 5
+-2.9571 0.0004 0.6849 5
+-2.0864 0.8896 -0.5877 4
+
+3 12 13
+3 12 13
+3 4 13
+4 13 15
+3 4 12
+4 12 16
+4 15 16
+4 15 16
+3 11 13
+3 11 13
+2 3 13
+2 8 13
+2 3 11
+2 10 11
+2 8 10
+2 8 10
+2 9 10
+2 8 9
+2 8 9
+2 9 14
+2 4 14
+4 14 15
+4 14 15
+2 4 15
+2 8 15
+3 11 12
+3 11 12
+3 7 11
+1 3 7
+1 6 7
+1 6 7
+1 7 18
+1 6 18
+1 3 6
+3 6 12
+4 14 16
+14 16 17
+4 16 17
+1 4 16
+1 6 16
+1 6 17
+1 4 17
+9 10 19
+2 10 19
+2 7 10
+1 2 7
+1 7 19
+1 2 19
+5 6 17
+5 17 18
+5 17 18
+5 6 18
+5 17 19
+5 18 19
+5 18 19
+5 7 19
+5 7 18
+14 17 19
+9 14 19
+8 13 15
+6 12 16
+7 10 11
Index: tests/Tesselations/neohexane/2.5/NonConvexEnvelope-neohexane.dat
===================================================================
--- tests/Tesselations/neohexane/2.5/NonConvexEnvelope-neohexane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/neohexane/2.5/NonConvexEnvelope-neohexane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="neohexane", N=14, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+-0.8046 -0.8891 1.536 1
+-0.8046 0.8909 1.5349 1
+1.2882 1.2483 -1.5229 0
+-0.4916 1.2484 -1.4957 0
+0.4175 2.1391 -0.2514 0
+1.6936 0.8909 1.4968 0
+1.6936 -0.8891 1.4978 0
+2.5642 0.0001 0.2252 0
+-0.4916 -1.2501 -1.4943 0
+1.2882 -1.2501 -1.5214 0
+0.4175 -2.1394 -0.2488 0
+-2.0864 -0.8903 -0.5867 1
+-2.9571 0.0004 0.6849 0
+-2.0864 0.8896 -0.5877 1
+
+6 7 8
+3 6 8
+3 5 6
+3 8 10
+3 9 10
+3 4 9
+4 9 14
+9 12 14
+12 13 14
+7 8 10
+7 10 11
+1 7 11
+1 11 12
+1 12 13
+9 11 12
+9 10 11
+1 2 13
+1 2 6
+1 6 7
+2 13 14
+2 5 14
+4 5 14
+3 4 5
+2 5 6
Index: tests/Tesselations/neohexane/2/NonConvexEnvelope-neohexane.dat
===================================================================
--- tests/Tesselations/neohexane/2/NonConvexEnvelope-neohexane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/neohexane/2/NonConvexEnvelope-neohexane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="neohexane", N=14, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+-0.8046 -0.8891 1.536 1
+-0.8046 0.8909 1.5349 1
+1.2882 1.2483 -1.5229 0
+-0.4916 1.2484 -1.4957 0
+0.4175 2.1391 -0.2514 0
+1.6936 0.8909 1.4968 0
+1.6936 -0.8891 1.4978 0
+2.5642 0.0001 0.2252 0
+-0.4916 -1.2501 -1.4943 0
+1.2882 -1.2501 -1.5214 0
+0.4175 -2.1394 -0.2488 0
+-2.0864 -0.8903 -0.5867 1
+-2.9571 0.0004 0.6849 0
+-2.0864 0.8896 -0.5877 1
+
+6 7 8
+3 6 8
+3 5 6
+7 8 10
+7 10 11
+9 10 11
+9 11 12
+1 11 12
+1 12 13
+1 7 11
+1 2 13
+1 2 6
+1 6 7
+2 13 14
+2 5 14
+4 5 14
+3 4 5
+2 5 6
+3 4 9
+3 9 10
+4 9 14
+9 12 14
+12 13 14
+3 8 10
Index: tests/Tesselations/neohexane/25/NonConvexEnvelope-neohexane.dat
===================================================================
--- tests/Tesselations/neohexane/25/NonConvexEnvelope-neohexane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/neohexane/25/NonConvexEnvelope-neohexane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="neohexane", N=14, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+-0.8046 -0.8891 1.536 1
+-0.8046 0.8909 1.5349 1
+1.2882 1.2483 -1.5229 0
+-0.4916 1.2484 -1.4957 0
+0.4175 2.1391 -0.2514 0
+1.6936 0.8909 1.4968 0
+1.6936 -0.8891 1.4978 0
+2.5642 0.0001 0.2252 0
+-0.4916 -1.2501 -1.4943 0
+1.2882 -1.2501 -1.5214 0
+0.4175 -2.1394 -0.2488 0
+-2.0864 -0.8903 -0.5867 1
+-2.9571 0.0004 0.6849 0
+-2.0864 0.8896 -0.5877 1
+
+6 7 8
+7 8 10
+7 10 11
+3 8 10
+3 6 8
+3 5 6
+3 9 10
+3 4 9
+4 9 14
+9 12 14
+12 13 14
+1 7 11
+1 11 12
+1 12 13
+9 11 12
+9 10 11
+1 6 7
+1 2 6
+1 2 13
+2 5 6
+2 5 14
+2 13 14
+4 5 14
+3 4 5
Index: tests/Tesselations/neohexane/3.5/NonConvexEnvelope-neohexane.dat
===================================================================
--- tests/Tesselations/neohexane/3.5/NonConvexEnvelope-neohexane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/neohexane/3.5/NonConvexEnvelope-neohexane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="neohexane", N=14, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+-0.8046 -0.8891 1.536 1
+-0.8046 0.8909 1.5349 1
+1.2882 1.2483 -1.5229 0
+-0.4916 1.2484 -1.4957 0
+0.4175 2.1391 -0.2514 0
+1.6936 0.8909 1.4968 0
+1.6936 -0.8891 1.4978 0
+2.5642 0.0001 0.2252 0
+-0.4916 -1.2501 -1.4943 0
+1.2882 -1.2501 -1.5214 0
+0.4175 -2.1394 -0.2488 0
+-2.0864 -0.8903 -0.5867 1
+-2.9571 0.0004 0.6849 0
+-2.0864 0.8896 -0.5877 1
+
+6 7 8
+3 6 8
+3 5 6
+3 8 10
+3 9 10
+3 4 9
+4 9 14
+9 12 14
+12 13 14
+7 8 10
+7 10 11
+1 7 11
+1 11 12
+1 12 13
+9 11 12
+9 10 11
+1 2 13
+1 2 6
+1 6 7
+2 13 14
+2 5 14
+4 5 14
+3 4 5
+2 5 6
Index: tests/Tesselations/neohexane/3/NonConvexEnvelope-neohexane.dat
===================================================================
--- tests/Tesselations/neohexane/3/NonConvexEnvelope-neohexane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/neohexane/3/NonConvexEnvelope-neohexane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="neohexane", N=14, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+-0.8046 -0.8891 1.536 1
+-0.8046 0.8909 1.5349 1
+1.2882 1.2483 -1.5229 0
+-0.4916 1.2484 -1.4957 0
+0.4175 2.1391 -0.2514 0
+1.6936 0.8909 1.4968 0
+1.6936 -0.8891 1.4978 0
+2.5642 0.0001 0.2252 0
+-0.4916 -1.2501 -1.4943 0
+1.2882 -1.2501 -1.5214 0
+0.4175 -2.1394 -0.2488 0
+-2.0864 -0.8903 -0.5867 1
+-2.9571 0.0004 0.6849 0
+-2.0864 0.8896 -0.5877 1
+
+6 7 8
+3 6 8
+3 5 6
+3 8 10
+3 9 10
+3 4 9
+4 9 14
+9 12 14
+12 13 14
+7 8 10
+7 10 11
+1 7 11
+1 11 12
+1 12 13
+9 11 12
+9 10 11
+1 2 13
+1 2 6
+1 6 7
+2 13 14
+2 5 14
+4 5 14
+3 4 5
+2 5 6
Index: tests/Tesselations/neohexane/4/NonConvexEnvelope-neohexane.dat
===================================================================
--- tests/Tesselations/neohexane/4/NonConvexEnvelope-neohexane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/neohexane/4/NonConvexEnvelope-neohexane.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="neohexane", N=14, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+-0.8046 -0.8891 1.536 1
+-0.8046 0.8909 1.5349 1
+1.2882 1.2483 -1.5229 0
+-0.4916 1.2484 -1.4957 0
+0.4175 2.1391 -0.2514 0
+1.6936 0.8909 1.4968 0
+1.6936 -0.8891 1.4978 0
+2.5642 0.0001 0.2252 0
+-0.4916 -1.2501 -1.4943 0
+1.2882 -1.2501 -1.5214 0
+0.4175 -2.1394 -0.2488 0
+-2.0864 -0.8903 -0.5867 1
+-2.9571 0.0004 0.6849 0
+-2.0864 0.8896 -0.5877 1
+
+6 7 8
+3 6 8
+3 5 6
+3 8 10
+3 9 10
+3 4 9
+4 9 14
+9 12 14
+12 13 14
+7 8 10
+7 10 11
+1 7 11
+1 11 12
+1 12 13
+9 11 12
+9 10 11
+1 2 13
+1 2 6
+1 6 7
+2 13 14
+2 5 14
+4 5 14
+3 4 5
+2 5 6
Index: tests/Tesselations/neohexane/neohexane.xyz
===================================================================
--- tests/Tesselations/neohexane/neohexane.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/neohexane/neohexane.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,22 @@
+20
+NCI NSC 74126 2, 2-Dimethylbutane
+C    0.4214    0.0000    0.0039
+C   -0.8142    0.0005    0.9062
+C    0.4079    1.2487   -0.8801
+C    1.6840    0.0005    0.8681
+C    0.4079   -1.2498   -0.8786
+C   -2.0768    0.0000    0.0421
+H   -0.8046   -0.8891    1.5360
+H   -0.8046    0.8909    1.5349
+H    1.2882    1.2483   -1.5229
+H   -0.4916    1.2484   -1.4957
+H    0.4175    2.1391   -0.2514
+H    1.6936    0.8909    1.4968
+H    1.6936   -0.8891    1.4978
+H    2.5642    0.0001    0.2252
+H   -0.4916   -1.2501   -1.4943
+H    1.2882   -1.2501   -1.5214
+H    0.4175   -2.1394   -0.2488
+H   -2.0864   -0.8903   -0.5867
+H   -2.9571    0.0004    0.6849
+H   -2.0864    0.8896   -0.5877
Index: tests/Tesselations/proline.test
===================================================================
--- tests/Tesselations/proline.test	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/proline.test	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,10 @@
+#! /bin/sh
+
+# Test a simple simulation: 
+
+. ./defs || exit 1
+set -e
+
+for radius in 1.5 2 2.5 3 3.5 4 25; do
+  Tesselation_run 0 $radius
+done
Index: tests/Tesselations/proline/1.5/NonConvexEnvelope-proline.dat
===================================================================
--- tests/Tesselations/proline/1.5/NonConvexEnvelope-proline.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/proline/1.5/NonConvexEnvelope-proline.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,75 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="proline", N=17, E=54, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+1.3674 0.1032 0.0298 8
+1.4766 0.8656 0.9607 2
+2.4457 -0.5467 -0.4355 2
+0.0194 -0.1227 -0.605 13
+-0.7011 -1.2899 0.0949 12
+-0.8273 1.0773 -0.4301 4
+-2.0129 -0.6836 0.6439 12
+-2.2114 0.5722 -0.2416 9
+3.31 -0.4048 -0.0256 1
+0.1409 -0.3437 -1.6655 3
+-0.9209 -2.0824 -0.6205 4
+-0.0914 -1.6754 0.9121 5
+-0.8161 1.5708 -1.3101 1
+-2.8421 -1.3797 0.5174 5
+-1.8997 -0.4032 1.6911 5
+-2.8243 1.3125 0.2726 5
+-2.6559 0.3014 -1.1993 5
+
+1 3 9
+1 3 9
+1 2 9
+1 2 9
+1 3 10
+1 4 10
+4 10 13
+4 6 13
+1 4 6
+1 2 6
+1 2 4
+1 4 12
+1 4 12
+4 5 12
+4 5 12
+5 12 15
+5 7 15
+5 6 7
+4 5 6
+6 7 15
+5 11 12
+5 11 12
+5 11 14
+5 7 14
+5 7 12
+4 5 11
+4 10 11
+7 12 15
+7 14 15
+7 14 15
+7 15 16
+7 14 16
+2 4 6
+1 3 4
+3 4 10
+8 14 16
+8 16 17
+8 16 17
+8 13 17
+8 13 16
+8 14 17
+6 13 16
+6 8 15
+6 8 16
+8 15 16
+10 13 17
+4 10 17
+4 5 10
+5 10 11
+4 5 17
+5 7 11
+5 7 17
+7 11 14
+7 14 17
Index: tests/Tesselations/proline/2.5/NonConvexEnvelope-proline.dat
===================================================================
--- tests/Tesselations/proline/2.5/NonConvexEnvelope-proline.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/proline/2.5/NonConvexEnvelope-proline.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,39 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="proline", N=13, E=22, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+1.3674 0.1032 0.0298 4
+1.4766 0.8656 0.9607 1
+2.4457 -0.5467 -0.4355 2
+-0.8273 1.0773 -0.4301 2
+3.31 -0.4048 -0.0256 1
+0.1409 -0.3437 -1.6655 1
+-0.9209 -2.0824 -0.6205 0
+-0.0914 -1.6754 0.9121 1
+-0.8161 1.5708 -1.3101 1
+-2.8421 -1.3797 0.5174 0
+-1.8997 -0.4032 1.6911 1
+-2.8243 1.3125 0.2726 0
+-2.6559 0.3014 -1.1993 0
+
+1 3 5
+1 2 5
+1 2 9
+1 6 9
+1 3 6
+2 4 9
+4 9 12
+4 11 12
+2 4 11
+9 12 13
+2 8 11
+2 5 8
+3 5 8
+3 7 8
+3 6 7
+6 9 13
+6 7 13
+7 10 13
+10 12 13
+10 11 12
+8 10 11
+7 8 10
Index: tests/Tesselations/proline/2/NonConvexEnvelope-proline.dat
===================================================================
--- tests/Tesselations/proline/2/NonConvexEnvelope-proline.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/proline/2/NonConvexEnvelope-proline.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,41 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="proline", N=13, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+1.3674 0.1032 0.0298 7
+1.4766 0.8656 0.9607 2
+2.4457 -0.5467 -0.4355 2
+-0.8273 1.0773 -0.4301 2
+3.31 -0.4048 -0.0256 1
+0.1409 -0.3437 -1.6655 1
+-0.9209 -2.0824 -0.6205 0
+-0.0914 -1.6754 0.9121 1
+-0.8161 1.5708 -1.3101 1
+-2.8421 -1.3797 0.5174 0
+-1.8997 -0.4032 1.6911 1
+-2.8243 1.3125 0.2726 0
+-2.6559 0.3014 -1.1993 0
+
+1 3 5
+1 3 5
+1 2 5
+1 2 5
+1 3 8
+1 2 8
+1 3 6
+1 6 9
+1 2 9
+2 4 9
+4 9 12
+4 11 12
+2 4 11
+9 12 13
+2 8 11
+6 9 13
+6 7 13
+7 10 13
+10 12 13
+10 11 12
+3 7 8
+3 6 7
+8 10 11
+7 8 10
Index: tests/Tesselations/proline/25/NonConvexEnvelope-proline.dat
===================================================================
--- tests/Tesselations/proline/25/NonConvexEnvelope-proline.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/proline/25/NonConvexEnvelope-proline.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,33 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="proline", N=11, E=18, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+1.4766 0.8656 0.9607 0
+2.4457 -0.5467 -0.4355 0
+3.31 -0.4048 -0.0256 0
+0.1409 -0.3437 -1.6655 0
+-0.9209 -2.0824 -0.6205 0
+-0.0914 -1.6754 0.9121 0
+-0.8161 1.5708 -1.3101 0
+-2.8421 -1.3797 0.5174 0
+-1.8997 -0.4032 1.6911 0
+-2.8243 1.3125 0.2726 0
+-2.6559 0.3014 -1.1993 0
+
+1 3 6
+1 6 9
+6 8 9
+5 6 8
+3 5 6
+2 3 5
+2 4 5
+4 5 11
+5 8 11
+4 7 11
+3 4 7
+2 3 4
+1 3 7
+1 7 10
+1 9 10
+7 10 11
+8 10 11
+8 9 10
Index: tests/Tesselations/proline/3.5/NonConvexEnvelope-proline.dat
===================================================================
--- tests/Tesselations/proline/3.5/NonConvexEnvelope-proline.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/proline/3.5/NonConvexEnvelope-proline.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,39 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="proline", N=13, E=22, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+1.3674 0.1032 0.0298 4
+1.4766 0.8656 0.9607 2
+2.4457 -0.5467 -0.4355 2
+-0.8273 1.0773 -0.4301 3
+3.31 -0.4048 -0.0256 1
+0.1409 -0.3437 -1.6655 0
+-0.9209 -2.0824 -0.6205 0
+-0.0914 -1.6754 0.9121 1
+-0.8161 1.5708 -1.3101 2
+-2.8421 -1.3797 0.5174 0
+-1.8997 -0.4032 1.6911 0
+-2.8243 1.3125 0.2726 1
+-2.6559 0.3014 -1.1993 0
+
+2 5 8
+2 8 11
+3 5 8
+3 7 8
+3 6 7
+2 11 12
+2 4 12
+4 9 12
+2 4 9
+1 2 9
+1 2 5
+1 3 5
+1 3 9
+3 6 9
+9 12 13
+6 9 13
+6 7 13
+7 10 13
+10 12 13
+10 11 12
+8 10 11
+7 8 10
Index: tests/Tesselations/proline/3/NonConvexEnvelope-proline.dat
===================================================================
--- tests/Tesselations/proline/3/NonConvexEnvelope-proline.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/proline/3/NonConvexEnvelope-proline.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,39 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="proline", N=13, E=22, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+1.3674 0.1032 0.0298 4
+1.4766 0.8656 0.9607 1
+2.4457 -0.5467 -0.4355 2
+-0.8273 1.0773 -0.4301 2
+3.31 -0.4048 -0.0256 1
+0.1409 -0.3437 -1.6655 1
+-0.9209 -2.0824 -0.6205 0
+-0.0914 -1.6754 0.9121 1
+-0.8161 1.5708 -1.3101 1
+-2.8421 -1.3797 0.5174 0
+-1.8997 -0.4032 1.6911 1
+-2.8243 1.3125 0.2726 0
+-2.6559 0.3014 -1.1993 0
+
+1 3 5
+1 2 5
+1 2 9
+1 6 9
+1 3 6
+2 4 9
+4 9 12
+4 11 12
+2 4 11
+9 12 13
+6 9 13
+6 7 13
+7 10 13
+2 8 11
+2 5 8
+3 5 8
+3 7 8
+3 6 7
+10 12 13
+10 11 12
+8 10 11
+7 8 10
Index: tests/Tesselations/proline/4/NonConvexEnvelope-proline.dat
===================================================================
--- tests/Tesselations/proline/4/NonConvexEnvelope-proline.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/proline/4/NonConvexEnvelope-proline.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,39 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="proline", N=13, E=22, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+1.3674 0.1032 0.0298 4
+1.4766 0.8656 0.9607 2
+2.4457 -0.5467 -0.4355 2
+-0.8273 1.0773 -0.4301 3
+3.31 -0.4048 -0.0256 1
+0.1409 -0.3437 -1.6655 0
+-0.9209 -2.0824 -0.6205 0
+-0.0914 -1.6754 0.9121 1
+-0.8161 1.5708 -1.3101 2
+-2.8421 -1.3797 0.5174 0
+-1.8997 -0.4032 1.6911 0
+-2.8243 1.3125 0.2726 1
+-2.6559 0.3014 -1.1993 0
+
+2 5 8
+2 8 11
+3 5 8
+3 7 8
+3 6 7
+2 11 12
+2 4 12
+4 9 12
+2 4 9
+1 2 9
+1 2 5
+1 3 5
+1 3 9
+3 6 9
+8 10 11
+7 8 10
+6 7 13
+7 10 13
+6 9 13
+9 12 13
+10 12 13
+10 11 12
Index: tests/Tesselations/proline/proline.xyz
===================================================================
--- tests/Tesselations/proline/proline.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/proline/proline.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,19 @@
+17
+NCI NSC 46703 2-Pyrrolidinecarboxylic acid, (S)-
+C    1.3674    0.1032    0.0298
+O    1.4766    0.8656    0.9607
+O    2.4457   -0.5467   -0.4355
+C    0.0194   -0.1227   -0.6050
+C   -0.7011   -1.2899    0.0949
+N   -0.8273    1.0773   -0.4301
+C   -2.0129   -0.6836    0.6439
+C   -2.2114    0.5722   -0.2416
+H    3.3100   -0.4048   -0.0256
+H    0.1409   -0.3437   -1.6655
+H   -0.9209   -2.0824   -0.6205
+H   -0.0914   -1.6754    0.9121
+H   -0.8161    1.5708   -1.3101
+H   -2.8421   -1.3797    0.5174
+H   -1.8997   -0.4032    1.6911
+H   -2.8243    1.3125    0.2726
+H   -2.6559    0.3014   -1.1993
Index: tests/Tesselations/putrescine.test
===================================================================
--- tests/Tesselations/putrescine.test	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/putrescine.test	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,10 @@
+#! /bin/sh
+
+# Test a simple simulation: 
+
+. ./defs || exit 1
+set -e
+
+for radius in 1.5 2 2.5 3 3.5 4 25; do
+  Tesselation_run 0 $radius
+done
Index: tests/Tesselations/putrescine/1.5/NonConvexEnvelope-putrescine.dat
===================================================================
--- tests/Tesselations/putrescine/1.5/NonConvexEnvelope-putrescine.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/putrescine/1.5/NonConvexEnvelope-putrescine.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,62 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="putrescine", N=18, E=40, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0 0 0 1
+-1.44 0.14 0.04 3
+-1.82 1.58 0.34 10
+-3.32 1.74 0.64 10
+-4.02 2.68 -0.34 3
+-5.36 2.98 0.12 1
+0.3728 0.5922 -0.7144 0
+0.2371 -0.9511 -0.198 0
+-1.8305 -0.4915 0.8105 2
+-1.8489 -0.1433 -0.9073 1
+-1.5967 2.1641 -0.5283 3
+-1.2621 1.9127 1.1903 3
+-3.4106 2.166 1.6173 3
+-3.785 0.778 0.5832 3
+-4.0792 2.2039 -1.2964 1
+-3.4614 3.5894 -0.4167 2
+-5.8857 2.1323 0.1908 0
+-5.8057 3.5953 -0.5302 0
+
+7 8 10
+7 10 11
+8 9 10
+9 10 14
+1 8 9
+1 2 9
+2 9 12
+1 2 12
+3 9 12
+3 4 12
+4 12 13
+4 13 14
+4 9 14
+3 4 9
+1 7 8
+1 7 12
+7 11 12
+3 10 11
+3 4 11
+4 11 15
+3 4 14
+3 10 14
+4 14 15
+14 15 17
+15 17 18
+15 16 18
+11 15 16
+6 16 18
+5 6 16
+5 13 16
+5 6 13
+6 17 18
+6 13 17
+13 14 17
+4 13 16
+3 4 13
+3 12 13
+3 4 16
+3 11 16
+3 11 12
Index: tests/Tesselations/putrescine/2.5/NonConvexEnvelope-putrescine.dat
===================================================================
--- tests/Tesselations/putrescine/2.5/NonConvexEnvelope-putrescine.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/putrescine/2.5/NonConvexEnvelope-putrescine.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="putrescine", N=14, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0 0 0 1
+-5.36 2.98 0.12 1
+0.3728 0.5922 -0.7144 0
+0.2371 -0.9511 -0.198 0
+-1.8305 -0.4915 0.8105 1
+-1.8489 -0.1433 -0.9073 1
+-1.5967 2.1641 -0.5283 1
+-1.2621 1.9127 1.1903 0
+-3.4106 2.166 1.6173 0
+-3.785 0.778 0.5832 1
+-4.0792 2.2039 -1.2964 1
+-3.4614 3.5894 -0.4167 1
+-5.8857 2.1323 0.1908 0
+-5.8057 3.5953 -0.5302 0
+
+3 4 6
+3 6 7
+6 7 11
+7 11 12
+11 12 14
+11 13 14
+10 11 13
+6 10 11
+5 6 10
+4 5 6
+7 8 12
+8 9 12
+2 9 12
+2 12 14
+3 7 8
+1 3 8
+1 3 4
+1 5 8
+1 4 5
+5 8 9
+5 9 10
+2 9 13
+9 10 13
+2 13 14
Index: tests/Tesselations/putrescine/2/NonConvexEnvelope-putrescine.dat
===================================================================
--- tests/Tesselations/putrescine/2/NonConvexEnvelope-putrescine.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/putrescine/2/NonConvexEnvelope-putrescine.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="putrescine", N=14, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0 0 0 1
+-5.36 2.98 0.12 1
+0.3728 0.5922 -0.7144 0
+0.2371 -0.9511 -0.198 0
+-1.8305 -0.4915 0.8105 1
+-1.8489 -0.1433 -0.9073 1
+-1.5967 2.1641 -0.5283 1
+-1.2621 1.9127 1.1903 0
+-3.4106 2.166 1.6173 0
+-3.785 0.778 0.5832 1
+-4.0792 2.2039 -1.2964 1
+-3.4614 3.5894 -0.4167 1
+-5.8857 2.1323 0.1908 0
+-5.8057 3.5953 -0.5302 0
+
+3 4 6
+3 6 7
+6 7 11
+7 11 12
+11 12 14
+11 13 14
+10 11 13
+6 10 11
+5 6 10
+4 5 6
+1 4 5
+1 5 8
+1 3 8
+3 7 8
+1 3 4
+5 8 9
+5 9 10
+7 8 12
+8 9 12
+2 9 12
+2 12 14
+2 9 13
+9 10 13
+2 13 14
Index: tests/Tesselations/putrescine/25/NonConvexEnvelope-putrescine.dat
===================================================================
--- tests/Tesselations/putrescine/25/NonConvexEnvelope-putrescine.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/putrescine/25/NonConvexEnvelope-putrescine.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="putrescine", N=14, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0 0 0 0
+-5.36 2.98 0.12 0
+0.3728 0.5922 -0.7144 0
+0.2371 -0.9511 -0.198 0
+-1.8305 -0.4915 0.8105 0
+-1.8489 -0.1433 -0.9073 1
+-1.5967 2.1641 -0.5283 1
+-1.2621 1.9127 1.1903 0
+-3.4106 2.166 1.6173 0
+-3.785 0.778 0.5832 1
+-4.0792 2.2039 -1.2964 1
+-3.4614 3.5894 -0.4167 0
+-5.8857 2.1323 0.1908 0
+-5.8057 3.5953 -0.5302 0
+
+3 4 6
+3 6 11
+3 7 11
+7 11 12
+11 12 14
+6 11 13
+11 13 14
+6 10 13
+5 6 10
+4 5 6
+7 8 12
+3 7 8
+8 9 12
+9 12 14
+2 9 14
+2 9 13
+2 13 14
+9 10 13
+5 9 10
+5 8 9
+4 5 8
+1 4 8
+1 3 8
+1 3 4
Index: tests/Tesselations/putrescine/3.5/NonConvexEnvelope-putrescine.dat
===================================================================
--- tests/Tesselations/putrescine/3.5/NonConvexEnvelope-putrescine.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/putrescine/3.5/NonConvexEnvelope-putrescine.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="putrescine", N=14, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0 0 0 1
+-5.36 2.98 0.12 1
+0.3728 0.5922 -0.7144 0
+0.2371 -0.9511 -0.198 0
+-1.8305 -0.4915 0.8105 1
+-1.8489 -0.1433 -0.9073 1
+-1.5967 2.1641 -0.5283 1
+-1.2621 1.9127 1.1903 0
+-3.4106 2.166 1.6173 0
+-3.785 0.778 0.5832 1
+-4.0792 2.2039 -1.2964 1
+-3.4614 3.5894 -0.4167 1
+-5.8857 2.1323 0.1908 0
+-5.8057 3.5953 -0.5302 0
+
+3 4 6
+3 6 7
+6 7 11
+7 11 12
+11 12 14
+11 13 14
+10 11 13
+6 10 11
+5 6 10
+4 5 6
+7 8 12
+8 9 12
+3 7 8
+2 9 12
+2 12 14
+1 3 8
+1 3 4
+1 5 8
+1 4 5
+5 8 9
+5 9 10
+9 10 13
+2 9 13
+2 13 14
Index: tests/Tesselations/putrescine/3/NonConvexEnvelope-putrescine.dat
===================================================================
--- tests/Tesselations/putrescine/3/NonConvexEnvelope-putrescine.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/putrescine/3/NonConvexEnvelope-putrescine.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="putrescine", N=14, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0 0 0 1
+-5.36 2.98 0.12 1
+0.3728 0.5922 -0.7144 0
+0.2371 -0.9511 -0.198 0
+-1.8305 -0.4915 0.8105 1
+-1.8489 -0.1433 -0.9073 1
+-1.5967 2.1641 -0.5283 1
+-1.2621 1.9127 1.1903 0
+-3.4106 2.166 1.6173 0
+-3.785 0.778 0.5832 1
+-4.0792 2.2039 -1.2964 1
+-3.4614 3.5894 -0.4167 1
+-5.8857 2.1323 0.1908 0
+-5.8057 3.5953 -0.5302 0
+
+3 4 6
+3 6 7
+6 7 11
+7 11 12
+11 12 14
+11 13 14
+10 11 13
+6 10 11
+5 6 10
+4 5 6
+7 8 12
+8 9 12
+2 9 12
+2 12 14
+3 7 8
+1 3 8
+1 3 4
+1 5 8
+1 4 5
+5 8 9
+5 9 10
+9 10 13
+2 9 13
+2 13 14
Index: tests/Tesselations/putrescine/4/NonConvexEnvelope-putrescine.dat
===================================================================
--- tests/Tesselations/putrescine/4/NonConvexEnvelope-putrescine.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/putrescine/4/NonConvexEnvelope-putrescine.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="putrescine", N=14, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0 0 0 1
+-5.36 2.98 0.12 1
+0.3728 0.5922 -0.7144 0
+0.2371 -0.9511 -0.198 0
+-1.8305 -0.4915 0.8105 1
+-1.8489 -0.1433 -0.9073 1
+-1.5967 2.1641 -0.5283 1
+-1.2621 1.9127 1.1903 0
+-3.4106 2.166 1.6173 0
+-3.785 0.778 0.5832 1
+-4.0792 2.2039 -1.2964 1
+-3.4614 3.5894 -0.4167 1
+-5.8857 2.1323 0.1908 0
+-5.8057 3.5953 -0.5302 0
+
+3 4 6
+3 6 7
+6 7 11
+7 11 12
+11 12 14
+11 13 14
+10 11 13
+6 10 11
+5 6 10
+4 5 6
+7 8 12
+8 9 12
+3 7 8
+2 9 12
+2 12 14
+1 3 8
+1 3 4
+1 5 8
+1 4 5
+5 8 9
+5 9 10
+9 10 13
+2 9 13
+2 13 14
Index: tests/Tesselations/putrescine/putrescine.xyz
===================================================================
--- tests/Tesselations/putrescine/putrescine.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/putrescine/putrescine.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,20 @@
+18
+NCI NSC 60545 NSC60545 1,4-butanediamine
+N    0.0000    0.0000    0.0000
+C   -1.4400    0.1400    0.0400
+C   -1.8200    1.5800    0.3400
+C   -3.3200    1.7400    0.6400
+C   -4.0200    2.6800   -0.3400
+N   -5.3600    2.9800    0.1200
+H    0.3728    0.5922   -0.7144
+H    0.2371   -0.9511   -0.1980
+H   -1.8305   -0.4915    0.8105
+H   -1.8489   -0.1433   -0.9073
+H   -1.5967    2.1641   -0.5283
+H   -1.2621    1.9127    1.1903
+H   -3.4106    2.1660    1.6173
+H   -3.7850    0.7780    0.5832
+H   -4.0792    2.2039   -1.2964
+H   -3.4614    3.5894   -0.4167
+H   -5.8857    2.1323    0.1908
+H   -5.8057    3.5953   -0.5302
Index: tests/Tesselations/tartaric_acid.test
===================================================================
--- tests/Tesselations/tartaric_acid.test	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/tartaric_acid.test	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,11 @@
+#! /bin/sh
+
+# Test a simple simulation: 
+
+. ./defs || exit 1
+set -e
+
+for radius in 1.5 2 2.5 3 3.5 4 25; do
+  Tesselation_run 0 $radius
+done
+
Index: tests/Tesselations/tartaric_acid/1.5/NonConvexEnvelope-tartaric_acid.dat
===================================================================
--- tests/Tesselations/tartaric_acid/1.5/NonConvexEnvelope-tartaric_acid.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/tartaric_acid/1.5/NonConvexEnvelope-tartaric_acid.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,64 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="tartaric_acid", N=16, E=44, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0.4795 0.2278 -0.5961 12
+-0.4795 0.2278 0.5961 12
+1.9014 0.2278 -0.0969 10
+0.2532 -0.939 -1.3895 5
+-1.9014 0.2278 0.0969 10
+-0.2532 -0.939 1.3894 5
+2.6448 -0.6784 -0.3905 3
+2.3422 1.2345 0.6738 4
+-2.6447 -0.6784 0.3905 2
+-2.3422 1.2345 -0.6738 3
+0.3069 1.1178 -1.2012 6
+-0.3069 1.1177 1.2013 6
+0.4163 -1.7017 -0.8178 1
+-0.4162 -1.7017 0.8178 1
+3.2546 1.2345 0.9941 3
+-3.2546 1.2345 -0.994 1
+
+3 7 15
+3 7 15
+3 8 15
+3 8 15
+3 8 12
+2 3 12
+2 6 12
+2 6 12
+2 3 6
+2 5 12
+2 5 6
+5 6 9
+6 9 14
+3 7 13
+1 3 13
+1 6 13
+1 3 6
+6 13 14
+3 8 11
+1 3 11
+1 4 11
+1 4 11
+1 5 11
+1 4 5
+5 10 11
+1 3 4
+3 4 7
+4 7 13
+5 10 16
+5 10 16
+5 9 16
+5 9 16
+5 9 14
+2 5 14
+2 4 14
+2 4 5
+4 13 14
+5 10 12
+2 10 12
+2 11 12
+2 10 11
+1 8 11
+1 11 12
+1 8 12
Index: tests/Tesselations/tartaric_acid/2.5/NonConvexEnvelope-tartaric_acid.dat
===================================================================
--- tests/Tesselations/tartaric_acid/2.5/NonConvexEnvelope-tartaric_acid.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/tartaric_acid/2.5/NonConvexEnvelope-tartaric_acid.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,46 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="tartaric_acid", N=14, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+1.9014 0.2278 -0.0969 7
+0.2532 -0.939 -1.3895 1
+-1.9014 0.2278 0.0969 7
+-0.2532 -0.939 1.3894 1
+2.6448 -0.6784 -0.3905 3
+2.3422 1.2345 0.6738 3
+-2.6447 -0.6784 0.3905 2
+-2.3422 1.2345 -0.6738 3
+0.3069 1.1178 -1.2012 2
+-0.3069 1.1177 1.2013 2
+0.4163 -1.7017 -0.8178 0
+-0.4162 -1.7017 0.8178 0
+3.2546 1.2345 0.9941 3
+-3.2546 1.2345 -0.994 2
+
+1 5 13
+1 5 13
+1 6 13
+1 6 13
+1 4 6
+1 4 5
+1 6 9
+4 5 12
+5 11 12
+4 6 10
+1 5 9
+2 5 9
+2 5 11
+6 9 10
+8 9 10
+3 8 10
+3 8 14
+3 8 14
+3 7 14
+3 7 14
+2 3 8
+2 3 7
+2 7 11
+7 11 12
+2 8 9
+3 7 10
+4 7 10
+4 7 12
Index: tests/Tesselations/tartaric_acid/2/NonConvexEnvelope-tartaric_acid.dat
===================================================================
--- tests/Tesselations/tartaric_acid/2/NonConvexEnvelope-tartaric_acid.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/tartaric_acid/2/NonConvexEnvelope-tartaric_acid.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,52 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="tartaric_acid", N=16, E=32, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0.4795 0.2278 -0.5961 3
+-0.4795 0.2278 0.5961 3
+1.9014 0.2278 -0.0969 8
+0.2532 -0.939 -1.3895 3
+-1.9014 0.2278 0.0969 8
+-0.2532 -0.939 1.3894 3
+2.6448 -0.6784 -0.3905 3
+2.3422 1.2345 0.6738 3
+-2.6447 -0.6784 0.3905 2
+-2.3422 1.2345 -0.6738 3
+0.3069 1.1178 -1.2012 2
+-0.3069 1.1177 1.2013 2
+0.4163 -1.7017 -0.8178 0
+-0.4162 -1.7017 0.8178 0
+3.2546 1.2345 0.9941 3
+-3.2546 1.2345 -0.994 2
+
+3 7 15
+3 7 15
+3 8 15
+3 8 15
+3 6 8
+6 8 12
+3 6 7
+6 7 14
+7 13 14
+3 8 11
+1 3 11
+1 4 11
+1 3 4
+3 4 7
+4 7 13
+8 11 12
+10 11 12
+5 10 12
+5 10 16
+5 10 16
+5 9 16
+5 9 16
+4 5 10
+4 10 11
+4 5 9
+4 9 13
+9 13 14
+2 5 12
+2 6 12
+2 5 6
+5 6 9
+6 9 14
Index: tests/Tesselations/tartaric_acid/25/NonConvexEnvelope-tartaric_acid.dat
===================================================================
--- tests/Tesselations/tartaric_acid/25/NonConvexEnvelope-tartaric_acid.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/tartaric_acid/25/NonConvexEnvelope-tartaric_acid.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,36 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="tartaric_acid", N=12, E=20, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+0.2532 -0.939 -1.3895 1
+-0.2532 -0.939 1.3894 1
+2.6448 -0.6784 -0.3905 1
+2.3422 1.2345 0.6738 1
+-2.6447 -0.6784 0.3905 1
+-2.3422 1.2345 -0.6738 1
+0.3069 1.1178 -1.2012 1
+-0.3069 1.1177 1.2013 1
+0.4163 -1.7017 -0.8178 0
+-0.4162 -1.7017 0.8178 0
+3.2546 1.2345 0.9941 0
+-3.2546 1.2345 -0.994 0
+
+3 7 11
+1 3 7
+1 7 12
+1 3 9
+1 5 12
+1 5 9
+5 9 10
+4 7 11
+4 6 7
+4 6 8
+4 8 11
+6 7 12
+6 8 12
+5 8 12
+2 5 8
+2 8 11
+2 5 10
+2 3 11
+2 3 10
+3 9 10
Index: tests/Tesselations/tartaric_acid/3.5/NonConvexEnvelope-tartaric_acid.dat
===================================================================
--- tests/Tesselations/tartaric_acid/3.5/NonConvexEnvelope-tartaric_acid.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/tartaric_acid/3.5/NonConvexEnvelope-tartaric_acid.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,46 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="tartaric_acid", N=14, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+1.9014 0.2278 -0.0969 4
+0.2532 -0.939 -1.3895 2
+-1.9014 0.2278 0.0969 3
+-0.2532 -0.939 1.3894 2
+2.6448 -0.6784 -0.3905 2
+2.3422 1.2345 0.6738 4
+-2.6447 -0.6784 0.3905 2
+-2.3422 1.2345 -0.6738 4
+0.3069 1.1178 -1.2012 4
+-0.3069 1.1177 1.2013 3
+0.4163 -1.7017 -0.8178 0
+-0.4162 -1.7017 0.8178 0
+3.2546 1.2345 0.9941 2
+-3.2546 1.2345 -0.994 2
+
+1 5 13
+1 6 13
+1 6 9
+1 5 9
+2 5 9
+2 5 11
+2 8 9
+2 8 14
+8 9 14
+8 9 14
+2 7 14
+2 7 11
+7 11 12
+6 9 10
+8 9 10
+3 8 10
+3 8 14
+3 7 14
+3 7 10
+4 7 10
+4 7 12
+4 6 10
+4 6 13
+6 10 13
+6 10 13
+4 5 13
+4 5 12
+5 11 12
Index: tests/Tesselations/tartaric_acid/3/NonConvexEnvelope-tartaric_acid.dat
===================================================================
--- tests/Tesselations/tartaric_acid/3/NonConvexEnvelope-tartaric_acid.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/tartaric_acid/3/NonConvexEnvelope-tartaric_acid.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="tartaric_acid", N=14, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+1.9014 0.2278 -0.0969 4
+0.2532 -0.939 -1.3895 2
+-1.9014 0.2278 0.0969 3
+-0.2532 -0.939 1.3894 2
+2.6448 -0.6784 -0.3905 2
+2.3422 1.2345 0.6738 2
+-2.6447 -0.6784 0.3905 2
+-2.3422 1.2345 -0.6738 2
+0.3069 1.1178 -1.2012 2
+-0.3069 1.1177 1.2013 2
+0.4163 -1.7017 -0.8178 0
+-0.4162 -1.7017 0.8178 0
+3.2546 1.2345 0.9941 1
+-3.2546 1.2345 -0.994 0
+
+1 5 13
+1 6 13
+1 6 9
+1 5 9
+2 5 9
+2 5 11
+6 9 10
+8 9 10
+3 8 10
+3 8 14
+3 7 14
+3 7 10
+4 7 10
+4 7 12
+2 8 9
+2 8 14
+2 7 14
+2 7 11
+7 11 12
+4 6 10
+4 6 13
+4 5 13
+4 5 12
+5 11 12
Index: tests/Tesselations/tartaric_acid/4/NonConvexEnvelope-tartaric_acid.dat
===================================================================
--- tests/Tesselations/tartaric_acid/4/NonConvexEnvelope-tartaric_acid.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/tartaric_acid/4/NonConvexEnvelope-tartaric_acid.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="tartaric_acid", N=14, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+1.9014 0.2278 -0.0969 4
+0.2532 -0.939 -1.3895 1
+-1.9014 0.2278 0.0969 3
+-0.2532 -0.939 1.3894 1
+2.6448 -0.6784 -0.3905 2
+2.3422 1.2345 0.6738 1
+-2.6447 -0.6784 0.3905 2
+-2.3422 1.2345 -0.6738 1
+0.3069 1.1178 -1.2012 2
+-0.3069 1.1177 1.2013 2
+0.4163 -1.7017 -0.8178 0
+-0.4162 -1.7017 0.8178 0
+3.2546 1.2345 0.9941 1
+-3.2546 1.2345 -0.994 0
+
+1 5 13
+1 6 13
+1 6 9
+1 5 9
+2 5 9
+2 5 11
+2 9 14
+8 9 14
+2 7 14
+2 7 11
+7 11 12
+8 9 10
+6 9 10
+6 10 13
+4 10 13
+4 5 13
+4 5 12
+5 11 12
+4 7 10
+3 7 10
+3 8 10
+3 8 14
+3 7 14
+4 7 12
Index: tests/Tesselations/tartaric_acid/tartaric_acid.xyz
===================================================================
--- tests/Tesselations/tartaric_acid/tartaric_acid.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/Tesselations/tartaric_acid/tartaric_acid.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,18 @@
+16
+NCI NSC 148314 Uvic acid
+C    0.4795    0.2278   -0.5961
+C   -0.4795    0.2278    0.5961
+C    1.9014    0.2278   -0.0969
+O    0.2532   -0.9390   -1.3895
+C   -1.9014    0.2278    0.0969
+O   -0.2532   -0.9390    1.3894
+O    2.6448   -0.6784   -0.3905
+O    2.3422    1.2345    0.6738
+O   -2.6447   -0.6784    0.3905
+O   -2.3422    1.2345   -0.6738
+H    0.3069    1.1178   -1.2012
+H   -0.3069    1.1177    1.2013
+H    0.4163   -1.7017   -0.8178
+H   -0.4162   -1.7017    0.8178
+H    3.2546    1.2345    0.9941
+H   -3.2546    1.2345   -0.9940
Index: tests/regression/Analysis/1/post/bin_output.csv
===================================================================
--- tests/regression/Analysis/1/post/bin_output.csv	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Analysis/1/post/bin_output.csv	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+BinStart	Count
+0	0
+0.5	62
+1	0
+1.5	0
+2	24
+2.5	63
+3	57
+3.5	121
+4	77
+4.5	81
+5	82
+5.5	74
+6	127
+6.5	168
+7	154
+7.5	152
+8	94
+8.5	105
+9	97
+9.5	100
+10	98
+10.5	64
+11	40
+11.5	47
+12	24
+12.5	6
+13	2
+13.5	3
+14	0
+14.5	0
+15	0
+15.5	0
+16	0
+16.5	0
+17	0
+17.5	0
+18	0
+18.5	0
+19	0
+19.5	0
+20	0
Index: tests/regression/Analysis/1/pre/test.conf
===================================================================
--- tests/regression/Analysis/1/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Analysis/1/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,165 @@
+# 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	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	62	1	1.0	3	3	1.00800000000	Hydrogen	H
+Ion_Type2	31	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	6.550000000	6.550000000	6.046000000	0 # molecule nr 0
+Ion_Type1_1	5.980000000	5.780000000	6.065000000	0 # molecule nr 1
+Ion_Type1_2	7.103000000	6.467000000	6.824000000	0 # molecule nr 2
+Ion_Type2_2	9.650000000	6.550000000	6.046000000	0 # molecule nr 3
+Ion_Type1_3	8.814000000	6.529000000	6.514000000	0 # molecule nr 4
+Ion_Type1_4	10.283000000	6.163000000	6.653000000	0 # molecule nr 5
+Ion_Type2_3	12.750000000	6.550000000	6.046000000	0 # molecule nr 6
+Ion_Type1_5	12.181000000	6.385000000	5.292000000	0 # molecule nr 7
+Ion_Type1_6	13.035000000	7.460000000	5.946000000	0 # molecule nr 8
+Ion_Type2_4	6.550000000	9.650000000	6.046000000	0 # molecule nr 9
+Ion_Type1_7	6.571000000	10.422000000	5.479000000	0 # molecule nr 10
+Ion_Type1_8	6.193000000	8.950000000	5.497000000	0 # molecule nr 11
+Ion_Type2_5	9.650000000	9.650000000	6.046000000	0 # molecule nr 12
+Ion_Type1_9	9.430000000	9.454000000	6.958000000	0 # molecule nr 13
+Ion_Type1_10	10.521000000	9.272000000	5.916000000	0 # molecule nr 14
+Ion_Type2_6	12.750000000	9.650000000	6.046000000	0 # molecule nr 15
+Ion_Type1_11	12.266000000	10.237000000	5.463000000	0 # molecule nr 16
+Ion_Type1_12	12.900000000	8.857000000	5.529000000	0 # molecule nr 17
+Ion_Type2_7	6.550000000	12.750000000	6.046000000	0 # molecule nr 18
+Ion_Type1_13	5.834000000	12.713000000	6.682000000	0 # molecule nr 19
+Ion_Type1_14	7.308000000	13.058000000	6.546000000	0 # molecule nr 20
+Ion_Type2_8	9.650000000	12.750000000	6.046000000	0 # molecule nr 21
+Ion_Type1_15	9.141000000	12.027000000	5.676000000	0 # molecule nr 22
+Ion_Type1_16	9.228000000	13.544000000	5.715000000	0 # molecule nr 23
+Ion_Type2_9	12.750000000	12.750000000	6.046000000	0 # molecule nr 24
+Ion_Type1_17	12.928000000	13.649000000	5.764000000	0 # molecule nr 25
+Ion_Type1_18	12.122000000	12.410000000	5.407000000	0 # molecule nr 26
+Ion_Type2_10	6.550000000	6.550000000	9.146000000	0 # molecule nr 27
+Ion_Type1_19	6.149000000	5.713000000	8.906000000	0 # molecule nr 28
+Ion_Type1_20	5.938000000	6.948000000	9.766000000	0 # molecule nr 29
+Ion_Type2_11	9.650000000	6.550000000	9.146000000	0 # molecule nr 30
+Ion_Type1_21	9.612000000	5.833000000	9.781000000	0 # molecule nr 31
+Ion_Type1_22	9.776000000	7.340000000	9.673000000	0 # molecule nr 32
+Ion_Type2_12	12.750000000	6.550000000	9.146000000	0 # molecule nr 33
+Ion_Type1_23	12.734000000	7.473000000	9.403000000	0 # molecule nr 34
+Ion_Type1_24	12.410000000	6.076000000	9.907000000	0 # molecule nr 35
+Ion_Type2_13	6.550000000	9.650000000	9.146000000	0 # molecule nr 36
+Ion_Type1_25	6.335000000	10.319000000	9.798000000	0 # molecule nr 37
+Ion_Type1_26	6.060000000	8.873000000	9.419000000	0 # molecule nr 38
+Ion_Type2_14	6.550000000	12.750000000	9.146000000	0 # molecule nr 39
+Ion_Type1_27	7.136000000	12.026000000	9.369000000	0 # molecule nr 40
+Ion_Type1_28	5.738000000	12.330000000	8.859000000	0 # molecule nr 41
+Ion_Type2_15	12.750000000	12.750000000	9.146000000	0 # molecule nr 42
+Ion_Type1_29	12.976000000	12.419000000	10.017000000	0 # molecule nr 43
+Ion_Type1_30	13.592000000	12.883000000	8.707000000	0 # molecule nr 44
+Ion_Type2_16	6.550000000	6.550000000	12.246000000	0 # molecule nr 45
+Ion_Type1_31	6.754000000	7.229000000	11.601000000	0 # molecule nr 46
+Ion_Type1_32	5.898000000	6.947000000	12.825000000	0 # molecule nr 47
+Ion_Type2_17	9.650000000	6.550000000	12.246000000	0 # molecule nr 48
+Ion_Type1_33	10.034000000	5.710000000	12.503000000	0 # molecule nr 49
+Ion_Type1_34	10.067000000	7.197000000	12.817000000	0 # molecule nr 50
+Ion_Type2_18	12.750000000	6.550000000	12.246000000	0 # molecule nr 51
+Ion_Type1_35	13.278000000	7.331000000	12.418000000	0 # molecule nr 52
+Ion_Type1_36	12.248000000	6.410000000	13.050000000	0 # molecule nr 53
+Ion_Type2_19	6.550000000	9.650000000	12.246000000	0 # molecule nr 54
+Ion_Type1_37	5.991000000	9.021000000	12.705000000	0 # molecule nr 55
+Ion_Type1_38	7.382000000	9.632000000	12.721000000	0 # molecule nr 56
+Ion_Type2_20	6.550000000	12.750000000	12.246000000	0 # molecule nr 57
+Ion_Type1_39	7.129000000	12.071000000	12.596000000	0 # molecule nr 58
+Ion_Type1_40	6.945000000	13.005000000	11.411000000	0 # molecule nr 59
+Ion_Type2_21	9.650000000	12.750000000	12.246000000	0 # molecule nr 60
+Ion_Type1_41	9.105000000	12.539000000	13.005000000	0 # molecule nr 61
+Ion_Type1_42	10.474000000	13.071000000	12.615000000	0 # molecule nr 62
+Ion_Type2_22	12.750000000	12.750000000	12.246000000	0 # molecule nr 63
+Ion_Type1_43	12.127000000	12.133000000	12.633000000	0 # molecule nr 64
+Ion_Type1_44	13.614000000	12.395000000	12.461000000	0 # molecule nr 65
+Ion_Type2_23	6.550000000	6.550000000	15.346000000	0 # molecule nr 66
+Ion_Type1_45	5.730000000	6.420000000	14.868000000	0 # molecule nr 67
+Ion_Type1_46	7.240000000	6.388000000	14.701000000	0 # molecule nr 68
+Ion_Type2_24	9.650000000	6.550000000	15.346000000	0 # molecule nr 69
+Ion_Type1_47	9.006000000	6.245000000	15.987000000	0 # molecule nr 70
+Ion_Type1_48	10.406000000	6.824000000	15.867000000	0 # molecule nr 71
+Ion_Type2_25	12.750000000	6.550000000	15.346000000	0 # molecule nr 72
+Ion_Type1_49	13.193000000	5.783000000	15.712000000	0 # molecule nr 73
+Ion_Type1_50	13.441000000	7.205000000	15.238000000	0 # molecule nr 74
+Ion_Type2_26	6.550000000	9.650000000	15.346000000	0 # molecule nr 75
+Ion_Type1_51	6.265000000	10.284000000	14.687000000	0 # molecule nr 76
+Ion_Type1_52	7.444000000	9.416000000	15.093000000	0 # molecule nr 77
+Ion_Type2_27	9.650000000	9.650000000	15.346000000	0 # molecule nr 78
+Ion_Type1_53	10.379000000	9.444000000	15.933000000	0 # molecule nr 79
+Ion_Type1_54	8.933000000	9.912000000	15.926000000	0 # molecule nr 80
+Ion_Type2_28	12.750000000	9.650000000	15.346000000	0 # molecule nr 81
+Ion_Type1_55	13.611000000	9.476000000	15.728000000	0 # molecule nr 82
+Ion_Type1_56	12.123000000	9.305000000	15.984000000	0 # molecule nr 83
+Ion_Type2_29	6.550000000	12.750000000	15.346000000	0 # molecule nr 84
+Ion_Type1_57	6.187000000	11.882000000	15.165000000	0 # molecule nr 85
+Ion_Type1_58	7.500000000	12.638000000	15.286000000	0 # molecule nr 86
+Ion_Type2_30	9.650000000	12.750000000	15.346000000	0 # molecule nr 87
+Ion_Type1_59	9.750000000	13.494000000	14.751000000	0 # molecule nr 88
+Ion_Type1_60	9.283000000	12.049000000	14.805000000	0 # molecule nr 89
+Ion_Type2_31	12.750000000	12.750000000	15.346000000	0 # molecule nr 90
+Ion_Type1_61	13.468000000	13.235000000	15.756000000	0 # molecule nr 91
+Ion_Type1_62	12.276000000	12.347000000	16.075000000	0 # molecule nr 92
Index: tests/regression/Analysis/2/post/bin_output-10.csv
===================================================================
--- tests/regression/Analysis/2/post/bin_output-10.csv	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Analysis/2/post/bin_output-10.csv	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,26 @@
+BinStart	Count
+0.5	62
+2	24
+2.5	63
+3	57
+3.5	121
+4	77
+4.5	81
+5	82
+5.5	74
+6	127
+6.5	168
+7	154
+7.5	152
+8	94
+8.5	105
+9	97
+9.5	100
+10	98
+10.5	64
+11	40
+11.5	47
+12	24
+12.5	6
+13	2
+13.5	3
Index: tests/regression/Analysis/2/post/bin_output-20.csv
===================================================================
--- tests/regression/Analysis/2/post/bin_output-20.csv	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Analysis/2/post/bin_output-20.csv	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,39 @@
+BinStart	Count
+0.5	62
+2	24
+2.5	63
+3	57
+3.5	121
+4	77
+4.5	81
+5	82
+5.5	74
+6	127
+6.5	168
+7	154
+7.5	152
+8	94
+8.5	105
+9	97
+9.5	100
+10	98
+10.5	64
+11	40
+11.5	47
+12	24
+12.5	6
+13	2
+13.5	3
+14	0
+14.5	0
+15	0
+15.5	0
+16	0
+16.5	0
+17	0
+17.5	0
+18	0
+18.5	0
+19	0
+19.5	0
+20	0
Index: tests/regression/Analysis/2/post/bin_output-5.csv
===================================================================
--- tests/regression/Analysis/2/post/bin_output-5.csv	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Analysis/2/post/bin_output-5.csv	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,29 @@
+BinStart	Count
+0	0
+0.5	62
+1	0
+1.5	0
+2	24
+2.5	63
+3	57
+3.5	121
+4	77
+4.5	81
+5	82
+5.5	74
+6	127
+6.5	168
+7	154
+7.5	152
+8	94
+8.5	105
+9	97
+9.5	100
+10	98
+10.5	64
+11	40
+11.5	47
+12	24
+12.5	6
+13	2
+13.5	3
Index: tests/regression/Analysis/2/pre/test.conf
===================================================================
--- tests/regression/Analysis/2/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Analysis/2/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,165 @@
+# 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	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	62	1	1.0	3	3	1.00800000000	Hydrogen	H
+Ion_Type2	31	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	6.550000000	6.550000000	6.046000000	0 # molecule nr 0
+Ion_Type1_1	5.980000000	5.780000000	6.065000000	0 # molecule nr 1
+Ion_Type1_2	7.103000000	6.467000000	6.824000000	0 # molecule nr 2
+Ion_Type2_2	9.650000000	6.550000000	6.046000000	0 # molecule nr 3
+Ion_Type1_3	8.814000000	6.529000000	6.514000000	0 # molecule nr 4
+Ion_Type1_4	10.283000000	6.163000000	6.653000000	0 # molecule nr 5
+Ion_Type2_3	12.750000000	6.550000000	6.046000000	0 # molecule nr 6
+Ion_Type1_5	12.181000000	6.385000000	5.292000000	0 # molecule nr 7
+Ion_Type1_6	13.035000000	7.460000000	5.946000000	0 # molecule nr 8
+Ion_Type2_4	6.550000000	9.650000000	6.046000000	0 # molecule nr 9
+Ion_Type1_7	6.571000000	10.422000000	5.479000000	0 # molecule nr 10
+Ion_Type1_8	6.193000000	8.950000000	5.497000000	0 # molecule nr 11
+Ion_Type2_5	9.650000000	9.650000000	6.046000000	0 # molecule nr 12
+Ion_Type1_9	9.430000000	9.454000000	6.958000000	0 # molecule nr 13
+Ion_Type1_10	10.521000000	9.272000000	5.916000000	0 # molecule nr 14
+Ion_Type2_6	12.750000000	9.650000000	6.046000000	0 # molecule nr 15
+Ion_Type1_11	12.266000000	10.237000000	5.463000000	0 # molecule nr 16
+Ion_Type1_12	12.900000000	8.857000000	5.529000000	0 # molecule nr 17
+Ion_Type2_7	6.550000000	12.750000000	6.046000000	0 # molecule nr 18
+Ion_Type1_13	5.834000000	12.713000000	6.682000000	0 # molecule nr 19
+Ion_Type1_14	7.308000000	13.058000000	6.546000000	0 # molecule nr 20
+Ion_Type2_8	9.650000000	12.750000000	6.046000000	0 # molecule nr 21
+Ion_Type1_15	9.141000000	12.027000000	5.676000000	0 # molecule nr 22
+Ion_Type1_16	9.228000000	13.544000000	5.715000000	0 # molecule nr 23
+Ion_Type2_9	12.750000000	12.750000000	6.046000000	0 # molecule nr 24
+Ion_Type1_17	12.928000000	13.649000000	5.764000000	0 # molecule nr 25
+Ion_Type1_18	12.122000000	12.410000000	5.407000000	0 # molecule nr 26
+Ion_Type2_10	6.550000000	6.550000000	9.146000000	0 # molecule nr 27
+Ion_Type1_19	6.149000000	5.713000000	8.906000000	0 # molecule nr 28
+Ion_Type1_20	5.938000000	6.948000000	9.766000000	0 # molecule nr 29
+Ion_Type2_11	9.650000000	6.550000000	9.146000000	0 # molecule nr 30
+Ion_Type1_21	9.612000000	5.833000000	9.781000000	0 # molecule nr 31
+Ion_Type1_22	9.776000000	7.340000000	9.673000000	0 # molecule nr 32
+Ion_Type2_12	12.750000000	6.550000000	9.146000000	0 # molecule nr 33
+Ion_Type1_23	12.734000000	7.473000000	9.403000000	0 # molecule nr 34
+Ion_Type1_24	12.410000000	6.076000000	9.907000000	0 # molecule nr 35
+Ion_Type2_13	6.550000000	9.650000000	9.146000000	0 # molecule nr 36
+Ion_Type1_25	6.335000000	10.319000000	9.798000000	0 # molecule nr 37
+Ion_Type1_26	6.060000000	8.873000000	9.419000000	0 # molecule nr 38
+Ion_Type2_14	6.550000000	12.750000000	9.146000000	0 # molecule nr 39
+Ion_Type1_27	7.136000000	12.026000000	9.369000000	0 # molecule nr 40
+Ion_Type1_28	5.738000000	12.330000000	8.859000000	0 # molecule nr 41
+Ion_Type2_15	12.750000000	12.750000000	9.146000000	0 # molecule nr 42
+Ion_Type1_29	12.976000000	12.419000000	10.017000000	0 # molecule nr 43
+Ion_Type1_30	13.592000000	12.883000000	8.707000000	0 # molecule nr 44
+Ion_Type2_16	6.550000000	6.550000000	12.246000000	0 # molecule nr 45
+Ion_Type1_31	6.754000000	7.229000000	11.601000000	0 # molecule nr 46
+Ion_Type1_32	5.898000000	6.947000000	12.825000000	0 # molecule nr 47
+Ion_Type2_17	9.650000000	6.550000000	12.246000000	0 # molecule nr 48
+Ion_Type1_33	10.034000000	5.710000000	12.503000000	0 # molecule nr 49
+Ion_Type1_34	10.067000000	7.197000000	12.817000000	0 # molecule nr 50
+Ion_Type2_18	12.750000000	6.550000000	12.246000000	0 # molecule nr 51
+Ion_Type1_35	13.278000000	7.331000000	12.418000000	0 # molecule nr 52
+Ion_Type1_36	12.248000000	6.410000000	13.050000000	0 # molecule nr 53
+Ion_Type2_19	6.550000000	9.650000000	12.246000000	0 # molecule nr 54
+Ion_Type1_37	5.991000000	9.021000000	12.705000000	0 # molecule nr 55
+Ion_Type1_38	7.382000000	9.632000000	12.721000000	0 # molecule nr 56
+Ion_Type2_20	6.550000000	12.750000000	12.246000000	0 # molecule nr 57
+Ion_Type1_39	7.129000000	12.071000000	12.596000000	0 # molecule nr 58
+Ion_Type1_40	6.945000000	13.005000000	11.411000000	0 # molecule nr 59
+Ion_Type2_21	9.650000000	12.750000000	12.246000000	0 # molecule nr 60
+Ion_Type1_41	9.105000000	12.539000000	13.005000000	0 # molecule nr 61
+Ion_Type1_42	10.474000000	13.071000000	12.615000000	0 # molecule nr 62
+Ion_Type2_22	12.750000000	12.750000000	12.246000000	0 # molecule nr 63
+Ion_Type1_43	12.127000000	12.133000000	12.633000000	0 # molecule nr 64
+Ion_Type1_44	13.614000000	12.395000000	12.461000000	0 # molecule nr 65
+Ion_Type2_23	6.550000000	6.550000000	15.346000000	0 # molecule nr 66
+Ion_Type1_45	5.730000000	6.420000000	14.868000000	0 # molecule nr 67
+Ion_Type1_46	7.240000000	6.388000000	14.701000000	0 # molecule nr 68
+Ion_Type2_24	9.650000000	6.550000000	15.346000000	0 # molecule nr 69
+Ion_Type1_47	9.006000000	6.245000000	15.987000000	0 # molecule nr 70
+Ion_Type1_48	10.406000000	6.824000000	15.867000000	0 # molecule nr 71
+Ion_Type2_25	12.750000000	6.550000000	15.346000000	0 # molecule nr 72
+Ion_Type1_49	13.193000000	5.783000000	15.712000000	0 # molecule nr 73
+Ion_Type1_50	13.441000000	7.205000000	15.238000000	0 # molecule nr 74
+Ion_Type2_26	6.550000000	9.650000000	15.346000000	0 # molecule nr 75
+Ion_Type1_51	6.265000000	10.284000000	14.687000000	0 # molecule nr 76
+Ion_Type1_52	7.444000000	9.416000000	15.093000000	0 # molecule nr 77
+Ion_Type2_27	9.650000000	9.650000000	15.346000000	0 # molecule nr 78
+Ion_Type1_53	10.379000000	9.444000000	15.933000000	0 # molecule nr 79
+Ion_Type1_54	8.933000000	9.912000000	15.926000000	0 # molecule nr 80
+Ion_Type2_28	12.750000000	9.650000000	15.346000000	0 # molecule nr 81
+Ion_Type1_55	13.611000000	9.476000000	15.728000000	0 # molecule nr 82
+Ion_Type1_56	12.123000000	9.305000000	15.984000000	0 # molecule nr 83
+Ion_Type2_29	6.550000000	12.750000000	15.346000000	0 # molecule nr 84
+Ion_Type1_57	6.187000000	11.882000000	15.165000000	0 # molecule nr 85
+Ion_Type1_58	7.500000000	12.638000000	15.286000000	0 # molecule nr 86
+Ion_Type2_30	9.650000000	12.750000000	15.346000000	0 # molecule nr 87
+Ion_Type1_59	9.750000000	13.494000000	14.751000000	0 # molecule nr 88
+Ion_Type1_60	9.283000000	12.049000000	14.805000000	0 # molecule nr 89
+Ion_Type2_31	12.750000000	12.750000000	15.346000000	0 # molecule nr 90
+Ion_Type1_61	13.468000000	13.235000000	15.756000000	0 # molecule nr 91
+Ion_Type1_62	12.276000000	12.347000000	16.075000000	0 # molecule nr 92
Index: tests/regression/Analysis/3/post/bin_output.csv
===================================================================
--- tests/regression/Analysis/3/post/bin_output.csv	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Analysis/3/post/bin_output.csv	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,42 @@
+BinStart	Count
+0	0
+0.5	0
+1	0
+1.5	0
+2	0
+2.5	1
+3	1
+3.5	6
+4	7
+4.5	10
+5	8
+5.5	13
+6	5
+6.5	6
+7	4
+7.5	1
+8	0
+8.5	0
+9	0
+9.5	0
+10	0
+10.5	0
+11	0
+11.5	0
+12	0
+12.5	0
+13	0
+13.5	0
+14	0
+14.5	0
+15	0
+15.5	0
+16	0
+16.5	0
+17	0
+17.5	0
+18	0
+18.5	0
+19	0
+19.5	0
+20	0
Index: tests/regression/Analysis/3/pre/test.conf
===================================================================
--- tests/regression/Analysis/3/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Analysis/3/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,165 @@
+# 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	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	62	1	1.0	3	3	1.00800000000	Hydrogen	H
+Ion_Type2	31	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	6.550000000	6.550000000	6.046000000	0 # molecule nr 0
+Ion_Type1_1	5.980000000	5.780000000	6.065000000	0 # molecule nr 1
+Ion_Type1_2	7.103000000	6.467000000	6.824000000	0 # molecule nr 2
+Ion_Type2_2	9.650000000	6.550000000	6.046000000	0 # molecule nr 3
+Ion_Type1_3	8.814000000	6.529000000	6.514000000	0 # molecule nr 4
+Ion_Type1_4	10.283000000	6.163000000	6.653000000	0 # molecule nr 5
+Ion_Type2_3	12.750000000	6.550000000	6.046000000	0 # molecule nr 6
+Ion_Type1_5	12.181000000	6.385000000	5.292000000	0 # molecule nr 7
+Ion_Type1_6	13.035000000	7.460000000	5.946000000	0 # molecule nr 8
+Ion_Type2_4	6.550000000	9.650000000	6.046000000	0 # molecule nr 9
+Ion_Type1_7	6.571000000	10.422000000	5.479000000	0 # molecule nr 10
+Ion_Type1_8	6.193000000	8.950000000	5.497000000	0 # molecule nr 11
+Ion_Type2_5	9.650000000	9.650000000	6.046000000	0 # molecule nr 12
+Ion_Type1_9	9.430000000	9.454000000	6.958000000	0 # molecule nr 13
+Ion_Type1_10	10.521000000	9.272000000	5.916000000	0 # molecule nr 14
+Ion_Type2_6	12.750000000	9.650000000	6.046000000	0 # molecule nr 15
+Ion_Type1_11	12.266000000	10.237000000	5.463000000	0 # molecule nr 16
+Ion_Type1_12	12.900000000	8.857000000	5.529000000	0 # molecule nr 17
+Ion_Type2_7	6.550000000	12.750000000	6.046000000	0 # molecule nr 18
+Ion_Type1_13	5.834000000	12.713000000	6.682000000	0 # molecule nr 19
+Ion_Type1_14	7.308000000	13.058000000	6.546000000	0 # molecule nr 20
+Ion_Type2_8	9.650000000	12.750000000	6.046000000	0 # molecule nr 21
+Ion_Type1_15	9.141000000	12.027000000	5.676000000	0 # molecule nr 22
+Ion_Type1_16	9.228000000	13.544000000	5.715000000	0 # molecule nr 23
+Ion_Type2_9	12.750000000	12.750000000	6.046000000	0 # molecule nr 24
+Ion_Type1_17	12.928000000	13.649000000	5.764000000	0 # molecule nr 25
+Ion_Type1_18	12.122000000	12.410000000	5.407000000	0 # molecule nr 26
+Ion_Type2_10	6.550000000	6.550000000	9.146000000	0 # molecule nr 27
+Ion_Type1_19	6.149000000	5.713000000	8.906000000	0 # molecule nr 28
+Ion_Type1_20	5.938000000	6.948000000	9.766000000	0 # molecule nr 29
+Ion_Type2_11	9.650000000	6.550000000	9.146000000	0 # molecule nr 30
+Ion_Type1_21	9.612000000	5.833000000	9.781000000	0 # molecule nr 31
+Ion_Type1_22	9.776000000	7.340000000	9.673000000	0 # molecule nr 32
+Ion_Type2_12	12.750000000	6.550000000	9.146000000	0 # molecule nr 33
+Ion_Type1_23	12.734000000	7.473000000	9.403000000	0 # molecule nr 34
+Ion_Type1_24	12.410000000	6.076000000	9.907000000	0 # molecule nr 35
+Ion_Type2_13	6.550000000	9.650000000	9.146000000	0 # molecule nr 36
+Ion_Type1_25	6.335000000	10.319000000	9.798000000	0 # molecule nr 37
+Ion_Type1_26	6.060000000	8.873000000	9.419000000	0 # molecule nr 38
+Ion_Type2_14	6.550000000	12.750000000	9.146000000	0 # molecule nr 39
+Ion_Type1_27	7.136000000	12.026000000	9.369000000	0 # molecule nr 40
+Ion_Type1_28	5.738000000	12.330000000	8.859000000	0 # molecule nr 41
+Ion_Type2_15	12.750000000	12.750000000	9.146000000	0 # molecule nr 42
+Ion_Type1_29	12.976000000	12.419000000	10.017000000	0 # molecule nr 43
+Ion_Type1_30	13.592000000	12.883000000	8.707000000	0 # molecule nr 44
+Ion_Type2_16	6.550000000	6.550000000	12.246000000	0 # molecule nr 45
+Ion_Type1_31	6.754000000	7.229000000	11.601000000	0 # molecule nr 46
+Ion_Type1_32	5.898000000	6.947000000	12.825000000	0 # molecule nr 47
+Ion_Type2_17	9.650000000	6.550000000	12.246000000	0 # molecule nr 48
+Ion_Type1_33	10.034000000	5.710000000	12.503000000	0 # molecule nr 49
+Ion_Type1_34	10.067000000	7.197000000	12.817000000	0 # molecule nr 50
+Ion_Type2_18	12.750000000	6.550000000	12.246000000	0 # molecule nr 51
+Ion_Type1_35	13.278000000	7.331000000	12.418000000	0 # molecule nr 52
+Ion_Type1_36	12.248000000	6.410000000	13.050000000	0 # molecule nr 53
+Ion_Type2_19	6.550000000	9.650000000	12.246000000	0 # molecule nr 54
+Ion_Type1_37	5.991000000	9.021000000	12.705000000	0 # molecule nr 55
+Ion_Type1_38	7.382000000	9.632000000	12.721000000	0 # molecule nr 56
+Ion_Type2_20	6.550000000	12.750000000	12.246000000	0 # molecule nr 57
+Ion_Type1_39	7.129000000	12.071000000	12.596000000	0 # molecule nr 58
+Ion_Type1_40	6.945000000	13.005000000	11.411000000	0 # molecule nr 59
+Ion_Type2_21	9.650000000	12.750000000	12.246000000	0 # molecule nr 60
+Ion_Type1_41	9.105000000	12.539000000	13.005000000	0 # molecule nr 61
+Ion_Type1_42	10.474000000	13.071000000	12.615000000	0 # molecule nr 62
+Ion_Type2_22	12.750000000	12.750000000	12.246000000	0 # molecule nr 63
+Ion_Type1_43	12.127000000	12.133000000	12.633000000	0 # molecule nr 64
+Ion_Type1_44	13.614000000	12.395000000	12.461000000	0 # molecule nr 65
+Ion_Type2_23	6.550000000	6.550000000	15.346000000	0 # molecule nr 66
+Ion_Type1_45	5.730000000	6.420000000	14.868000000	0 # molecule nr 67
+Ion_Type1_46	7.240000000	6.388000000	14.701000000	0 # molecule nr 68
+Ion_Type2_24	9.650000000	6.550000000	15.346000000	0 # molecule nr 69
+Ion_Type1_47	9.006000000	6.245000000	15.987000000	0 # molecule nr 70
+Ion_Type1_48	10.406000000	6.824000000	15.867000000	0 # molecule nr 71
+Ion_Type2_25	12.750000000	6.550000000	15.346000000	0 # molecule nr 72
+Ion_Type1_49	13.193000000	5.783000000	15.712000000	0 # molecule nr 73
+Ion_Type1_50	13.441000000	7.205000000	15.238000000	0 # molecule nr 74
+Ion_Type2_26	6.550000000	9.650000000	15.346000000	0 # molecule nr 75
+Ion_Type1_51	6.265000000	10.284000000	14.687000000	0 # molecule nr 76
+Ion_Type1_52	7.444000000	9.416000000	15.093000000	0 # molecule nr 77
+Ion_Type2_27	9.650000000	9.650000000	15.346000000	0 # molecule nr 78
+Ion_Type1_53	10.379000000	9.444000000	15.933000000	0 # molecule nr 79
+Ion_Type1_54	8.933000000	9.912000000	15.926000000	0 # molecule nr 80
+Ion_Type2_28	12.750000000	9.650000000	15.346000000	0 # molecule nr 81
+Ion_Type1_55	13.611000000	9.476000000	15.728000000	0 # molecule nr 82
+Ion_Type1_56	12.123000000	9.305000000	15.984000000	0 # molecule nr 83
+Ion_Type2_29	6.550000000	12.750000000	15.346000000	0 # molecule nr 84
+Ion_Type1_57	6.187000000	11.882000000	15.165000000	0 # molecule nr 85
+Ion_Type1_58	7.500000000	12.638000000	15.286000000	0 # molecule nr 86
+Ion_Type2_30	9.650000000	12.750000000	15.346000000	0 # molecule nr 87
+Ion_Type1_59	9.750000000	13.494000000	14.751000000	0 # molecule nr 88
+Ion_Type1_60	9.283000000	12.049000000	14.805000000	0 # molecule nr 89
+Ion_Type2_31	12.750000000	12.750000000	15.346000000	0 # molecule nr 90
+Ion_Type1_61	13.468000000	13.235000000	15.756000000	0 # molecule nr 91
+Ion_Type1_62	12.276000000	12.347000000	16.075000000	0 # molecule nr 92
Index: tests/regression/Analysis/4/post/bin_output.csv
===================================================================
--- tests/regression/Analysis/4/post/bin_output.csv	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Analysis/4/post/bin_output.csv	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,22 @@
+BinStart	Count
+0	0
+1	0
+2	5
+3	19
+4	29
+5	38
+6	59
+7	58
+8	43
+9	42
+10	48
+11	32
+12	18
+13	13
+14	4
+15	2
+16	0
+17	0
+18	0
+19	0
+20	0
Index: tests/regression/Analysis/4/post/output.csv
===================================================================
--- tests/regression/Analysis/4/post/output.csv	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Analysis/4/post/output.csv	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,411 @@
+BinStart	Triangle
+2.1615101	[H236|(8.6850559,8.1733259,10.850813)]	[11|H9,H10,H11]
+2.4065182	[H328|(11.038056,8.1673259,13.076813)]	[9|H4,H5,H11]
+2.4830003	[H347|(11.674056,10.949326,13.366813)]	[6|H5,H8,H11]
+2.5845795	[H332|(13.742056,8.4173259,13.282813)]	[5|H5,H6,H8]
+2.7660132	[H346|(10.159056,10.824326,13.352813)]	[6|H5,H8,H11]
+3.0544821	[H247|(16.783056,10.073326,11.247813)]	[0|H4,H6,H7]
+3.0766911	[H260|(13.453056,13.979326,10.064813)]	[3|H6,H7,H8]
+3.1563175	[H238|(16.418056,8.3763259,10.561813)]	[5|H5,H6,H8]
+3.2720788	[H365|(11.316056,13.560326,13.181813)]	[3|H6,H7,H8]
+3.5237829	[H235|(7.8440559,7.0973259,11.517813)]	[11|H9,H10,H11]
+3.5338413	[H142|(8.2870559,6.9513259,7.6468131)]	[1|H4,H7,H10]
+3.5499604	[H331|(14.408056,7.0613259,13.446813)]	[5|H5,H6,H8]
+3.6394421	[H248|(17.116056,11.525326,11.550813)]	[0|H4,H6,H7]
+3.6406699	[H257|(8.0500559,13.287326,11.463813)]	[4|H7,H8,H9]
+3.6877615	[H329|(10.670056,6.8663259,13.772813)]	[9|H4,H5,H11]
+3.7836271	[H170|(13.229056,14.523326,7.6518131)]	[0|H4,H6,H7]
+3.7944745	[H127|(10.577056,5.4943259,8.1188131)]	[1|H4,H7,H10]
+3.7970448	[H220|(10.694056,5.4013259,11.433813)]	[9|H4,H5,H11]
+3.8058945	[H167|(10.662056,14.095326,6.8258131)]	[0|H4,H6,H7]
+3.80928	[H166|(11.010056,14.867326,8.0888131)]	[0|H4,H6,H7]
+3.8924476	[H344|(8.6960559,11.208326,13.777813)]	[7|H8,H9,H11]
+3.9221077	[H350|(14.091056,10.158326,14.571813)]	[5|H5,H6,H8]
+3.9833108	[H154|(17.481056,10.051326,8.0578131)]	[0|H4,H6,H7]
+3.9938709	[H55|(11.090056,11.636326,5.2018131)]	[1|H4,H7,H10]
+4.0103298	[H259|(14.819056,14.416326,10.568813)]	[5|H5,H6,H8]
+4.0588232	[H223|(13.430056,5.1493259,11.441813)]	[5|H5,H6,H8]
+4.0967455	[H164|(8.6790559,13.674326,7.4708131)]	[2|H7,H9,H10]
+4.1548902	[H146|(16.710056,8.3903259,7.1248131)]	[8|H4,H5,H6]
+4.164366	[H59|(14.204056,11.334326,5.4648131)]	[0|H4,H6,H7]
+4.1737233	[H143|(6.9360559,7.5263259,8.0408131)]	[11|H9,H10,H11]
+4.18155	[H349|(14.631056,11.542326,14.250813)]	[5|H5,H6,H8]
+4.2066788	[H352|(16.365056,11.149326,13.407813)]	[5|H5,H6,H8]
+4.387257	[H325|(7.2130559,8.4003259,13.527813)]	[11|H9,H10,H11]
+4.4568153	[H58|(13.086056,10.640326,4.7038131)]	[0|H4,H6,H7]
+4.4885393	[H155|(17.812056,11.522326,7.8638131)]	[0|H4,H6,H7]
+4.5084456	[H239|(17.915056,8.3013259,10.814813)]	[0|H4,H6,H7]
+4.5545202	[H244|(5.2080559,10.202326,10.380813)]	[11|H9,H10,H11]
+4.5621787	[H169|(14.699056,14.453326,7.2738131)]	[0|H4,H6,H7]
+4.575169	[H35|(8.4080559,8.2793259,5.2028131)]	[1|H4,H7,H10]
+4.5981642	[H313|(13.570056,5.4103259,13.510813)]	[5|H5,H6,H8]
+4.6681477	[H130|(14.510056,5.1773259,7.0948131)]	[0|H4,H6,H7]
+4.6686424	[H310|(10.397056,5.1733259,13.304813)]	[11|H9,H10,H11]
+4.7252218	[H217|(8.3460559,5.0223259,10.125813)]	[11|H9,H10,H11]
+4.7348892	[H263|(17.243056,13.466326,11.643813)]	[0|H4,H6,H7]
+4.7495429	[H364|(11.399056,14.794326,14.064813)]	[3|H6,H7,H8]
+4.7752158	[H77|(13.811056,13.205326,5.1738131)]	[0|H4,H6,H7]
+4.7998026	[H37|(11.766056,7.3423259,4.6608131)]	[1|H4,H7,H10]
+4.8639461	[H172|(17.451056,13.084326,7.8118131)]	[0|H4,H6,H7]
+4.8817614	[H218|(7.4780559,5.4543259,11.296813)]	[11|H9,H10,H11]
+4.9159097	[H343|(7.8780559,10.404326,14.773813)]	[11|H9,H10,H11]
+4.96521	[H256|(7.7780559,14.779326,11.368813)]	[4|H7,H8,H9]
+4.9773397	[H163|(7.2040559,13.586326,7.1148131)]	[11|H9,H10,H11]
+4.9846394	[H173|(16.301056,13.897326,7.2388131)]	[3|H6,H7,H8]
+5.0365163	[H353|(17.799056,10.652326,13.313813)]	[0|H4,H6,H7]
+5.0741964	[H128|(11.103056,4.1203259,8.4988131)]	[1|H4,H7,H10]
+5.1049636	[H368|(14.540056,13.549326,14.618813)]	[3|H6,H7,H8]
+5.1440173	[H40|(13.569056,8.3753259,4.0388131)]	[0|H4,H6,H7]
+5.1751338	[H145|(17.466056,7.0733259,7.1998131)]	[0|H4,H6,H7]
+5.1827993	[H326|(7.6090559,7.8283259,14.878813)]	[11|H9,H10,H11]
+5.1981922	[H221|(11.251056,3.9873259,11.414813)]	[9|H4,H5,H11]
+5.2485612	[H224|(14.564056,4.1373259,11.410813)]	[5|H5,H6,H8]
+5.2569938	[H38|(10.960056,8.3863259,3.9038131)]	[1|H4,H7,H10]
+5.2690702	[H454|(10.867056,10.602326,16.126813)]	[6|H5,H8,H11]
+5.3178359	[H367|(14.261056,14.903326,13.986813)]	[3|H6,H7,H8]
+5.350325	[H73|(10.056056,13.549326,4.6048131)]	[0|H4,H6,H7]
+5.4055287	[H275|(10.874056,16.556326,11.646813)]	[3|H6,H7,H8]
+5.4096876	[H151|(5.0530559,10.092326,7.3138131)]	[11|H9,H10,H11]
+5.4119894	[H56|(10.724056,11.247326,3.7798131)]	[1|H4,H7,H10]
+5.4537056	[H226|(16.343056,4.7833259,11.405813)]	[5|H5,H6,H8]
+5.4554775	[H34|(7.7960559,6.8993259,5.0268131)]	[1|H4,H7,H10]
+5.4606061	[H335|(17.442056,7.0193259,13.460813)]	[5|H5,H6,H8]
+5.4931777	[H232|(5.4030559,7.1253259,10.961813)]	[11|H9,H10,H11]
+5.4998783	[H245|(4.5130559,10.495326,11.699813)]	[11|H9,H10,H11]
+5.5249458	[H314|(14.888056,4.6543259,13.556813)]	[5|H5,H6,H8]
+5.5722366	[H41|(14.453056,7.1393259,4.0818131)]	[0|H4,H6,H7]
+5.6013874	[H277|(13.690056,16.555326,11.579813)]	[3|H6,H7,H8]
+5.619249	[H62|(17.269056,10.237326,5.3388131)]	[0|H4,H6,H7]
+5.6285089	[H131|(13.769056,3.8663259,7.2968131)]	[0|H4,H6,H7]
+5.6446916	[H52|(8.4810559,10.513326,4.0628131)]	[1|H4,H7,H10]
+5.6930833	[H278|(13.539056,16.746326,10.078813)]	[3|H6,H7,H8]
+5.7247711	[H262|(17.521056,14.826326,11.023813)]	[0|H4,H6,H7]
+5.8193625	[H361|(7.4570559,13.320326,14.543813)]	[4|H7,H8,H9]
+5.8623193	[H251|(19.698056,11.677326,10.718813)]	[0|H4,H6,H7]
+5.8690545	[H317|(16.300056,5.0023259,13.551813)]	[5|H5,H6,H8]
+5.9057268	[H437|(11.693056,7.5133259,16.555813)]	[9|H4,H5,H11]
+5.9073214	[H233|(4.5670559,8.1453259,11.716813)]	[11|H9,H10,H11]
+5.9326057	[H152|(4.7100559,11.551326,7.0618131)]	[11|H9,H10,H11]
+5.932697	[H61|(16.256056,10.644326,4.2818131)]	[0|H4,H6,H7]
+5.9531265	[H472|(10.623056,13.765326,16.154813)]	[3|H6,H7,H8]
+5.9706316	[H44|(17.658056,8.1183259,5.3548131)]	[0|H4,H6,H7]
+5.9952609	[H125|(8.1370559,3.8173259,8.0098131)]	[1|H4,H7,H10]
+6.0111481	[H434|(8.4070559,8.1083259,16.368813)]	[11|H9,H10,H11]
+6.0484954	[H439|(14.510056,8.5383259,16.739813)]	[5|H5,H6,H8]
+6.0534324	[H362|(8.2720559,14.602326,14.506813)]	[7|H8,H9,H11]
+6.0538257	[H124|(7.4120559,4.5363259,6.8848131)]	[1|H4,H7,H10]
+6.0597889	[H334|(17.509056,7.7093259,14.812813)]	[5|H5,H6,H8]
+6.0646101	[H139|(4.3870559,7.9123259,8.6358131)]	[11|H9,H10,H11]
+6.1033383	[H386|(14.003056,16.560326,13.136813)]	[3|H6,H7,H8]
+6.10959	[H311|(10.264056,4.2533259,14.507813)]	[11|H9,H10,H11]
+6.1110642	[H250|(20.130056,10.400326,10.016813)]	[0|H4,H6,H7]
+6.1313507	[H133|(17.448056,5.2983259,7.0938131)]	[0|H4,H6,H7]
+6.1432983	[H341|(5.0380559,9.9773259,13.921813)]	[11|H9,H10,H11]
+6.1783979	[H74|(11.080056,14.276326,3.7488131)]	[0|H4,H6,H7]
+6.2286613	[H383|(11.010056,16.300326,14.494813)]	[3|H6,H7,H8]
+6.2288607	[H188|(14.737056,16.780326,8.2948131)]	[0|H4,H6,H7]
+6.2379594	[H158|(20.016056,10.124326,8.3018131)]	[0|H4,H6,H7]
+6.2858123	[H76|(14.438056,13.634326,3.8578131)]	[0|H4,H6,H7]
+6.2869523	[H22|(13.191056,5.0633259,4.3338131)]	[0|H4,H6,H7]
+6.346306	[H272|(8.1570559,16.518326,11.540813)]	[4|H7,H8,H9]
+6.3470367	[H53|(7.3940559,11.572326,4.1328131)]	[2|H7,H9,H10]
+6.3702419	[H308|(8.3440559,3.9203259,13.696813)]	[11|H9,H10,H11]
+6.3932854	[H271|(7.7260559,16.501326,10.083813)]	[4|H7,H8,H9]
+6.4256324	[H455|(10.263056,11.579326,17.122813)]	[6|H5,H8,H11]
+6.438195	[H187|(13.405056,17.509326,8.3468131)]	[0|H4,H6,H7]
+6.4500502	[H382|(11.763056,17.187326,13.516813)]	[3|H6,H7,H8]
+6.4890697	[H340|(4.1200559,10.944326,13.192813)]	[11|H9,H10,H11]
+6.5109579	[H358|(4.9380559,13.274326,13.333813)]	[11|H9,H10,H11]
+6.5176804	[H43|(17.271056,6.8333259,4.6408131)]	[0|H4,H6,H7]
+6.52596	[H184|(10.007056,17.384326,7.6668131)]	[0|H4,H6,H7]
+6.5329131	[H254|(4.9600559,14.839326,10.501813)]	[11|H9,H10,H11]
+6.5644769	[H281|(16.629056,16.430326,10.328813)]	[3|H6,H7,H8]
+6.5912434	[H476|(14.443056,13.220326,16.644813)]	[3|H6,H7,H8]
+6.6296428	[H91|(11.093056,16.137326,4.6388131)]	[0|H4,H6,H7]
+6.6323982	[H185|(11.407056,17.611326,7.1198131)]	[0|H4,H6,H7]
+6.6420678	[H475|(13.846056,14.578326,16.315813)]	[3|H6,H7,H8]
+6.6467837	[H370|(17.205056,14.906326,13.722813)]	[3|H6,H7,H8]
+6.6817938	[H20|(10.147056,4.1113259,4.7518131)]	[1|H4,H7,H10]
+6.6952898	[H227|(17.815056,4.4083259,11.436813)]	[5|H5,H6,H8]
+6.7055675	[H140|(4.4900559,6.8703259,7.5338131)]	[2|H7,H9,H10]
+6.7148143	[H176|(19.810056,13.427326,8.4168131)]	[0|H4,H6,H7]
+6.715563	[H19|(11.666056,4.0893259,4.6988131)]	[1|H4,H7,H10]
+6.7294886	[H70|(8.0470559,13.382326,3.9308131)]	[2|H7,H9,H10]
+6.7312743	[H241|(19.737056,6.9493259,10.764813)]	[0|H4,H6,H7]
+6.7387932	[H190|(16.589056,16.402326,8.1778131)]	[0|H4,H6,H7]
+6.7731586	[H182|(7.2410559,16.498326,8.2498131)]	[2|H7,H9,H10]
+6.7769935	[H274|(10.789056,17.984326,11.131813)]	[3|H6,H7,H8]
+6.7891944	[H307|(6.9070559,4.3623259,13.920813)]	[11|H9,H10,H11]
+6.7940626	[H355|(20.100056,10.855326,12.991813)]	[0|H4,H6,H7]
+6.8205907	[H452|(7.1530559,11.166326,16.410813)]	[7|H8,H9,H11]
+6.8374602	[H134|(17.028056,3.8483259,7.2728131)]	[0|H4,H6,H7]
+6.8539306	[H265|(19.464056,14.532326,10.615813)]	[0|H4,H6,H7]
+6.8576714	[H457|(14.937056,10.906326,17.291813)]	[5|H5,H6,H8]
+6.8863007	[H421|(14.323056,5.4433259,16.557813)]	[5|H5,H6,H8]
+6.8891963	[H371|(17.515056,13.888326,14.808813)]	[0|H4,H6,H7]
+6.9018976	[H95|(13.659056,16.925326,5.5218131)]	[0|H4,H6,H7]
+6.9305971	[H215|(5.5370559,4.4763259,11.287813)]	[11|H9,H10,H11]
+6.9620094	[H149|(19.794056,8.0163259,6.9148131)]	[0|H4,H6,H7]
+6.9644318	[H469|(8.3410559,13.376326,16.518813)]	[4|H7,H8,H9]
+6.9759993	[H473|(10.845056,13.154326,17.528813)]	[3|H6,H7,H8]
+6.978677	[H23|(13.821056,3.7453259,4.7538131)]	[0|H4,H6,H7]
+7.0087284	[H436|(11.247056,8.2153259,17.828813)]	[9|H4,H5,H11]
+7.0139314	[H157|(20.293056,10.517326,6.8598131)]	[0|H4,H6,H7]
+7.0145429	[H458|(13.560056,10.536326,17.816813)]	[5|H5,H6,H8]
+7.0425357	[H253|(3.9190559,14.136326,11.358813)]	[11|H9,H10,H11]
+7.0431978	[H49|(5.1580559,11.711326,4.8048131)]	[11|H9,H10,H11]
+7.0490957	[H160|(4.1950559,14.461326,8.3908131)]	[11|H9,H10,H11]
+7.0638945	[H181|(8.4240559,17.442326,8.3858131)]	[2|H7,H9,H10]
+7.0919587	[H92|(10.501056,17.246326,5.4928131)]	[0|H4,H6,H7]
+7.1257915	[H433|(7.0330559,8.3323259,16.978813)]	[11|H9,H10,H11]
+7.1258241	[H356|(19.712056,10.128326,14.269813)]	[0|H4,H6,H7]
+7.1306704	[H316|(17.446056,4.0323259,13.319813)]	[5|H5,H6,H8]
+7.1474287	[H16|(8.1750559,3.8593259,4.9838131)]	[1|H4,H7,H10]
+7.2069634	[H17|(6.8880559,4.6613259,4.8958131)]	[1|H4,H7,H10]
+7.2070855	[H122|(4.4790559,5.5483259,8.0728131)]	[11|H9,H10,H11]
+7.2221795	[H31|(4.8480559,8.7173259,4.7798131)]	[11|H9,H10,H11]
+7.2222028	[H379|(8.4880559,17.210326,13.276813)]	[3|H6,H7,H8]
+7.238952	[H323|(4.7670559,7.7873259,14.900813)]	[11|H9,H10,H11]
+7.2620249	[H161|(4.5110559,14.397326,6.9058131)]	[11|H9,H10,H11]
+7.273479	[H440|(13.961056,7.8813259,17.995813)]	[5|H5,H6,H8]
+7.3809232	[H451|(7.4290559,10.108326,17.465813)]	[11|H9,H10,H11]
+7.3840521	[H461|(17.250056,11.690326,16.554813)]	[5|H5,H6,H8]
+7.3889559	[H71|(7.5010559,14.773326,4.2078131)]	[2|H7,H9,H10]
+7.4064727	[H460|(17.687056,10.236326,16.623813)]	[5|H5,H6,H8]
+7.4332614	[H88|(8.0470559,16.344326,5.2138131)]	[2|H7,H9,H10]
+7.4336727	[H25|(16.356056,4.7533259,4.0598131)]	[0|H4,H6,H7]
+7.4435549	[H337|(19.646056,7.0203259,13.790813)]	[5|H5,H6,H8]
+7.4681352	[H385|(13.773056,17.965326,13.670813)]	[3|H6,H7,H8]
+7.501124	[H322|(3.7740559,7.7393259,13.750813)]	[11|H9,H10,H11]
+7.5153999	[H65|(19.288056,10.623326,4.6388131)]	[0|H4,H6,H7]
+7.5422046	[H68|(4.5640559,13.380326,5.3788131)]	[11|H9,H10,H11]
+7.5794973	[H389|(16.818056,16.829326,13.065813)]	[5|H5,H6,H8]
+7.5901759	[H80|(17.999056,14.293326,4.8228131)]	[0|H4,H6,H7]
+7.595448	[H94|(13.325056,16.779326,4.0458131)]	[0|H4,H6,H7]
+7.6173579	[H416|(7.5770559,5.5933259,16.882813)]	[11|H9,H10,H11]
+7.6455543	[H359|(4.3880559,14.690326,13.389813)]	[11|H9,H10,H11]
+7.6908225	[H373|(20.242056,13.786326,13.004813)]	[0|H4,H6,H7]
+7.7021985	[H280|(18.028056,16.966326,10.584813)]	[0|H4,H6,H7]
+7.7120414	[H242|(21.073056,7.5373259,11.188813)]	[0|H4,H6,H7]
+7.7145738	[H136|(19.303056,4.6553259,8.0458131)]	[0|H4,H6,H7]
+7.7235718	[H305|(4.3830559,5.4953259,13.566813)]	[11|H9,H10,H11]
+7.7335503	[H191|(17.545056,16.627326,7.0178131)]	[0|H4,H6,H7]
+7.7386598	[H229|(19.473056,4.7263259,10.235813)]	[8|H4,H5,H6]
+7.7471166	[H338|(19.841056,8.2123259,14.713813)]	[5|H5,H6,H8]
+7.7748411	[H415|(7.7540559,4.2543259,16.186813)]	[11|H9,H10,H11]
+7.796633	[H493|(13.645056,16.325326,16.577813)]	[3|H6,H7,H8]
+7.8001317	[H490|(11.610056,16.695326,16.510813)]	[3|H6,H7,H8]
+7.8052824	[H478|(16.806056,14.389326,16.233813)]	[3|H6,H7,H8]
+7.8071737	[H419|(10.511056,5.2893259,17.663813)]	[11|H9,H10,H11]
+7.8099596	[H470|(7.2450559,14.423326,16.412813)]	[4|H7,H8,H9]
+7.8114061	[H64|(20.355056,11.271326,5.5058131)]	[0|H4,H6,H7]
+7.8147489	[H79|(16.943056,14.221326,3.7318131)]	[0|H4,H6,H7]
+7.927931	[H46|(20.207056,8.0933259,5.5488131)]	[8|H4,H5,H6]
+7.9396615	[H304|(4.9350559,4.1303259,13.188813)]	[11|H9,H10,H11]
+7.94345	[H47|(19.348056,8.0073259,4.2978131)]	[0|H4,H6,H7]
+7.9464529	[H431|(4.9130559,8.4083259,16.350813)]	[11|H9,H10,H11]
+7.9529266	[H266|(20.940056,14.320326,10.321813)]	[0|H4,H6,H7]
+7.9564822	[H442|(18.008056,8.1163259,17.081813)]	[5|H5,H6,H8]
+7.9937411	[H148|(21.150056,7.7563259,7.5498131)]	[0|H4,H6,H7]
+8.0004701	[H50|(3.7780559,11.083326,4.7018131)]	[11|H9,H10,H11]
+8.0266289	[H388|(16.358056,16.914326,14.512813)]	[3|H6,H7,H8]
+8.0345157	[H443|(16.769056,7.8873259,17.932813)]	[5|H5,H6,H8]
+8.0992649	[H67|(5.0470559,14.782326,5.0438131)]	[11|H9,H10,H11]
+8.1002245	[H175|(20.698056,14.646326,8.2298131)]	[0|H4,H6,H7]
+8.1430909	[H83|(19.991056,13.269326,5.2498131)]	[0|H4,H6,H7]
+8.1703622	[H293|(10.443056,19.343326,10.883813)]	[3|H6,H7,H8]
+8.2168185	[H214|(4.0320559,4.2893259,11.395813)]	[11|H9,H10,H11]
+8.2364685	[H491|(10.146056,17.101326,16.467813)]	[3|H6,H7,H8]
+8.2859858	[H26|(17.869056,4.6033259,4.0598131)]	[0|H4,H6,H7]
+8.3469013	[H202|(11.157056,19.403326,7.2358131)]	[0|H4,H6,H7]
+8.4053237	[H422|(14.550056,4.6543259,17.836813)]	[5|H5,H6,H8]
+8.4238069	[H320|(19.306056,4.3833259,14.046813)]	[5|H5,H6,H8]
+8.4284697	[H32|(4.2240559,7.7163259,3.8208131)]	[1|H4,H7,H10]
+8.4575926	[H565|(13.728056,10.738326,19.238813)]	[5|H5,H6,H8]
+8.4582689	[H121|(3.9300559,4.1423259,7.8878131)]	[1|H4,H7,H10]
+8.4685863	[H418|(11.288056,3.9853259,17.588813)]	[9|H4,H5,H11]
+8.5010813	[H479|(17.963056,13.598326,16.821813)]	[3|H6,H7,H8]
+8.5163214	[H268|(5.4100559,17.656326,11.156813)]	[11|H9,H10,H11]
+8.5276443	[H206|(14.363056,19.308326,7.5458131)]	[0|H4,H6,H7]
+8.5439891	[H14|(5.3420559,4.8663259,3.9458131)]	[1|H4,H7,H10]
+8.5742403	[H380|(7.7090559,17.934326,14.363813)]	[3|H6,H7,H8]
+8.5850826	[H548|(13.950056,7.4293259,19.252813)]	[5|H5,H6,H8]
+8.5935829	[H448|(4.0150559,10.812326,16.389813)]	[11|H9,H10,H11]
+8.6105026	[H179|(4.3700559,16.481326,7.0768131)]	[11|H9,H10,H11]
+8.6245531	[H374|(20.853056,13.384326,14.337813)]	[0|H4,H6,H7]
+8.6534475	[H292|(11.792056,19.953326,10.537813)]	[3|H6,H7,H8]
+8.6908677	[H464|(19.569056,10.247326,16.716813)]	[5|H5,H6,H8]
+8.7145672	[H319|(20.244056,5.5343259,14.374813)]	[5|H5,H6,H8]
+8.7181588	[H89|(7.4700559,17.750326,5.2348131)]	[2|H7,H9,H10]
+8.7254515	[H377|(4.8690559,17.000326,13.001813)]	[11|H9,H10,H11]
+8.7261079	[H137|(20.727056,4.8783259,8.5268131)]	[0|H4,H6,H7]
+8.7416578	[H283|(19.295056,17.314326,10.992813)]	[0|H4,H6,H7]
+8.7530818	[H430|(4.3460559,7.0183259,16.587813)]	[11|H9,H10,H11]
+8.7574532	[H494|(14.164056,17.737326,16.364813)]	[3|H6,H7,H8]
+8.7678582	[H203|(10.224056,19.876326,8.3388131)]	[0|H4,H6,H7]
+8.8844107	[H541|(8.3110559,8.1113259,19.395813)]	[11|H9,H10,H11]
+8.8882972	[H545|(11.155056,8.6203259,19.755813)]	[9|H4,H5,H11]
+8.9033862	[H544|(10.178056,7.4643259,19.612813)]	[11|H9,H10,H11]
+8.9152373	[H559|(7.8230559,10.655326,19.211813)]	[11|H9,H10,H11]
+8.933593	[H193|(20.164056,16.759326,8.6468131)]	[0|H4,H6,H7]
+8.991589	[H400|(10.153056,19.688326,13.623813)]	[3|H6,H7,H8]
+8.996518	[H445|(20.173056,7.3583259,16.182813)]	[5|H5,H6,H8]
+9.006188	[H230|(20.991056,4.6773259,10.285813)]	[8|H4,H5,H6]
+9.0505714	[H401|(11.599056,20.019326,13.294813)]	[3|H6,H7,H8]
+9.057867	[H269|(3.9700559,17.249326,11.425813)]	[11|H9,H10,H11]
+9.0862307	[H403|(14.304056,19.764326,13.129813)]	[3|H6,H7,H8]
+9.0932195	[H97|(16.446056,17.266326,3.9808131)]	[0|H4,H6,H7]
+9.0947678	[H424|(16.669056,4.5573259,17.884813)]	[5|H5,H6,H8]
+9.1642312	[H580|(11.220056,13.122326,19.840813)]	[3|H6,H7,H8]
+9.1660603	[H178|(5.0770559,17.815326,7.2518131)]	[11|H9,H10,H11]
+9.1893012	[H295|(14.579056,20.084326,10.076813)]	[3|H6,H7,H8]
+9.2298712	[H488|(7.3920559,16.243326,17.256813)]	[3|H6,H7,H8]
+9.2519534	[H425|(18.044056,4.5683259,17.237813)]	[5|H5,H6,H8]
+9.2902049	[H98|(17.825056,16.653326,4.1638131)]	[3|H6,H7,H8]
+9.3207727	[H449|(4.4680559,11.627326,17.589813)]	[11|H9,H10,H11]
+9.3746957	[H563|(10.340056,10.114326,20.229813)]	[6|H5,H8,H11]
+9.4222045	[H391|(19.322056,16.928326,14.265813)]	[0|H4,H6,H7]
+9.4409102	[H446|(20.429056,8.6943259,16.861813)]	[5|H5,H6,H8]
+9.4653941	[H205|(14.394056,20.411326,8.5908131)]	[0|H4,H6,H7]
+9.4658719	[H299|(16.336056,19.684326,11.112813)]	[3|H6,H7,H8]
+9.4880124	[H82|(20.552056,13.539326,3.8628131)]	[0|H4,H6,H7]
+9.5129615	[H28|(19.767056,3.8503259,4.8308131)]	[0|H4,H6,H7]
+9.5642945	[H529|(14.486056,4.9043259,19.341813)]	[5|H5,H6,H8]
+9.5871452	[H578|(8.2200559,14.112326,19.286813)]	[3|H6,H7,H8]
+9.5883291	[H13|(3.9180559,4.3913259,4.1898131)]	[1|H4,H7,H10]
+9.6155495	[H397|(8.0730559,19.390326,14.421813)]	[3|H6,H7,H8]
+9.6498006	[H208|(17.165056,19.460326,8.3758131)]	[3|H6,H7,H8]
+9.675241	[H550|(17.157056,7.1263259,19.442813)]	[5|H5,H6,H8]
+9.6951209	[H467|(5.3090559,14.144326,17.774813)]	[4|H7,H8,H9]
+9.7484806	[H289|(8.0640559,20.227326,11.766813)]	[3|H6,H7,H8]
+9.7573037	[H199|(7.1300559,19.822326,8.3158131)]	[2|H7,H9,H10]
+9.7785142	[H566|(13.750056,10.083326,20.610813)]	[5|H5,H6,H8]
+9.7962273	[H101|(19.325056,16.953326,4.9858131)]	[0|H4,H6,H7]
+9.8253804	[H412|(5.2310559,4.8003259,17.839813)]	[11|H9,H10,H11]
+9.8326241	[H542|(6.8930559,7.8653259,19.885813)]	[11|H9,H10,H11]
+9.8351856	[H560|(8.5620559,11.462326,20.266813)]	[6|H5,H8,H11]
+9.8479887	[H113|(14.592056,20.007326,5.3868131)]	[0|H4,H6,H7]
+9.8720044	[H284|(20.569056,17.795326,10.316813)]	[0|H4,H6,H7]
+9.8721625	[H497|(16.615056,16.618326,17.721813)]	[3|H6,H7,H8]
+9.9433325	[H200|(8.4380559,20.597326,8.3368131)]	[0|H4,H6,H7]
+9.9476145	[H466|(3.9450559,13.563326,17.440813)]	[11|H9,H10,H11]
+9.9609811	[H485|(5.2940559,16.589326,16.459813)]	[4|H7,H8,H9]
+9.9639204	[H296|(14.352056,20.943326,11.309813)]	[3|H6,H7,H8]
+9.9753256	[H482|(19.433056,14.454326,17.334813)]	[0|H4,H6,H7]
+10.011723	[H527|(10.001056,4.8493259,19.898813)]	[11|H9,H10,H11]
+10.014004	[H427|(19.425056,4.1643259,16.858813)]	[5|H5,H6,H8]
+10.014122	[H376|(4.6940559,18.021326,14.113813)]	[11|H9,H10,H11]
+10.018358	[H404|(13.344056,20.810326,13.673813)]	[3|H6,H7,H8]
+10.056684	[H547|(14.502056,7.1163259,20.634813)]	[5|H5,H6,H8]
+10.070075	[H551|(16.185056,7.8173259,20.384813)]	[5|H5,H6,H8]
+10.090221	[H487|(8.0420559,17.462326,17.891813)]	[3|H6,H7,H8]
+10.108834	[H496|(17.969056,16.649326,17.031813)]	[3|H6,H7,H8]
+10.117644	[H112|(13.188056,20.471326,5.0358131)]	[0|H4,H6,H7]
+10.119478	[H562|(10.788056,11.371326,20.955813)]	[6|H5,H8,H11]
+10.156688	[H109|(10.497056,20.644326,5.3708131)]	[0|H4,H6,H7]
+10.170168	[H463|(20.830056,10.357326,17.557813)]	[5|H5,H6,H8]
+10.198106	[H106|(8.1440559,20.094326,5.5388131)]	[0|H4,H6,H7]
+10.199854	[H86|(5.0110559,16.959326,3.7408131)]	[2|H7,H9,H10]
+10.214294	[H569|(16.232056,11.149326,20.410813)]	[5|H5,H6,H8]
+10.220562	[H428|(19.904056,5.4233259,17.562813)]	[5|H5,H6,H8]
+10.261425	[H530|(13.653056,5.5083259,20.459813)]	[5|H5,H6,H8]
+10.269801	[H539|(5.2960559,8.3283259,19.619813)]	[11|H9,H10,H11]
+10.281592	[H194|(20.747056,17.872326,7.7908131)]	[0|H4,H6,H7]
+10.315495	[H581|(11.586056,14.281326,20.754813)]	[3|H6,H7,H8]
+10.32569	[H583|(13.289056,14.359326,20.644813)]	[3|H6,H7,H8]
+10.34537	[H392|(20.181056,17.939326,13.523813)]	[0|H4,H6,H7]
+10.347882	[H29|(20.743056,4.5033259,3.8658131)]	[0|H4,H6,H7]
+10.359711	[H290|(8.1710559,20.973326,10.446813)]	[3|H6,H7,H8]
+10.405079	[H577|(7.2560559,13.205326,20.033813)]	[7|H8,H9,H11]
+10.446993	[H100|(20.791056,16.901326,5.3868131)]	[0|H4,H6,H7]
+10.447567	[H511|(13.360056,20.081326,16.347813)]	[3|H6,H7,H8]
+10.451273	[H413|(3.8080559,4.5903259,17.349813)]	[11|H9,H10,H11]
+10.468902	[H602|(14.423056,16.332326,19.704813)]	[3|H6,H7,H8]
+10.492753	[H598|(11.762056,16.746326,19.851813)]	[3|H6,H7,H8]
+10.530454	[H107|(8.5510559,19.937326,4.0828131)]	[0|H4,H6,H7]
+10.545772	[H197|(5.0650559,19.455326,7.2228131)]	[2|H7,H9,H10]
+10.55899	[H557|(5.6650559,10.825326,20.051813)]	[11|H9,H10,H11]
+10.587385	[H556|(4.3800559,10.928326,19.245813)]	[11|H9,H10,H11]
+10.596337	[H584|(14.687056,13.781326,20.795813)]	[3|H6,H7,H8]
+10.641643	[H85|(3.8080559,17.386326,4.5658131)]	[11|H9,H10,H11]
+10.659504	[H115|(16.790056,20.064326,5.5388131)]	[0|H4,H6,H7]
+10.672073	[H110|(11.529056,20.807326,4.2678131)]	[0|H4,H6,H7]
+10.684917	[H601|(13.392056,17.430326,19.503813)]	[3|H6,H7,H8]
+10.68773	[H116|(16.966056,19.331326,4.2188131)]	[0|H4,H6,H7]
+10.745796	[H526|(10.990056,3.7233259,20.153813)]	[9|H4,H5,H11]
+10.875172	[H572|(19.755056,10.471326,19.406813)]	[5|H5,H6,H8]
+10.887862	[H508|(10.685056,19.628326,17.794813)]	[3|H6,H7,H8]
+10.911942	[H506|(8.1860559,19.329326,17.283813)]	[3|H6,H7,H8]
+10.936525	[H532|(16.263056,4.9623259,20.484813)]	[5|H5,H6,H8]
+10.958983	[H481|(20.831056,14.049326,17.771813)]	[0|H4,H6,H7]
+10.964717	[H298|(16.862056,21.099326,10.933813)]	[3|H6,H7,H8]
+10.970727	[H398|(8.0310559,20.905326,14.528813)]	[3|H6,H7,H8]
+11.008131	[H587|(16.339056,14.462326,20.438813)]	[3|H6,H7,H8]
+11.064955	[H209|(17.262056,20.972326,8.2588131)]	[0|H4,H6,H7]
+11.086675	[H574|(5.0450559,13.226326,19.651813)]	[7|H8,H9,H11]
+11.097282	[H524|(7.2010559,3.9443259,20.059813)]	[11|H9,H10,H11]
+11.121857	[H568|(17.696056,11.249326,20.806813)]	[5|H5,H6,H8]
+11.151885	[H484|(4.1230559,17.557326,16.459813)]	[4|H7,H8,H9]
+11.201595	[H505|(8.2970559,20.449326,16.262813)]	[3|H6,H7,H8]
+11.215686	[H406|(18.070056,20.209326,13.925813)]	[3|H6,H7,H8]
+11.240911	[H523|(8.4240559,4.4123259,20.831813)]	[11|H9,H10,H11]
+11.317601	[H287|(3.8030559,19.989326,11.082813)]	[11|H9,H10,H11]
+11.321056	[H586|(17.184056,13.237326,20.746813)]	[5|H5,H6,H8]
+11.392297	[H520|(4.6380559,5.6013259,19.895813)]	[11|H9,H10,H11]
+11.408512	[H409|(19.585056,19.801326,13.324813)]	[0|H4,H6,H7]
+11.440492	[H512|(14.679056,20.760326,16.676813)]	[3|H6,H7,H8]
+11.441945	[H407|(16.842056,21.053326,14.226813)]	[3|H6,H7,H8]
+11.455754	[H599|(10.737056,16.618326,20.965813)]	[3|H6,H7,H8]
+11.475823	[H301|(20.061056,20.172326,9.8978131)]	[0|H4,H6,H7]
+11.546761	[H211|(20.733056,19.668326,8.3658131)]	[0|H4,H6,H7]
+11.578702	[H196|(5.3410559,20.892326,7.6318131)]	[2|H7,H9,H10]
+11.615478	[H553|(19.420056,8.0833259,20.588813)]	[5|H5,H6,H8]
+11.617124	[H595|(8.2750559,16.422326,20.667813)]	[3|H6,H7,H8]
+11.649092	[H499|(21.057056,16.913326,16.623813)]	[0|H4,H6,H7]
+11.77875	[H509|(10.898056,21.075326,17.381813)]	[3|H6,H7,H8]
+11.778818	[H538|(4.3950559,8.3513259,20.843813)]	[11|H9,H10,H11]
+11.791511	[H212|(19.590056,20.667326,8.2848131)]	[0|H4,H6,H7]
+11.803704	[H286|(4.6960559,21.075326,10.504813)]	[11|H9,H10,H11]
+11.814398	[H554|(20.126056,6.8243259,20.112813)]	[5|H5,H6,H8]
+11.822456	[H515|(16.948056,19.512326,17.713813)]	[3|H6,H7,H8]
+11.825297	[H533|(17.724056,4.8013259,20.870813)]	[5|H5,H6,H8]
+11.891577	[H500|(20.037056,18.008326,16.889813)]	[0|H4,H6,H7]
+11.918058	[H605|(16.973056,16.193326,20.483813)]	[3|H6,H7,H8]
+11.926016	[H535|(19.256056,4.6683259,20.077813)]	[5|H5,H6,H8]
+12.071778	[H394|(3.8650559,20.351326,13.528813)]	[11|H9,H10,H11]
+12.095539	[H571|(21.101056,11.040326,19.823813)]	[5|H5,H6,H8]
+12.102745	[H104|(4.0570559,19.524326,4.3958131)]	[2|H7,H9,H10]
+12.103061	[H103|(5.3770559,20.135326,3.9548131)]	[2|H7,H9,H10]
+12.144567	[H514|(18.003056,20.004326,16.735813)]	[5|H5,H6,H8]
+12.256424	[H118|(19.649056,19.601326,4.1258131)]	[3|H6,H7,H8]
+12.315578	[H302|(21.133056,20.424326,10.944813)]	[0|H4,H6,H7]
+12.38815	[H395|(4.8600559,20.927326,14.522813)]	[4|H7,H8,H9]
+12.521228	[H521|(4.9040559,4.6903259,21.082813)]	[11|H9,H10,H11]
+12.573945	[H119|(20.934056,19.620326,4.9368131)]	[0|H4,H6,H7]
+12.574419	[H575|(4.0820559,13.608326,20.763813)]	[7|H8,H9,H11]
+12.590457	[H596|(7.4340559,17.683326,20.783813)]	[3|H6,H7,H8]
+12.622906	[H410|(20.994056,20.363326,13.420813)]	[0|H4,H6,H7]
+12.624738	[H613|(7.7470559,19.779326,19.274813)]	[3|H6,H7,H8]
+12.797415	[H607|(19.796056,17.101326,19.280813)]	[3|H6,H7,H8]
+12.911737	[H502|(3.9560559,19.991326,16.484813)]	[4|H7,H8,H9]
+12.936275	[H604|(17.911056,17.386326,20.575813)]	[3|H6,H7,H8]
+12.984248	[H590|(20.022056,13.683326,21.035813)]	[5|H5,H6,H8]
+13.017624	[H589|(20.750056,14.764326,20.252813)]	[0|H4,H6,H7]
+13.026152	[H503|(5.1730559,20.895326,16.604813)]	[4|H7,H8,H9]
+13.086071	[H592|(4.3170559,16.255326,20.436813)]	[7|H8,H9,H11]
+13.203436	[H619|(13.108056,20.388326,20.382813)]	[3|H6,H7,H8]
+13.29575	[H617|(11.576056,20.116326,20.831813)]	[3|H6,H7,H8]
+13.313967	[H518|(20.700056,20.103326,16.221813)]	[0|H4,H6,H7]
+13.37545	[H536|(20.409056,4.1863259,20.942813)]	[5|H5,H6,H8]
+13.525067	[H608|(20.773056,16.301326,20.126813)]	[0|H4,H6,H7]
+13.602914	[H620|(14.444056,21.027326,20.040813)]	[3|H6,H7,H8]
+13.60526	[H616|(10.285056,20.829326,20.462813)]	[3|H6,H7,H8]
+13.739966	[H623|(17.071056,19.396326,20.696813)]	[3|H6,H7,H8]
+13.847762	[H614|(8.1710559,21.053326,19.987813)]	[3|H6,H7,H8]
+13.952512	[H593|(4.4010559,17.737326,20.766813)]	[4|H7,H8,H9]
+14.060328	[H610|(5.0670559,19.292326,20.232813)]	[3|H6,H7,H8]
+14.399143	[H517|(20.390056,21.066326,17.356813)]	[3|H6,H7,H8]
+14.431564	[H626|(20.119056,19.385326,19.613813)]	[3|H6,H7,H8]
+14.664861	[H622|(17.886056,20.655326,20.447813)]	[3|H6,H7,H8]
+15.433693	[H625|(20.410056,20.874326,19.514813)]	[3|H6,H7,H8]
+15.464089	[H611|(4.7610559,20.553326,21.024813)]	[3|H6,H7,H8]
Index: tests/regression/Analysis/4/pre/test.conf
===================================================================
--- tests/regression/Analysis/4/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Analysis/4/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,699 @@
+# 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)
+25	
+0	25	
+0	0	25	
+
+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	418	1	1.0	3	3	1.00800000000	Hydrogen	H
+Ion_Type2	3	6	1.0	3	3	12.01100000000	Carbon	C
+Ion_Type3	205	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	13.129055911	9.787325879	9.993813099	0 # molecule nr 0
+Ion_Type2_2	11.880055911	10.670325879	9.993813099	0 # molecule nr 1
+Ion_Type2_3	10.631055911	9.787325879	9.993813099	0 # molecule nr 2
+Ion_Type1_1	13.129055911	9.158325879	9.103813099	0 # molecule nr 3
+Ion_Type1_2	13.129055911	9.158325879	10.883813099	0 # molecule nr 4
+Ion_Type1_3	14.019055911	10.416325879	9.993813099	0 # molecule nr 5
+Ion_Type1_4	11.880055911	11.300325879	9.103813099	0 # molecule nr 6
+Ion_Type1_5	11.880055911	11.300325879	10.883813099	0 # molecule nr 7
+Ion_Type1_6	9.741055911	10.416325879	9.993813099	0 # molecule nr 8
+Ion_Type1_7	10.631055911	9.158325879	9.103813099	0 # molecule nr 9
+Ion_Type1_8	10.631055911	9.158325879	10.883813099	0 # molecule nr 10
+Ion_Type3_1	4.712055911	4.678325879	4.643813099	0 # molecule nr 11
+Ion_Type1_9	3.918055911	4.391325879	4.189813099	0 # molecule nr 12
+Ion_Type1_10	5.342055911	4.866325879	3.945813099	0 # molecule nr 13
+Ion_Type3_2	7.812055911	4.678325879	4.643813099	0 # molecule nr 14
+Ion_Type1_11	8.175055911	3.859325879	4.983813099	0 # molecule nr 15
+Ion_Type1_12	6.888055911	4.661325879	4.895813099	0 # molecule nr 16
+Ion_Type3_3	10.912055911	4.678325879	4.643813099	0 # molecule nr 17
+Ion_Type1_13	11.666055911	4.089325879	4.698813099	0 # molecule nr 18
+Ion_Type1_14	10.147055911	4.111325879	4.751813099	0 # molecule nr 19
+Ion_Type3_4	14.012055911	4.678325879	4.643813099	0 # molecule nr 20
+Ion_Type1_15	13.191055911	5.063325879	4.333813099	0 # molecule nr 21
+Ion_Type1_16	13.821055911	3.745325879	4.753813099	0 # molecule nr 22
+Ion_Type3_5	17.112055911	4.678325879	4.643813099	0 # molecule nr 23
+Ion_Type1_17	16.356055911	4.753325879	4.059813099	0 # molecule nr 24
+Ion_Type1_18	17.869055911	4.603325879	4.059813099	0 # molecule nr 25
+Ion_Type3_6	20.212055911	4.678325879	4.643813099	0 # molecule nr 26
+Ion_Type1_19	19.767055911	3.850325879	4.830813099	0 # molecule nr 27
+Ion_Type1_20	20.743055911	4.503325879	3.865813099	0 # molecule nr 28
+Ion_Type3_7	4.712055911	7.778325879	4.643813099	0 # molecule nr 29
+Ion_Type1_21	4.848055911	8.717325879	4.779813099	0 # molecule nr 30
+Ion_Type1_22	4.224055911	7.716325879	3.820813099	0 # molecule nr 31
+Ion_Type3_8	7.812055911	7.778325879	4.643813099	0 # molecule nr 32
+Ion_Type1_23	7.796055911	6.899325879	5.026813099	0 # molecule nr 33
+Ion_Type1_24	8.408055911	8.279325879	5.202813099	0 # molecule nr 34
+Ion_Type3_9	10.912055911	7.778325879	4.643813099	0 # molecule nr 35
+Ion_Type1_25	11.766055911	7.342325879	4.660813099	0 # molecule nr 36
+Ion_Type1_26	10.960055911	8.386325879	3.903813099	0 # molecule nr 37
+Ion_Type3_10	14.012055911	7.778325879	4.643813099	0 # molecule nr 38
+Ion_Type1_27	13.569055911	8.375325879	4.038813099	0 # molecule nr 39
+Ion_Type1_28	14.453055911	7.139325879	4.081813099	0 # molecule nr 40
+Ion_Type3_11	17.112055911	7.778325879	4.643813099	0 # molecule nr 41
+Ion_Type1_29	17.271055911	6.833325879	4.640813099	0 # molecule nr 42
+Ion_Type1_30	17.658055911	8.118325879	5.354813099	0 # molecule nr 43
+Ion_Type3_12	20.212055911	7.778325879	4.643813099	0 # molecule nr 44
+Ion_Type1_31	20.207055911	8.093325879	5.548813099	0 # molecule nr 45
+Ion_Type1_32	19.348055911	8.007325879	4.297813099	0 # molecule nr 46
+Ion_Type3_13	4.712055911	10.878325879	4.643813099	0 # molecule nr 47
+Ion_Type1_33	5.158055911	11.711325879	4.804813099	0 # molecule nr 48
+Ion_Type1_34	3.778055911	11.083325879	4.701813099	0 # molecule nr 49
+Ion_Type3_14	7.812055911	10.878325879	4.643813099	0 # molecule nr 50
+Ion_Type1_35	8.481055911	10.513325879	4.062813099	0 # molecule nr 51
+Ion_Type1_36	7.394055911	11.572325879	4.132813099	0 # molecule nr 52
+Ion_Type3_15	10.912055911	10.878325879	4.643813099	0 # molecule nr 53
+Ion_Type1_37	11.090055911	11.636325879	5.201813099	0 # molecule nr 54
+Ion_Type1_38	10.724055911	11.247325879	3.779813099	0 # molecule nr 55
+Ion_Type3_16	14.012055911	10.878325879	4.643813099	0 # molecule nr 56
+Ion_Type1_39	13.086055911	10.640325879	4.703813099	0 # molecule nr 57
+Ion_Type1_40	14.204055911	11.334325879	5.464813099	0 # molecule nr 58
+Ion_Type3_17	17.112055911	10.878325879	4.643813099	0 # molecule nr 59
+Ion_Type1_41	16.256055911	10.644325879	4.281813099	0 # molecule nr 60
+Ion_Type1_42	17.269055911	10.237325879	5.338813099	0 # molecule nr 61
+Ion_Type3_18	20.212055911	10.878325879	4.643813099	0 # molecule nr 62
+Ion_Type1_43	20.355055911	11.271325879	5.505813099	0 # molecule nr 63
+Ion_Type1_44	19.288055911	10.623325879	4.638813099	0 # molecule nr 64
+Ion_Type3_19	4.712055911	13.978325879	4.643813099	0 # molecule nr 65
+Ion_Type1_45	5.047055911	14.782325879	5.043813099	0 # molecule nr 66
+Ion_Type1_46	4.564055911	13.380325879	5.378813099	0 # molecule nr 67
+Ion_Type3_20	7.812055911	13.978325879	4.643813099	0 # molecule nr 68
+Ion_Type1_47	8.047055911	13.382325879	3.930813099	0 # molecule nr 69
+Ion_Type1_48	7.501055911	14.773325879	4.207813099	0 # molecule nr 70
+Ion_Type3_21	10.912055911	13.978325879	4.643813099	0 # molecule nr 71
+Ion_Type1_49	10.056055911	13.549325879	4.604813099	0 # molecule nr 72
+Ion_Type1_50	11.080055911	14.276325879	3.748813099	0 # molecule nr 73
+Ion_Type3_22	14.012055911	13.978325879	4.643813099	0 # molecule nr 74
+Ion_Type1_51	14.438055911	13.634325879	3.857813099	0 # molecule nr 75
+Ion_Type1_52	13.811055911	13.205325879	5.173813099	0 # molecule nr 76
+Ion_Type3_23	17.112055911	13.978325879	4.643813099	0 # molecule nr 77
+Ion_Type1_53	16.943055911	14.221325879	3.731813099	0 # molecule nr 78
+Ion_Type1_54	17.999055911	14.293325879	4.822813099	0 # molecule nr 79
+Ion_Type3_24	20.212055911	13.978325879	4.643813099	0 # molecule nr 80
+Ion_Type1_55	20.552055911	13.539325879	3.862813099	0 # molecule nr 81
+Ion_Type1_56	19.991055911	13.269325879	5.249813099	0 # molecule nr 82
+Ion_Type3_25	4.712055911	17.078325879	4.643813099	0 # molecule nr 83
+Ion_Type1_57	3.808055911	17.386325879	4.565813099	0 # molecule nr 84
+Ion_Type1_58	5.011055911	16.959325879	3.740813099	0 # molecule nr 85
+Ion_Type3_26	7.812055911	17.078325879	4.643813099	0 # molecule nr 86
+Ion_Type1_59	8.047055911	16.344325879	5.213813099	0 # molecule nr 87
+Ion_Type1_60	7.470055911	17.750325879	5.234813099	0 # molecule nr 88
+Ion_Type3_27	10.912055911	17.078325879	4.643813099	0 # molecule nr 89
+Ion_Type1_61	11.093055911	16.137325879	4.638813099	0 # molecule nr 90
+Ion_Type1_62	10.501055911	17.246325879	5.492813099	0 # molecule nr 91
+Ion_Type3_28	14.012055911	17.078325879	4.643813099	0 # molecule nr 92
+Ion_Type1_63	13.325055911	16.779325879	4.045813099	0 # molecule nr 93
+Ion_Type1_64	13.659055911	16.925325879	5.521813099	0 # molecule nr 94
+Ion_Type3_29	17.112055911	17.078325879	4.643813099	0 # molecule nr 95
+Ion_Type1_65	16.446055911	17.266325879	3.980813099	0 # molecule nr 96
+Ion_Type1_66	17.825055911	16.653325879	4.163813099	0 # molecule nr 97
+Ion_Type3_30	20.212055911	17.078325879	4.643813099	0 # molecule nr 98
+Ion_Type1_67	20.791055911	16.901325879	5.386813099	0 # molecule nr 99
+Ion_Type1_68	19.325055911	16.953325879	4.985813099	0 # molecule nr 100
+Ion_Type3_31	4.712055911	20.178325879	4.643813099	0 # molecule nr 101
+Ion_Type1_69	5.377055911	20.135325879	3.954813099	0 # molecule nr 102
+Ion_Type1_70	4.057055911	19.524325879	4.395813099	0 # molecule nr 103
+Ion_Type3_32	7.812055911	20.178325879	4.643813099	0 # molecule nr 104
+Ion_Type1_71	8.144055911	20.094325879	5.538813099	0 # molecule nr 105
+Ion_Type1_72	8.551055911	19.937325879	4.082813099	0 # molecule nr 106
+Ion_Type3_33	10.912055911	20.178325879	4.643813099	0 # molecule nr 107
+Ion_Type1_73	10.497055911	20.644325879	5.370813099	0 # molecule nr 108
+Ion_Type1_74	11.529055911	20.807325879	4.267813099	0 # molecule nr 109
+Ion_Type3_34	14.012055911	20.178325879	4.643813099	0 # molecule nr 110
+Ion_Type1_75	13.188055911	20.471325879	5.035813099	0 # molecule nr 111
+Ion_Type1_76	14.592055911	20.007325879	5.386813099	0 # molecule nr 112
+Ion_Type3_35	17.112055911	20.178325879	4.643813099	0 # molecule nr 113
+Ion_Type1_77	16.790055911	20.064325879	5.538813099	0 # molecule nr 114
+Ion_Type1_78	16.966055911	19.331325879	4.218813099	0 # molecule nr 115
+Ion_Type3_36	20.212055911	20.178325879	4.643813099	0 # molecule nr 116
+Ion_Type1_79	19.649055911	19.601325879	4.125813099	0 # molecule nr 117
+Ion_Type1_80	20.934055911	19.620325879	4.936813099	0 # molecule nr 118
+Ion_Type3_37	4.712055911	4.678325879	7.743813099	0 # molecule nr 119
+Ion_Type1_81	3.930055911	4.142325879	7.887813099	0 # molecule nr 120
+Ion_Type1_82	4.479055911	5.548325879	8.072813099	0 # molecule nr 121
+Ion_Type3_38	7.812055911	4.678325879	7.743813099	0 # molecule nr 122
+Ion_Type1_83	7.412055911	4.536325879	6.884813099	0 # molecule nr 123
+Ion_Type1_84	8.137055911	3.817325879	8.009813099	0 # molecule nr 124
+Ion_Type3_39	10.912055911	4.678325879	7.743813099	0 # molecule nr 125
+Ion_Type1_85	10.577055911	5.494325879	8.118813099	0 # molecule nr 126
+Ion_Type1_86	11.103055911	4.120325879	8.498813099	0 # molecule nr 127
+Ion_Type3_40	14.012055911	4.678325879	7.743813099	0 # molecule nr 128
+Ion_Type1_87	14.510055911	5.177325879	7.094813099	0 # molecule nr 129
+Ion_Type1_88	13.769055911	3.866325879	7.296813099	0 # molecule nr 130
+Ion_Type3_41	17.112055911	4.678325879	7.743813099	0 # molecule nr 131
+Ion_Type1_89	17.448055911	5.298325879	7.093813099	0 # molecule nr 132
+Ion_Type1_90	17.028055911	3.848325879	7.272813099	0 # molecule nr 133
+Ion_Type3_42	20.212055911	4.678325879	7.743813099	0 # molecule nr 134
+Ion_Type1_91	19.303055911	4.655325879	8.045813099	0 # molecule nr 135
+Ion_Type1_92	20.727055911	4.878325879	8.526813099	0 # molecule nr 136
+Ion_Type3_43	4.712055911	7.778325879	7.743813099	0 # molecule nr 137
+Ion_Type1_93	4.387055911	7.912325879	8.635813099	0 # molecule nr 138
+Ion_Type1_94	4.490055911	6.870325879	7.533813099	0 # molecule nr 139
+Ion_Type3_44	7.812055911	7.778325879	7.743813099	0 # molecule nr 140
+Ion_Type1_95	8.287055911	6.951325879	7.646813099	0 # molecule nr 141
+Ion_Type1_96	6.936055911	7.526325879	8.040813099	0 # molecule nr 142
+Ion_Type3_45	17.112055911	7.778325879	7.743813099	0 # molecule nr 143
+Ion_Type1_97	17.466055911	7.073325879	7.199813099	0 # molecule nr 144
+Ion_Type1_98	16.710055911	8.390325879	7.124813099	0 # molecule nr 145
+Ion_Type3_46	20.212055911	7.778325879	7.743813099	0 # molecule nr 146
+Ion_Type1_99	21.150055911	7.756325879	7.549813099	0 # molecule nr 147
+Ion_Type1_100	19.794055911	8.016325879	6.914813099	0 # molecule nr 148
+Ion_Type3_47	4.712055911	10.878325879	7.743813099	0 # molecule nr 149
+Ion_Type1_101	5.053055911	10.092325879	7.313813099	0 # molecule nr 150
+Ion_Type1_102	4.710055911	11.551325879	7.061813099	0 # molecule nr 151
+Ion_Type3_48	17.112055911	10.878325879	7.743813099	0 # molecule nr 152
+Ion_Type1_103	17.481055911	10.051325879	8.057813099	0 # molecule nr 153
+Ion_Type1_104	17.812055911	11.522325879	7.863813099	0 # molecule nr 154
+Ion_Type3_49	20.212055911	10.878325879	7.743813099	0 # molecule nr 155
+Ion_Type1_105	20.293055911	10.517325879	6.859813099	0 # molecule nr 156
+Ion_Type1_106	20.016055911	10.124325879	8.301813099	0 # molecule nr 157
+Ion_Type3_50	4.712055911	13.978325879	7.743813099	0 # molecule nr 158
+Ion_Type1_107	4.195055911	14.461325879	8.390813099	0 # molecule nr 159
+Ion_Type1_108	4.511055911	14.397325879	6.905813099	0 # molecule nr 160
+Ion_Type3_51	7.812055911	13.978325879	7.743813099	0 # molecule nr 161
+Ion_Type1_109	7.204055911	13.586325879	7.114813099	0 # molecule nr 162
+Ion_Type1_110	8.679055911	13.674325879	7.470813099	0 # molecule nr 163
+Ion_Type3_52	10.912055911	13.978325879	7.743813099	0 # molecule nr 164
+Ion_Type1_111	11.010055911	14.867325879	8.088813099	0 # molecule nr 165
+Ion_Type1_112	10.662055911	14.095325879	6.825813099	0 # molecule nr 166
+Ion_Type3_53	14.012055911	13.978325879	7.743813099	0 # molecule nr 167
+Ion_Type1_113	14.699055911	14.453325879	7.273813099	0 # molecule nr 168
+Ion_Type1_114	13.229055911	14.523325879	7.651813099	0 # molecule nr 169
+Ion_Type3_54	17.112055911	13.978325879	7.743813099	0 # molecule nr 170
+Ion_Type1_115	17.451055911	13.084325879	7.811813099	0 # molecule nr 171
+Ion_Type1_116	16.301055911	13.897325879	7.238813099	0 # molecule nr 172
+Ion_Type3_55	20.212055911	13.978325879	7.743813099	0 # molecule nr 173
+Ion_Type1_117	20.698055911	14.646325879	8.229813099	0 # molecule nr 174
+Ion_Type1_118	19.810055911	13.427325879	8.416813099	0 # molecule nr 175
+Ion_Type3_56	4.712055911	17.078325879	7.743813099	0 # molecule nr 176
+Ion_Type1_119	5.077055911	17.815325879	7.251813099	0 # molecule nr 177
+Ion_Type1_120	4.370055911	16.481325879	7.076813099	0 # molecule nr 178
+Ion_Type3_57	7.812055911	17.078325879	7.743813099	0 # molecule nr 179
+Ion_Type1_121	8.424055911	17.442325879	8.385813099	0 # molecule nr 180
+Ion_Type1_122	7.241055911	16.498325879	8.249813099	0 # molecule nr 181
+Ion_Type3_58	10.912055911	17.078325879	7.743813099	0 # molecule nr 182
+Ion_Type1_123	10.007055911	17.384325879	7.666813099	0 # molecule nr 183
+Ion_Type1_124	11.407055911	17.611325879	7.119813099	0 # molecule nr 184
+Ion_Type3_59	14.012055911	17.078325879	7.743813099	0 # molecule nr 185
+Ion_Type1_125	13.405055911	17.509325879	8.346813099	0 # molecule nr 186
+Ion_Type1_126	14.737055911	16.780325879	8.294813099	0 # molecule nr 187
+Ion_Type3_60	17.112055911	17.078325879	7.743813099	0 # molecule nr 188
+Ion_Type1_127	16.589055911	16.402325879	8.177813099	0 # molecule nr 189
+Ion_Type1_128	17.545055911	16.627325879	7.017813099	0 # molecule nr 190
+Ion_Type3_61	20.212055911	17.078325879	7.743813099	0 # molecule nr 191
+Ion_Type1_129	20.164055911	16.759325879	8.646813099	0 # molecule nr 192
+Ion_Type1_130	20.747055911	17.872325879	7.790813099	0 # molecule nr 193
+Ion_Type3_62	4.712055911	20.178325879	7.743813099	0 # molecule nr 194
+Ion_Type1_131	5.341055911	20.892325879	7.631813099	0 # molecule nr 195
+Ion_Type1_132	5.065055911	19.455325879	7.222813099	0 # molecule nr 196
+Ion_Type3_63	7.812055911	20.178325879	7.743813099	0 # molecule nr 197
+Ion_Type1_133	7.130055911	19.822325879	8.315813099	0 # molecule nr 198
+Ion_Type1_134	8.438055911	20.597325879	8.336813099	0 # molecule nr 199
+Ion_Type3_64	10.912055911	20.178325879	7.743813099	0 # molecule nr 200
+Ion_Type1_135	11.157055911	19.403325879	7.235813099	0 # molecule nr 201
+Ion_Type1_136	10.224055911	19.876325879	8.338813099	0 # molecule nr 202
+Ion_Type3_65	14.012055911	20.178325879	7.743813099	0 # molecule nr 203
+Ion_Type1_137	14.394055911	20.411325879	8.590813099	0 # molecule nr 204
+Ion_Type1_138	14.363055911	19.308325879	7.545813099	0 # molecule nr 205
+Ion_Type3_66	17.112055911	20.178325879	7.743813099	0 # molecule nr 206
+Ion_Type1_139	17.165055911	19.460325879	8.375813099	0 # molecule nr 207
+Ion_Type1_140	17.262055911	20.972325879	8.258813099	0 # molecule nr 208
+Ion_Type3_67	20.212055911	20.178325879	7.743813099	0 # molecule nr 209
+Ion_Type1_141	20.733055911	19.668325879	8.365813099	0 # molecule nr 210
+Ion_Type1_142	19.590055911	20.667325879	8.284813099	0 # molecule nr 211
+Ion_Type3_68	4.712055911	4.678325879	10.843813099	0 # molecule nr 212
+Ion_Type1_143	4.032055911	4.289325879	11.395813099	0 # molecule nr 213
+Ion_Type1_144	5.537055911	4.476325879	11.287813099	0 # molecule nr 214
+Ion_Type3_69	7.812055911	4.678325879	10.843813099	0 # molecule nr 215
+Ion_Type1_145	8.346055911	5.022325879	10.125813099	0 # molecule nr 216
+Ion_Type1_146	7.478055911	5.454325879	11.296813099	0 # molecule nr 217
+Ion_Type3_70	10.912055911	4.678325879	10.843813099	0 # molecule nr 218
+Ion_Type1_147	10.694055911	5.401325879	11.433813099	0 # molecule nr 219
+Ion_Type1_148	11.251055911	3.987325879	11.414813099	0 # molecule nr 220
+Ion_Type3_71	14.012055911	4.678325879	10.843813099	0 # molecule nr 221
+Ion_Type1_149	13.430055911	5.149325879	11.441813099	0 # molecule nr 222
+Ion_Type1_150	14.564055911	4.137325879	11.410813099	0 # molecule nr 223
+Ion_Type3_72	17.112055911	4.678325879	10.843813099	0 # molecule nr 224
+Ion_Type1_151	16.343055911	4.783325879	11.405813099	0 # molecule nr 225
+Ion_Type1_152	17.815055911	4.408325879	11.436813099	0 # molecule nr 226
+Ion_Type3_73	20.212055911	4.678325879	10.843813099	0 # molecule nr 227
+Ion_Type1_153	19.473055911	4.726325879	10.235813099	0 # molecule nr 228
+Ion_Type1_154	20.991055911	4.677325879	10.285813099	0 # molecule nr 229
+Ion_Type3_74	4.712055911	7.778325879	10.843813099	0 # molecule nr 230
+Ion_Type1_155	5.403055911	7.125325879	10.961813099	0 # molecule nr 231
+Ion_Type1_156	4.567055911	8.145325879	11.716813099	0 # molecule nr 232
+Ion_Type3_75	7.812055911	7.778325879	10.843813099	0 # molecule nr 233
+Ion_Type1_157	7.844055911	7.097325879	11.517813099	0 # molecule nr 234
+Ion_Type1_158	8.685055911	8.173325879	10.850813099	0 # molecule nr 235
+Ion_Type3_76	17.112055911	7.778325879	10.843813099	0 # molecule nr 236
+Ion_Type1_159	16.418055911	8.376325879	10.561813099	0 # molecule nr 237
+Ion_Type1_160	17.915055911	8.301325879	10.814813099	0 # molecule nr 238
+Ion_Type3_77	20.212055911	7.778325879	10.843813099	0 # molecule nr 239
+Ion_Type1_161	19.737055911	6.949325879	10.764813099	0 # molecule nr 240
+Ion_Type1_162	21.073055911	7.537325879	11.188813099	0 # molecule nr 241
+Ion_Type3_78	4.712055911	10.878325879	10.843813099	0 # molecule nr 242
+Ion_Type1_163	5.208055911	10.202325879	10.380813099	0 # molecule nr 243
+Ion_Type1_164	4.513055911	10.495325879	11.699813099	0 # molecule nr 244
+Ion_Type3_79	17.112055911	10.878325879	10.843813099	0 # molecule nr 245
+Ion_Type1_165	16.783055911	10.073325879	11.247813099	0 # molecule nr 246
+Ion_Type1_166	17.116055911	11.525325879	11.550813099	0 # molecule nr 247
+Ion_Type3_80	20.212055911	10.878325879	10.843813099	0 # molecule nr 248
+Ion_Type1_167	20.130055911	10.400325879	10.016813099	0 # molecule nr 249
+Ion_Type1_168	19.698055911	11.677325879	10.718813099	0 # molecule nr 250
+Ion_Type3_81	4.712055911	13.978325879	10.843813099	0 # molecule nr 251
+Ion_Type1_169	3.919055911	14.136325879	11.358813099	0 # molecule nr 252
+Ion_Type1_170	4.960055911	14.839325879	10.501813099	0 # molecule nr 253
+Ion_Type3_82	7.812055911	13.978325879	10.843813099	0 # molecule nr 254
+Ion_Type1_171	7.778055911	14.779325879	11.368813099	0 # molecule nr 255
+Ion_Type1_172	8.050055911	13.287325879	11.463813099	0 # molecule nr 256
+Ion_Type3_83	14.012055911	13.978325879	10.843813099	0 # molecule nr 257
+Ion_Type1_173	14.819055911	14.416325879	10.568813099	0 # molecule nr 258
+Ion_Type1_174	13.453055911	13.979325879	10.064813099	0 # molecule nr 259
+Ion_Type3_84	17.112055911	13.978325879	10.843813099	0 # molecule nr 260
+Ion_Type1_175	17.521055911	14.826325879	11.023813099	0 # molecule nr 261
+Ion_Type1_176	17.243055911	13.466325879	11.643813099	0 # molecule nr 262
+Ion_Type3_85	20.212055911	13.978325879	10.843813099	0 # molecule nr 263
+Ion_Type1_177	19.464055911	14.532325879	10.615813099	0 # molecule nr 264
+Ion_Type1_178	20.940055911	14.320325879	10.321813099	0 # molecule nr 265
+Ion_Type3_86	4.712055911	17.078325879	10.843813099	0 # molecule nr 266
+Ion_Type1_179	5.410055911	17.656325879	11.156813099	0 # molecule nr 267
+Ion_Type1_180	3.970055911	17.249325879	11.425813099	0 # molecule nr 268
+Ion_Type3_87	7.812055911	17.078325879	10.843813099	0 # molecule nr 269
+Ion_Type1_181	7.726055911	16.501325879	10.083813099	0 # molecule nr 270
+Ion_Type1_182	8.157055911	16.518325879	11.540813099	0 # molecule nr 271
+Ion_Type3_88	10.912055911	17.078325879	10.843813099	0 # molecule nr 272
+Ion_Type1_183	10.789055911	17.984325879	11.131813099	0 # molecule nr 273
+Ion_Type1_184	10.874055911	16.556325879	11.646813099	0 # molecule nr 274
+Ion_Type3_89	14.012055911	17.078325879	10.843813099	0 # molecule nr 275
+Ion_Type1_185	13.690055911	16.555325879	11.579813099	0 # molecule nr 276
+Ion_Type1_186	13.539055911	16.746325879	10.078813099	0 # molecule nr 277
+Ion_Type3_90	17.112055911	17.078325879	10.843813099	0 # molecule nr 278
+Ion_Type1_187	18.028055911	16.966325879	10.584813099	0 # molecule nr 279
+Ion_Type1_188	16.629055911	16.430325879	10.328813099	0 # molecule nr 280
+Ion_Type3_91	20.212055911	17.078325879	10.843813099	0 # molecule nr 281
+Ion_Type1_189	19.295055911	17.314325879	10.992813099	0 # molecule nr 282
+Ion_Type1_190	20.569055911	17.795325879	10.316813099	0 # molecule nr 283
+Ion_Type3_92	4.712055911	20.178325879	10.843813099	0 # molecule nr 284
+Ion_Type1_191	4.696055911	21.075325879	10.504813099	0 # molecule nr 285
+Ion_Type1_192	3.803055911	19.989325879	11.082813099	0 # molecule nr 286
+Ion_Type3_93	7.812055911	20.178325879	10.843813099	0 # molecule nr 287
+Ion_Type1_193	8.064055911	20.227325879	11.766813099	0 # molecule nr 288
+Ion_Type1_194	8.171055911	20.973325879	10.446813099	0 # molecule nr 289
+Ion_Type3_94	10.912055911	20.178325879	10.843813099	0 # molecule nr 290
+Ion_Type1_195	11.792055911	19.953325879	10.537813099	0 # molecule nr 291
+Ion_Type1_196	10.443055911	19.343325879	10.883813099	0 # molecule nr 292
+Ion_Type3_95	14.012055911	20.178325879	10.843813099	0 # molecule nr 293
+Ion_Type1_197	14.579055911	20.084325879	10.076813099	0 # molecule nr 294
+Ion_Type1_198	14.352055911	20.943325879	11.309813099	0 # molecule nr 295
+Ion_Type3_96	17.112055911	20.178325879	10.843813099	0 # molecule nr 296
+Ion_Type1_199	16.862055911	21.099325879	10.933813099	0 # molecule nr 297
+Ion_Type1_200	16.336055911	19.684325879	11.112813099	0 # molecule nr 298
+Ion_Type3_97	20.212055911	20.178325879	10.843813099	0 # molecule nr 299
+Ion_Type1_201	20.061055911	20.172325879	9.897813099	0 # molecule nr 300
+Ion_Type1_202	21.133055911	20.424325879	10.944813099	0 # molecule nr 301
+Ion_Type3_98	4.712055911	4.678325879	13.943813099	0 # molecule nr 302
+Ion_Type1_203	4.935055911	4.130325879	13.188813099	0 # molecule nr 303
+Ion_Type1_204	4.383055911	5.495325879	13.566813099	0 # molecule nr 304
+Ion_Type3_99	7.812055911	4.678325879	13.943813099	0 # molecule nr 305
+Ion_Type1_205	6.907055911	4.362325879	13.920813099	0 # molecule nr 306
+Ion_Type1_206	8.344055911	3.920325879	13.696813099	0 # molecule nr 307
+Ion_Type3_100	10.912055911	4.678325879	13.943813099	0 # molecule nr 308
+Ion_Type1_207	10.397055911	5.173325879	13.304813099	0 # molecule nr 309
+Ion_Type1_208	10.264055911	4.253325879	14.507813099	0 # molecule nr 310
+Ion_Type3_101	14.012055911	4.678325879	13.943813099	0 # molecule nr 311
+Ion_Type1_209	13.570055911	5.410325879	13.510813099	0 # molecule nr 312
+Ion_Type1_210	14.888055911	4.654325879	13.556813099	0 # molecule nr 313
+Ion_Type3_102	17.112055911	4.678325879	13.943813099	0 # molecule nr 314
+Ion_Type1_211	17.446055911	4.032325879	13.319813099	0 # molecule nr 315
+Ion_Type1_212	16.300055911	5.002325879	13.551813099	0 # molecule nr 316
+Ion_Type3_103	20.212055911	4.678325879	13.943813099	0 # molecule nr 317
+Ion_Type1_213	20.244055911	5.534325879	14.374813099	0 # molecule nr 318
+Ion_Type1_214	19.306055911	4.383325879	14.046813099	0 # molecule nr 319
+Ion_Type3_104	4.712055911	7.778325879	13.943813099	0 # molecule nr 320
+Ion_Type1_215	3.774055911	7.739325879	13.750813099	0 # molecule nr 321
+Ion_Type1_216	4.767055911	7.787325879	14.900813099	0 # molecule nr 322
+Ion_Type3_105	7.812055911	7.778325879	13.943813099	0 # molecule nr 323
+Ion_Type1_217	7.213055911	8.400325879	13.527813099	0 # molecule nr 324
+Ion_Type1_218	7.609055911	7.828325879	14.878813099	0 # molecule nr 325
+Ion_Type3_106	10.912055911	7.778325879	13.943813099	0 # molecule nr 326
+Ion_Type1_219	11.038055911	8.167325879	13.076813099	0 # molecule nr 327
+Ion_Type1_220	10.670055911	6.866325879	13.772813099	0 # molecule nr 328
+Ion_Type3_107	14.012055911	7.778325879	13.943813099	0 # molecule nr 329
+Ion_Type1_221	14.408055911	7.061325879	13.446813099	0 # molecule nr 330
+Ion_Type1_222	13.742055911	8.417325879	13.282813099	0 # molecule nr 331
+Ion_Type3_108	17.112055911	7.778325879	13.943813099	0 # molecule nr 332
+Ion_Type1_223	17.509055911	7.709325879	14.812813099	0 # molecule nr 333
+Ion_Type1_224	17.442055911	7.019325879	13.460813099	0 # molecule nr 334
+Ion_Type3_109	20.212055911	7.778325879	13.943813099	0 # molecule nr 335
+Ion_Type1_225	19.646055911	7.020325879	13.790813099	0 # molecule nr 336
+Ion_Type1_226	19.841055911	8.212325879	14.713813099	0 # molecule nr 337
+Ion_Type3_110	4.712055911	10.878325879	13.943813099	0 # molecule nr 338
+Ion_Type1_227	4.120055911	10.944325879	13.192813099	0 # molecule nr 339
+Ion_Type1_228	5.038055911	9.977325879	13.921813099	0 # molecule nr 340
+Ion_Type3_111	7.812055911	10.878325879	13.943813099	0 # molecule nr 341
+Ion_Type1_229	7.878055911	10.404325879	14.773813099	0 # molecule nr 342
+Ion_Type1_230	8.696055911	11.208325879	13.777813099	0 # molecule nr 343
+Ion_Type3_112	10.912055911	10.878325879	13.943813099	0 # molecule nr 344
+Ion_Type1_231	10.159055911	10.824325879	13.352813099	0 # molecule nr 345
+Ion_Type1_232	11.674055911	10.949325879	13.366813099	0 # molecule nr 346
+Ion_Type3_113	14.012055911	10.878325879	13.943813099	0 # molecule nr 347
+Ion_Type1_233	14.631055911	11.542325879	14.250813099	0 # molecule nr 348
+Ion_Type1_234	14.091055911	10.158325879	14.571813099	0 # molecule nr 349
+Ion_Type3_114	17.112055911	10.878325879	13.943813099	0 # molecule nr 350
+Ion_Type1_235	16.365055911	11.149325879	13.407813099	0 # molecule nr 351
+Ion_Type1_236	17.799055911	10.652325879	13.313813099	0 # molecule nr 352
+Ion_Type3_115	20.212055911	10.878325879	13.943813099	0 # molecule nr 353
+Ion_Type1_237	20.100055911	10.855325879	12.991813099	0 # molecule nr 354
+Ion_Type1_238	19.712055911	10.128325879	14.269813099	0 # molecule nr 355
+Ion_Type3_116	4.712055911	13.978325879	13.943813099	0 # molecule nr 356
+Ion_Type1_239	4.938055911	13.274325879	13.333813099	0 # molecule nr 357
+Ion_Type1_240	4.388055911	14.690325879	13.389813099	0 # molecule nr 358
+Ion_Type3_117	7.812055911	13.978325879	13.943813099	0 # molecule nr 359
+Ion_Type1_241	7.457055911	13.320325879	14.543813099	0 # molecule nr 360
+Ion_Type1_242	8.272055911	14.602325879	14.506813099	0 # molecule nr 361
+Ion_Type3_118	10.912055911	13.978325879	13.943813099	0 # molecule nr 362
+Ion_Type1_243	11.399055911	14.794325879	14.064813099	0 # molecule nr 363
+Ion_Type1_244	11.316055911	13.560325879	13.181813099	0 # molecule nr 364
+Ion_Type3_119	14.012055911	13.978325879	13.943813099	0 # molecule nr 365
+Ion_Type1_245	14.261055911	14.903325879	13.986813099	0 # molecule nr 366
+Ion_Type1_246	14.540055911	13.549325879	14.618813099	0 # molecule nr 367
+Ion_Type3_120	17.112055911	13.978325879	13.943813099	0 # molecule nr 368
+Ion_Type1_247	17.205055911	14.906325879	13.722813099	0 # molecule nr 369
+Ion_Type1_248	17.515055911	13.888325879	14.808813099	0 # molecule nr 370
+Ion_Type3_121	20.212055911	13.978325879	13.943813099	0 # molecule nr 371
+Ion_Type1_249	20.242055911	13.786325879	13.004813099	0 # molecule nr 372
+Ion_Type1_250	20.853055911	13.384325879	14.337813099	0 # molecule nr 373
+Ion_Type3_122	4.712055911	17.078325879	13.943813099	0 # molecule nr 374
+Ion_Type1_251	4.694055911	18.021325879	14.113813099	0 # molecule nr 375
+Ion_Type1_252	4.869055911	17.000325879	13.001813099	0 # molecule nr 376
+Ion_Type3_123	7.812055911	17.078325879	13.943813099	0 # molecule nr 377
+Ion_Type1_253	8.488055911	17.210325879	13.276813099	0 # molecule nr 378
+Ion_Type1_254	7.709055911	17.934325879	14.363813099	0 # molecule nr 379
+Ion_Type3_124	10.912055911	17.078325879	13.943813099	0 # molecule nr 380
+Ion_Type1_255	11.763055911	17.187325879	13.516813099	0 # molecule nr 381
+Ion_Type1_256	11.010055911	16.300325879	14.494813099	0 # molecule nr 382
+Ion_Type3_125	14.012055911	17.078325879	13.943813099	0 # molecule nr 383
+Ion_Type1_257	13.773055911	17.965325879	13.670813099	0 # molecule nr 384
+Ion_Type1_258	14.003055911	16.560325879	13.136813099	0 # molecule nr 385
+Ion_Type3_126	17.112055911	17.078325879	13.943813099	0 # molecule nr 386
+Ion_Type1_259	16.358055911	16.914325879	14.512813099	0 # molecule nr 387
+Ion_Type1_260	16.818055911	16.829325879	13.065813099	0 # molecule nr 388
+Ion_Type3_127	20.212055911	17.078325879	13.943813099	0 # molecule nr 389
+Ion_Type1_261	19.322055911	16.928325879	14.265813099	0 # molecule nr 390
+Ion_Type1_262	20.181055911	17.939325879	13.523813099	0 # molecule nr 391
+Ion_Type3_128	4.712055911	20.178325879	13.943813099	0 # molecule nr 392
+Ion_Type1_263	3.865055911	20.351325879	13.528813099	0 # molecule nr 393
+Ion_Type1_264	4.860055911	20.927325879	14.522813099	0 # molecule nr 394
+Ion_Type3_129	7.812055911	20.178325879	13.943813099	0 # molecule nr 395
+Ion_Type1_265	8.073055911	19.390325879	14.421813099	0 # molecule nr 396
+Ion_Type1_266	8.031055911	20.905325879	14.528813099	0 # molecule nr 397
+Ion_Type3_130	10.912055911	20.178325879	13.943813099	0 # molecule nr 398
+Ion_Type1_267	10.153055911	19.688325879	13.623813099	0 # molecule nr 399
+Ion_Type1_268	11.599055911	20.019325879	13.294813099	0 # molecule nr 400
+Ion_Type3_131	14.012055911	20.178325879	13.943813099	0 # molecule nr 401
+Ion_Type1_269	14.304055911	19.764325879	13.129813099	0 # molecule nr 402
+Ion_Type1_270	13.344055911	20.810325879	13.673813099	0 # molecule nr 403
+Ion_Type3_132	17.112055911	20.178325879	13.943813099	0 # molecule nr 404
+Ion_Type1_271	18.070055911	20.209325879	13.925813099	0 # molecule nr 405
+Ion_Type1_272	16.842055911	21.053325879	14.226813099	0 # molecule nr 406
+Ion_Type3_133	20.212055911	20.178325879	13.943813099	0 # molecule nr 407
+Ion_Type1_273	19.585055911	19.801325879	13.324813099	0 # molecule nr 408
+Ion_Type1_274	20.994055911	20.363325879	13.420813099	0 # molecule nr 409
+Ion_Type3_134	4.712055911	4.678325879	17.043813099	0 # molecule nr 410
+Ion_Type1_275	5.231055911	4.800325879	17.839813099	0 # molecule nr 411
+Ion_Type1_276	3.808055911	4.590325879	17.349813099	0 # molecule nr 412
+Ion_Type3_135	7.812055911	4.678325879	17.043813099	0 # molecule nr 413
+Ion_Type1_277	7.754055911	4.254325879	16.186813099	0 # molecule nr 414
+Ion_Type1_278	7.577055911	5.593325879	16.882813099	0 # molecule nr 415
+Ion_Type3_136	10.912055911	4.678325879	17.043813099	0 # molecule nr 416
+Ion_Type1_279	11.288055911	3.985325879	17.588813099	0 # molecule nr 417
+Ion_Type1_280	10.511055911	5.289325879	17.663813099	0 # molecule nr 418
+Ion_Type3_137	14.012055911	4.678325879	17.043813099	0 # molecule nr 419
+Ion_Type1_281	14.323055911	5.443325879	16.557813099	0 # molecule nr 420
+Ion_Type1_282	14.550055911	4.654325879	17.836813099	0 # molecule nr 421
+Ion_Type3_138	17.112055911	4.678325879	17.043813099	0 # molecule nr 422
+Ion_Type1_283	16.669055911	4.557325879	17.884813099	0 # molecule nr 423
+Ion_Type1_284	18.044055911	4.568325879	17.237813099	0 # molecule nr 424
+Ion_Type3_139	20.212055911	4.678325879	17.043813099	0 # molecule nr 425
+Ion_Type1_285	19.425055911	4.164325879	16.858813099	0 # molecule nr 426
+Ion_Type1_286	19.904055911	5.423325879	17.562813099	0 # molecule nr 427
+Ion_Type3_140	4.712055911	7.778325879	17.043813099	0 # molecule nr 428
+Ion_Type1_287	4.346055911	7.018325879	16.587813099	0 # molecule nr 429
+Ion_Type1_288	4.913055911	8.408325879	16.350813099	0 # molecule nr 430
+Ion_Type3_141	7.812055911	7.778325879	17.043813099	0 # molecule nr 431
+Ion_Type1_289	7.033055911	8.332325879	16.978813099	0 # molecule nr 432
+Ion_Type1_290	8.407055911	8.108325879	16.368813099	0 # molecule nr 433
+Ion_Type3_142	10.912055911	7.778325879	17.043813099	0 # molecule nr 434
+Ion_Type1_291	11.247055911	8.215325879	17.828813099	0 # molecule nr 435
+Ion_Type1_292	11.693055911	7.513325879	16.555813099	0 # molecule nr 436
+Ion_Type3_143	14.012055911	7.778325879	17.043813099	0 # molecule nr 437
+Ion_Type1_293	14.510055911	8.538325879	16.739813099	0 # molecule nr 438
+Ion_Type1_294	13.961055911	7.881325879	17.995813099	0 # molecule nr 439
+Ion_Type3_144	17.112055911	7.778325879	17.043813099	0 # molecule nr 440
+Ion_Type1_295	18.008055911	8.116325879	17.081813099	0 # molecule nr 441
+Ion_Type1_296	16.769055911	7.887325879	17.932813099	0 # molecule nr 442
+Ion_Type3_145	20.212055911	7.778325879	17.043813099	0 # molecule nr 443
+Ion_Type1_297	20.173055911	7.358325879	16.182813099	0 # molecule nr 444
+Ion_Type1_298	20.429055911	8.694325879	16.861813099	0 # molecule nr 445
+Ion_Type3_146	4.712055911	10.878325879	17.043813099	0 # molecule nr 446
+Ion_Type1_299	4.015055911	10.812325879	16.389813099	0 # molecule nr 447
+Ion_Type1_300	4.468055911	11.627325879	17.589813099	0 # molecule nr 448
+Ion_Type3_147	7.812055911	10.878325879	17.043813099	0 # molecule nr 449
+Ion_Type1_301	7.429055911	10.108325879	17.465813099	0 # molecule nr 450
+Ion_Type1_302	7.153055911	11.166325879	16.410813099	0 # molecule nr 451
+Ion_Type3_148	10.912055911	10.878325879	17.043813099	0 # molecule nr 452
+Ion_Type1_303	10.867055911	10.602325879	16.126813099	0 # molecule nr 453
+Ion_Type1_304	10.263055911	11.579325879	17.122813099	0 # molecule nr 454
+Ion_Type3_149	14.012055911	10.878325879	17.043813099	0 # molecule nr 455
+Ion_Type1_305	14.937055911	10.906325879	17.291813099	0 # molecule nr 456
+Ion_Type1_306	13.560055911	10.536325879	17.816813099	0 # molecule nr 457
+Ion_Type3_150	17.112055911	10.878325879	17.043813099	0 # molecule nr 458
+Ion_Type1_307	17.687055911	10.236325879	16.623813099	0 # molecule nr 459
+Ion_Type1_308	17.250055911	11.690325879	16.554813099	0 # molecule nr 460
+Ion_Type3_151	20.212055911	10.878325879	17.043813099	0 # molecule nr 461
+Ion_Type1_309	20.830055911	10.357325879	17.557813099	0 # molecule nr 462
+Ion_Type1_310	19.569055911	10.247325879	16.716813099	0 # molecule nr 463
+Ion_Type3_152	4.712055911	13.978325879	17.043813099	0 # molecule nr 464
+Ion_Type1_311	3.945055911	13.563325879	17.440813099	0 # molecule nr 465
+Ion_Type1_312	5.309055911	14.144325879	17.774813099	0 # molecule nr 466
+Ion_Type3_153	7.812055911	13.978325879	17.043813099	0 # molecule nr 467
+Ion_Type1_313	8.341055911	13.376325879	16.518813099	0 # molecule nr 468
+Ion_Type1_314	7.245055911	14.423325879	16.412813099	0 # molecule nr 469
+Ion_Type3_154	10.912055911	13.978325879	17.043813099	0 # molecule nr 470
+Ion_Type1_315	10.623055911	13.765325879	16.154813099	0 # molecule nr 471
+Ion_Type1_316	10.845055911	13.154325879	17.528813099	0 # molecule nr 472
+Ion_Type3_155	14.012055911	13.978325879	17.043813099	0 # molecule nr 473
+Ion_Type1_317	13.846055911	14.578325879	16.315813099	0 # molecule nr 474
+Ion_Type1_318	14.443055911	13.220325879	16.644813099	0 # molecule nr 475
+Ion_Type3_156	17.112055911	13.978325879	17.043813099	0 # molecule nr 476
+Ion_Type1_319	16.806055911	14.389325879	16.233813099	0 # molecule nr 477
+Ion_Type1_320	17.963055911	13.598325879	16.821813099	0 # molecule nr 478
+Ion_Type3_157	20.212055911	13.978325879	17.043813099	0 # molecule nr 479
+Ion_Type1_321	20.831055911	14.049325879	17.771813099	0 # molecule nr 480
+Ion_Type1_322	19.433055911	14.454325879	17.334813099	0 # molecule nr 481
+Ion_Type3_158	4.712055911	17.078325879	17.043813099	0 # molecule nr 482
+Ion_Type1_323	4.123055911	17.557325879	16.459813099	0 # molecule nr 483
+Ion_Type1_324	5.294055911	16.589325879	16.459813099	0 # molecule nr 484
+Ion_Type3_159	7.812055911	17.078325879	17.043813099	0 # molecule nr 485
+Ion_Type1_325	8.042055911	17.462325879	17.891813099	0 # molecule nr 486
+Ion_Type1_326	7.392055911	16.243325879	17.256813099	0 # molecule nr 487
+Ion_Type3_160	10.912055911	17.078325879	17.043813099	0 # molecule nr 488
+Ion_Type1_327	11.610055911	16.695325879	16.510813099	0 # molecule nr 489
+Ion_Type1_328	10.146055911	17.101325879	16.467813099	0 # molecule nr 490
+Ion_Type3_161	14.012055911	17.078325879	17.043813099	0 # molecule nr 491
+Ion_Type1_329	13.645055911	16.325325879	16.577813099	0 # molecule nr 492
+Ion_Type1_330	14.164055911	17.737325879	16.364813099	0 # molecule nr 493
+Ion_Type3_162	17.112055911	17.078325879	17.043813099	0 # molecule nr 494
+Ion_Type1_331	17.969055911	16.649325879	17.031813099	0 # molecule nr 495
+Ion_Type1_332	16.615055911	16.618325879	17.721813099	0 # molecule nr 496
+Ion_Type3_163	20.212055911	17.078325879	17.043813099	0 # molecule nr 497
+Ion_Type1_333	21.057055911	16.913325879	16.623813099	0 # molecule nr 498
+Ion_Type1_334	20.037055911	18.008325879	16.889813099	0 # molecule nr 499
+Ion_Type3_164	4.712055911	20.178325879	17.043813099	0 # molecule nr 500
+Ion_Type1_335	3.956055911	19.991325879	16.484813099	0 # molecule nr 501
+Ion_Type1_336	5.173055911	20.895325879	16.604813099	0 # molecule nr 502
+Ion_Type3_165	7.812055911	20.178325879	17.043813099	0 # molecule nr 503
+Ion_Type1_337	8.297055911	20.449325879	16.262813099	0 # molecule nr 504
+Ion_Type1_338	8.186055911	19.329325879	17.283813099	0 # molecule nr 505
+Ion_Type3_166	10.912055911	20.178325879	17.043813099	0 # molecule nr 506
+Ion_Type1_339	10.685055911	19.628325879	17.794813099	0 # molecule nr 507
+Ion_Type1_340	10.898055911	21.075325879	17.381813099	0 # molecule nr 508
+Ion_Type3_167	14.012055911	20.178325879	17.043813099	0 # molecule nr 509
+Ion_Type1_341	13.360055911	20.081325879	16.347813099	0 # molecule nr 510
+Ion_Type1_342	14.679055911	20.760325879	16.676813099	0 # molecule nr 511
+Ion_Type3_168	17.112055911	20.178325879	17.043813099	0 # molecule nr 512
+Ion_Type1_343	18.003055911	20.004325879	16.735813099	0 # molecule nr 513
+Ion_Type1_344	16.948055911	19.512325879	17.713813099	0 # molecule nr 514
+Ion_Type3_169	20.212055911	20.178325879	17.043813099	0 # molecule nr 515
+Ion_Type1_345	20.390055911	21.066325879	17.356813099	0 # molecule nr 516
+Ion_Type1_346	20.700055911	20.103325879	16.221813099	0 # molecule nr 517
+Ion_Type3_170	4.712055911	4.678325879	20.143813099	0 # molecule nr 518
+Ion_Type1_347	4.638055911	5.601325879	19.895813099	0 # molecule nr 519
+Ion_Type1_348	4.904055911	4.690325879	21.082813099	0 # molecule nr 520
+Ion_Type3_171	7.812055911	4.678325879	20.143813099	0 # molecule nr 521
+Ion_Type1_349	8.424055911	4.412325879	20.831813099	0 # molecule nr 522
+Ion_Type1_350	7.201055911	3.944325879	20.059813099	0 # molecule nr 523
+Ion_Type3_172	10.912055911	4.678325879	20.143813099	0 # molecule nr 524
+Ion_Type1_351	10.990055911	3.723325879	20.153813099	0 # molecule nr 525
+Ion_Type1_352	10.001055911	4.849325879	19.898813099	0 # molecule nr 526
+Ion_Type3_173	14.012055911	4.678325879	20.143813099	0 # molecule nr 527
+Ion_Type1_353	14.486055911	4.904325879	19.341813099	0 # molecule nr 528
+Ion_Type1_354	13.653055911	5.508325879	20.459813099	0 # molecule nr 529
+Ion_Type3_174	17.112055911	4.678325879	20.143813099	0 # molecule nr 530
+Ion_Type1_355	16.263055911	4.962325879	20.484813099	0 # molecule nr 531
+Ion_Type1_356	17.724055911	4.801325879	20.870813099	0 # molecule nr 532
+Ion_Type3_175	20.212055911	4.678325879	20.143813099	0 # molecule nr 533
+Ion_Type1_357	19.256055911	4.668325879	20.077813099	0 # molecule nr 534
+Ion_Type1_358	20.409055911	4.186325879	20.942813099	0 # molecule nr 535
+Ion_Type3_176	4.712055911	7.778325879	20.143813099	0 # molecule nr 536
+Ion_Type1_359	4.395055911	8.351325879	20.843813099	0 # molecule nr 537
+Ion_Type1_360	5.296055911	8.328325879	19.619813099	0 # molecule nr 538
+Ion_Type3_177	7.812055911	7.778325879	20.143813099	0 # molecule nr 539
+Ion_Type1_361	8.311055911	8.111325879	19.395813099	0 # molecule nr 540
+Ion_Type1_362	6.893055911	7.865325879	19.885813099	0 # molecule nr 541
+Ion_Type3_178	10.912055911	7.778325879	20.143813099	0 # molecule nr 542
+Ion_Type1_363	10.178055911	7.464325879	19.612813099	0 # molecule nr 543
+Ion_Type1_364	11.155055911	8.620325879	19.755813099	0 # molecule nr 544
+Ion_Type3_179	14.012055911	7.778325879	20.143813099	0 # molecule nr 545
+Ion_Type1_365	14.502055911	7.116325879	20.634813099	0 # molecule nr 546
+Ion_Type1_366	13.950055911	7.429325879	19.252813099	0 # molecule nr 547
+Ion_Type3_180	17.112055911	7.778325879	20.143813099	0 # molecule nr 548
+Ion_Type1_367	17.157055911	7.126325879	19.442813099	0 # molecule nr 549
+Ion_Type1_368	16.185055911	7.817325879	20.384813099	0 # molecule nr 550
+Ion_Type3_181	20.212055911	7.778325879	20.143813099	0 # molecule nr 551
+Ion_Type1_369	19.420055911	8.083325879	20.588813099	0 # molecule nr 552
+Ion_Type1_370	20.126055911	6.824325879	20.112813099	0 # molecule nr 553
+Ion_Type3_182	4.712055911	10.878325879	20.143813099	0 # molecule nr 554
+Ion_Type1_371	4.380055911	10.928325879	19.245813099	0 # molecule nr 555
+Ion_Type1_372	5.665055911	10.825325879	20.051813099	0 # molecule nr 556
+Ion_Type3_183	7.812055911	10.878325879	20.143813099	0 # molecule nr 557
+Ion_Type1_373	7.823055911	10.655325879	19.211813099	0 # molecule nr 558
+Ion_Type1_374	8.562055911	11.462325879	20.266813099	0 # molecule nr 559
+Ion_Type3_184	10.912055911	10.878325879	20.143813099	0 # molecule nr 560
+Ion_Type1_375	10.788055911	11.371325879	20.955813099	0 # molecule nr 561
+Ion_Type1_376	10.340055911	10.114325879	20.229813099	0 # molecule nr 562
+Ion_Type3_185	14.012055911	10.878325879	20.143813099	0 # molecule nr 563
+Ion_Type1_377	13.728055911	10.738325879	19.238813099	0 # molecule nr 564
+Ion_Type1_378	13.750055911	10.083325879	20.610813099	0 # molecule nr 565
+Ion_Type3_186	17.112055911	10.878325879	20.143813099	0 # molecule nr 566
+Ion_Type1_379	17.696055911	11.249325879	20.806813099	0 # molecule nr 567
+Ion_Type1_380	16.232055911	11.149325879	20.410813099	0 # molecule nr 568
+Ion_Type3_187	20.212055911	10.878325879	20.143813099	0 # molecule nr 569
+Ion_Type1_381	21.101055911	11.040325879	19.823813099	0 # molecule nr 570
+Ion_Type1_382	19.755055911	10.471325879	19.406813099	0 # molecule nr 571
+Ion_Type3_188	4.712055911	13.978325879	20.143813099	0 # molecule nr 572
+Ion_Type1_383	5.045055911	13.226325879	19.651813099	0 # molecule nr 573
+Ion_Type1_384	4.082055911	13.608325879	20.763813099	0 # molecule nr 574
+Ion_Type3_189	7.812055911	13.978325879	20.143813099	0 # molecule nr 575
+Ion_Type1_385	7.256055911	13.205325879	20.033813099	0 # molecule nr 576
+Ion_Type1_386	8.220055911	14.112325879	19.286813099	0 # molecule nr 577
+Ion_Type3_190	10.912055911	13.978325879	20.143813099	0 # molecule nr 578
+Ion_Type1_387	11.220055911	13.122325879	19.840813099	0 # molecule nr 579
+Ion_Type1_388	11.586055911	14.281325879	20.754813099	0 # molecule nr 580
+Ion_Type3_191	14.012055911	13.978325879	20.143813099	0 # molecule nr 581
+Ion_Type1_389	13.289055911	14.359325879	20.644813099	0 # molecule nr 582
+Ion_Type1_390	14.687055911	13.781325879	20.795813099	0 # molecule nr 583
+Ion_Type3_192	17.112055911	13.978325879	20.143813099	0 # molecule nr 584
+Ion_Type1_391	17.184055911	13.237325879	20.746813099	0 # molecule nr 585
+Ion_Type1_392	16.339055911	14.462325879	20.438813099	0 # molecule nr 586
+Ion_Type3_193	20.212055911	13.978325879	20.143813099	0 # molecule nr 587
+Ion_Type1_393	20.750055911	14.764325879	20.252813099	0 # molecule nr 588
+Ion_Type1_394	20.022055911	13.683325879	21.035813099	0 # molecule nr 589
+Ion_Type3_194	4.712055911	17.078325879	20.143813099	0 # molecule nr 590
+Ion_Type1_395	4.317055911	16.255325879	20.436813099	0 # molecule nr 591
+Ion_Type1_396	4.401055911	17.737325879	20.766813099	0 # molecule nr 592
+Ion_Type3_195	7.812055911	17.078325879	20.143813099	0 # molecule nr 593
+Ion_Type1_397	8.275055911	16.422325879	20.667813099	0 # molecule nr 594
+Ion_Type1_398	7.434055911	17.683325879	20.783813099	0 # molecule nr 595
+Ion_Type3_196	10.912055911	17.078325879	20.143813099	0 # molecule nr 596
+Ion_Type1_399	11.762055911	16.746325879	19.851813099	0 # molecule nr 597
+Ion_Type1_400	10.737055911	16.618325879	20.965813099	0 # molecule nr 598
+Ion_Type3_197	14.012055911	17.078325879	20.143813099	0 # molecule nr 599
+Ion_Type1_401	13.392055911	17.430325879	19.503813099	0 # molecule nr 600
+Ion_Type1_402	14.423055911	16.332325879	19.704813099	0 # molecule nr 601
+Ion_Type3_198	17.112055911	17.078325879	20.143813099	0 # molecule nr 602
+Ion_Type1_403	17.911055911	17.386325879	20.575813099	0 # molecule nr 603
+Ion_Type1_404	16.973055911	16.193325879	20.483813099	0 # molecule nr 604
+Ion_Type3_199	20.212055911	17.078325879	20.143813099	0 # molecule nr 605
+Ion_Type1_405	19.796055911	17.101325879	19.280813099	0 # molecule nr 606
+Ion_Type1_406	20.773055911	16.301325879	20.126813099	0 # molecule nr 607
+Ion_Type3_200	4.712055911	20.178325879	20.143813099	0 # molecule nr 608
+Ion_Type1_407	5.067055911	19.292325879	20.232813099	0 # molecule nr 609
+Ion_Type1_408	4.761055911	20.553325879	21.024813099	0 # molecule nr 610
+Ion_Type3_201	7.812055911	20.178325879	20.143813099	0 # molecule nr 611
+Ion_Type1_409	7.747055911	19.779325879	19.274813099	0 # molecule nr 612
+Ion_Type1_410	8.171055911	21.053325879	19.987813099	0 # molecule nr 613
+Ion_Type3_202	10.912055911	20.178325879	20.143813099	0 # molecule nr 614
+Ion_Type1_411	10.285055911	20.829325879	20.462813099	0 # molecule nr 615
+Ion_Type1_412	11.576055911	20.116325879	20.831813099	0 # molecule nr 616
+Ion_Type3_203	14.012055911	20.178325879	20.143813099	0 # molecule nr 617
+Ion_Type1_413	13.108055911	20.388325879	20.382813099	0 # molecule nr 618
+Ion_Type1_414	14.444055911	21.027325879	20.040813099	0 # molecule nr 619
+Ion_Type3_204	17.112055911	20.178325879	20.143813099	0 # molecule nr 620
+Ion_Type1_415	17.886055911	20.655325879	20.447813099	0 # molecule nr 621
+Ion_Type1_416	17.071055911	19.396325879	20.696813099	0 # molecule nr 622
+Ion_Type3_205	20.212055911	20.178325879	20.143813099	0 # molecule nr 623
+Ion_Type1_417	20.410055911	20.874325879	19.514813099	0 # molecule nr 624
+Ion_Type1_418	20.119055911	19.385325879	19.613813099	0 # molecule nr 625
Index: tests/regression/Analysis/5/pre/test.conf
===================================================================
--- tests/regression/Analysis/5/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Analysis/5/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,83 @@
+# 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/Domain/1/post/test.conf
===================================================================
--- tests/regression/Domain/1/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Domain/1/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -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)
+10	
+0	10	
+0	0	10	
+
+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: tests/regression/Domain/2/post/test.conf
===================================================================
--- tests/regression/Domain/2/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Domain/2/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,73 @@
+# 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	1	# 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	1	# check every ..th steps
+InitMaxMinGapStopStep	1	# check every ..th steps
+
+BoxLength			# (Length of a unit cell)
+15	
+0	15	
+0	0	15	
+
+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	1	# here: specifying both maximum number of SpinUp- and -Down-states
+PsiMaxNoUp	1	# 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	2	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	7.000000000	7.500000000	6.500000000	0 # molecule nr 0
+Ion_Type1_2	8.000000000	7.500000000	8.500000000	0 # molecule nr 1
Index: tests/regression/Domain/2/pre/test.conf
===================================================================
--- tests/regression/Domain/2/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Domain/2/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,73 @@
+# 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	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	2	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	10.000000000	10.000000000	10.000000000	0 # molecule nr 0
+Ion_Type1_2	11.000000000	10.000000000	12.000000000	0 # molecule nr 0
Index: tests/regression/Domain/3/post/test.conf
===================================================================
--- tests/regression/Domain/3/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Domain/3/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,73 @@
+# 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	1	# 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	1	# check every ..th steps
+InitMaxMinGapStopStep	1	# check every ..th steps
+
+BoxLength			# (Length of a unit cell)
+11	
+0	20	
+0	0	32	
+
+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	1	# here: specifying both maximum number of SpinUp- and -Down-states
+PsiMaxNoUp	1	# 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	2	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	5.000000000	10.000000000	15.000000000	0 # molecule nr 0
+Ion_Type1_2	6.000000000	10.000000000	17.000000000	0 # molecule nr 1
Index: tests/regression/Domain/3/pre/test.conf
===================================================================
--- tests/regression/Domain/3/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Domain/3/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,73 @@
+# 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	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	2	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	10.000000000	10.000000000	10.000000000	0 # molecule nr 0
+Ion_Type1_2	11.000000000	10.000000000	12.000000000	0 # molecule nr 0
Index: tests/regression/Domain/4/post/test.conf
===================================================================
--- tests/regression/Domain/4/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Domain/4/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,73 @@
+# 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	1	# 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	1	# check every ..th steps
+InitMaxMinGapStopStep	1	# check every ..th steps
+
+BoxLength			# (Length of a unit cell)
+1	
+0	0	
+0	0	2	
+
+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	1	# here: specifying both maximum number of SpinUp- and -Down-states
+PsiMaxNoUp	1	# 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	2	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	0.000000000	0 # molecule nr 0
+Ion_Type1_2	1.000000000	0.000000000	2.000000000	0 # molecule nr 1
Index: tests/regression/Domain/4/pre/test.conf
===================================================================
--- tests/regression/Domain/4/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Domain/4/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,73 @@
+# 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	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	2	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	10.000000000	10.000000000	10.000000000	0 # molecule nr 0
+Ion_Type1_2	11.000000000	10.000000000	12.000000000	0 # molecule nr 0
Index: tests/regression/Domain/5/post/test.conf
===================================================================
--- tests/regression/Domain/5/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Domain/5/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,83 @@
+# 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	10	# 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	10	# check every ..th steps
+InitMaxMinGapStopStep	1	# check every ..th steps
+
+BoxLength			# (Length of a unit cell)
+10	
+0	20	
+0	0	18	
+
+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	10	# here: specifying both maximum number of SpinUp- and -Down-states
+PsiMaxNoUp	10	# here: specifying maximum number of SpinUp-states
+PsiMaxNoDown	10	# 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_Type1_1	4.891042973	2.645886050	2.381297445	0 # molecule nr 0
+Ion_Type1_2	4.891042973	2.645886050	3.983297422	0 # molecule nr 1
+Ion_Type1_3	5.336019804	3.904536878	3.182297433	0 # molecule nr 2
+Ion_Type1_4	4.266392982	4.787886018	2.381297445	0 # molecule nr 3
+Ion_Type1_5	4.266392982	4.787886018	3.983297422	0 # molecule nr 4
+Ion_Type1_6	3.196816159	3.904536877	3.182297433	0 # molecule nr 5
+Ion_Type1_7	3.641792991	2.645886050	2.381297445	0 # molecule nr 6
+Ion_Type1_8	3.641792991	2.645886050	3.983297422	0 # molecule nr 7
+Ion_Type2_1	4.891042973	3.275186040	3.182297433	0 # molecule nr 8
+Ion_Type2_2	4.266392982	4.158586027	3.182297433	0 # molecule nr 9
+Ion_Type2_3	3.641792991	3.275186040	3.182297433	0 # molecule nr 10
Index: tests/regression/Domain/5/pre/test.conf
===================================================================
--- tests/regression/Domain/5/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Domain/5/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,83 @@
+# 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_Type1_1	9.782085945	2.645886050	2.645886050	0 # molecule nr 0
+Ion_Type1_2	9.782085945	2.645886050	4.425886024	0 # molecule nr 1
+Ion_Type1_3	10.672039608	3.904536878	3.535886037	0 # molecule nr 2
+Ion_Type1_4	8.532785963	4.787886018	2.645886050	0 # molecule nr 3
+Ion_Type1_5	8.532785963	4.787886018	4.425886024	0 # molecule nr 4
+Ion_Type1_6	6.393632318	3.904536877	3.535886037	0 # molecule nr 5
+Ion_Type1_7	7.283585982	2.645886050	2.645886050	0 # molecule nr 6
+Ion_Type1_8	7.283585982	2.645886050	4.425886024	0 # molecule nr 7
+Ion_Type2_1	9.782085945	3.275186040	3.535886037	0 # molecule nr 8
+Ion_Type2_2	8.532785963	4.158586027	3.535886037	0 # molecule nr 9
+Ion_Type2_3	7.283585982	3.275186040	3.535886037	0 # molecule nr 10
Index: tests/regression/Domain/6/post/test-x.xyz
===================================================================
--- tests/regression/Domain/6/post/test-x.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Domain/6/post/test-x.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,24 @@
+22
+	Created by molecuilder on Mon May 31 19:07:16 2010
+H	9.78209	2.64589	2.64589
+C	27.2836	3.27519	3.53589
+C	28.5328	4.15859	3.53589
+C	29.7821	3.27519	3.53589
+H	27.2836	2.64589	4.42589
+H	9.78209	2.64589	4.42589
+H	10.672	3.90454	3.53589
+H	8.53279	4.78789	2.64589
+H	27.2836	2.64589	2.64589
+H	26.3936	3.90454	3.53589
+H	28.5328	4.78789	4.42589
+H	28.5328	4.78789	2.64589
+H	30.672	3.90454	3.53589
+H	29.7821	2.64589	4.42589
+H	29.7821	2.64589	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/Domain/6/post/test-y.xyz
===================================================================
--- tests/regression/Domain/6/post/test-y.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Domain/6/post/test-y.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,24 @@
+22
+	Created by molecuilder on Mon May 31 19:07:16 2010
+H	9.78209	2.64589	2.64589
+C	7.28359	23.2752	3.53589
+C	8.53279	24.1586	3.53589
+C	9.78209	23.2752	3.53589
+H	7.28359	22.6459	4.42589
+H	9.78209	2.64589	4.42589
+H	10.672	3.90454	3.53589
+H	8.53279	4.78789	2.64589
+H	7.28359	22.6459	2.64589
+H	6.39363	23.9045	3.53589
+H	8.53279	24.7879	4.42589
+H	8.53279	24.7879	2.64589
+H	10.672	23.9045	3.53589
+H	9.78209	22.6459	4.42589
+H	9.78209	22.6459	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/Domain/6/post/test-z.xyz
===================================================================
--- tests/regression/Domain/6/post/test-z.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Domain/6/post/test-z.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,24 @@
+22
+	Created by molecuilder on Mon May 31 19:07:16 2010
+H	9.78209	2.64589	2.64589
+C	7.28359	3.27519	23.5359
+C	8.53279	4.15859	23.5359
+C	9.78209	3.27519	23.5359
+H	7.28359	2.64589	24.4259
+H	9.78209	2.64589	4.42589
+H	10.672	3.90454	3.53589
+H	8.53279	4.78789	2.64589
+H	7.28359	2.64589	22.6459
+H	6.39363	3.90454	23.5359
+H	8.53279	4.78789	24.4259
+H	8.53279	4.78789	22.6459
+H	10.672	3.90454	23.5359
+H	9.78209	2.64589	24.4259
+H	9.78209	2.64589	22.6459
+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/Domain/6/post/test.xyz
===================================================================
--- tests/regression/Domain/6/post/test.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Domain/6/post/test.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,13 @@
+11
+	Created by molecuilder on Mon May 31 19:21:12 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/Domain/6/pre/test.conf
===================================================================
--- tests/regression/Domain/6/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Domain/6/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,83 @@
+# 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_Type1_1	9.782085945	2.645886050	2.645886050	0 # molecule nr 0
+Ion_Type1_2	9.782085945	2.645886050	4.425886024	0 # molecule nr 1
+Ion_Type1_3	10.672039608	3.904536878	3.535886037	0 # molecule nr 2
+Ion_Type1_4	8.532785963	4.787886018	2.645886050	0 # molecule nr 3
+Ion_Type1_5	8.532785963	4.787886018	4.425886024	0 # molecule nr 4
+Ion_Type1_6	6.393632318	3.904536877	3.535886037	0 # molecule nr 5
+Ion_Type1_7	7.283585982	2.645886050	2.645886050	0 # molecule nr 6
+Ion_Type1_8	7.283585982	2.645886050	4.425886024	0 # molecule nr 7
+Ion_Type2_1	9.782085945	3.275186040	3.535886037	0 # molecule nr 8
+Ion_Type2_2	8.532785963	4.158586027	3.535886037	0 # molecule nr 9
+Ion_Type2_3	7.283585982	3.275186040	3.535886037	0 # molecule nr 10
Index: tests/regression/Filling/1/post/test.conf
===================================================================
--- tests/regression/Filling/1/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Filling/1/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,1089 @@
+# 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	680	# 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	680	# 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	680	# here: specifying both maximum number of SpinUp- and -Down-states
+PsiMaxNoUp	680	# here: specifying maximum number of SpinUp-states
+PsiMaxNoDown	680	# 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_Type1_1	9.782085945	2.645886050	2.645886050	0 # molecule nr 0
+Ion_Type1_2	9.782085945	2.645886050	4.425886024	0 # molecule nr 1
+Ion_Type1_3	10.672039608	3.904536878	3.535886037	0 # molecule nr 2
+Ion_Type1_4	8.532785963	4.787886018	2.645886050	0 # molecule nr 3
+Ion_Type1_5	8.532785963	4.787886018	4.425886024	0 # molecule nr 4
+Ion_Type1_6	6.393632318	3.904536877	3.535886037	0 # molecule nr 5
+Ion_Type1_7	7.283585982	2.645886050	2.645886050	0 # molecule nr 6
+Ion_Type1_8	7.283585982	2.645886050	4.425886024	0 # molecule nr 7
+Ion_Type2_1	9.782085945	3.275186040	3.535886037	0 # molecule nr 8
+Ion_Type2_2	8.532785963	4.158586027	3.535886037	0 # molecule nr 9
+Ion_Type2_3	7.283585982	3.275186040	3.535886037	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/Filling/1/pre/test.conf
===================================================================
--- tests/regression/Filling/1/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Filling/1/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,83 @@
+# 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_Type1_1	9.782085945	2.645886050	2.645886050	0 # molecule nr 0
+Ion_Type1_2	9.782085945	2.645886050	4.425886024	0 # molecule nr 1
+Ion_Type1_3	10.672039608	3.904536878	3.535886037	0 # molecule nr 2
+Ion_Type1_4	8.532785963	4.787886018	2.645886050	0 # molecule nr 3
+Ion_Type1_5	8.532785963	4.787886018	4.425886024	0 # molecule nr 4
+Ion_Type1_6	6.393632318	3.904536877	3.535886037	0 # molecule nr 5
+Ion_Type1_7	7.283585982	2.645886050	2.645886050	0 # molecule nr 6
+Ion_Type1_8	7.283585982	2.645886050	4.425886024	0 # molecule nr 7
+Ion_Type2_1	9.782085945	3.275186040	3.535886037	0 # molecule nr 8
+Ion_Type2_2	8.532785963	4.158586027	3.535886037	0 # molecule nr 9
+Ion_Type2_3	7.283585982	3.275186040	3.535886037	0 # molecule nr 10
Index: tests/regression/Filling/2/pre/test.conf
===================================================================
--- tests/regression/Filling/2/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Filling/2/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,83 @@
+# 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/Fragmentation/1/pre/test.conf
===================================================================
--- tests/regression/Fragmentation/1/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Fragmentation/1/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,83 @@
+# 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/Fragmentation/2/post/BondFragment0.conf
===================================================================
--- tests/regression/Fragmentation/2/post/BondFragment0.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Fragmentation/2/post/BondFragment0.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,77 @@
+# ParallelCarParinello - main configuration file - created with molecuilder
+
+mainname	pcp	# programm name (for runtime files)
+defaultpath	not specified/BondFragment0/	# 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	4	# 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	4	# check every ..th steps
+InitMaxMinGapStopStep	1	# check every ..th steps
+
+BoxLength			# (Length of a unit cell)
+6.77993	
+0	6.25865	
+0	0	6.78	
+
+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	4	# here: specifying both maximum number of SpinUp- and -Down-states
+PsiMaxNoUp	4	# here: specifying maximum number of SpinUp-states
+PsiMaxNoDown	4	# 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	4	1	1.0	3	3	1.00800000000	Hydrogen	H
+Ion_Type2	1	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	3.389977412	3.129299990	3.389999987	0 # molecule nr 0
+Ion_Type1_1	3.389977412	2.500000000	2.500000000	0 # molecule nr 1
+Ion_Type1_2	3.389977412	2.500000000	4.279999974	0 # molecule nr 2
+Ion_Type1_3	2.500000000	3.758617244	3.389999987	0 # molecule nr 3
+Ion_Type1_4	4.279931075	3.758650828	3.389999987	0 # molecule nr 4
Index: tests/regression/Fragmentation/2/post/BondFragment0.xyz
===================================================================
--- tests/regression/Fragmentation/2/post/BondFragment0.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Fragmentation/2/post/BondFragment0.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,7 @@
+5
+	Created by molecuilder on Tue Oct  6 19:01:29 2009
+C	9.78209	3.27519	3.53589	
+H	9.78209	2.64589	2.64589	
+H	9.78209	2.64589	4.42589	
+H	8.89211	3.9045	3.53589	
+H	10.672	3.90454	3.53589	
Index: tests/regression/Fragmentation/2/post/BondFragment1.conf
===================================================================
--- tests/regression/Fragmentation/2/post/BondFragment1.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Fragmentation/2/post/BondFragment1.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,77 @@
+# ParallelCarParinello - main configuration file - created with molecuilder
+
+mainname	pcp	# programm name (for runtime files)
+defaultpath	not specified/BondFragment1/	# 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	4	# 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	4	# check every ..th steps
+InitMaxMinGapStopStep	1	# check every ..th steps
+
+BoxLength			# (Length of a unit cell)
+6.77993	
+0	6.25865	
+0	0	6.78	
+
+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	4	# here: specifying both maximum number of SpinUp- and -Down-states
+PsiMaxNoUp	4	# here: specifying maximum number of SpinUp-states
+PsiMaxNoDown	4	# 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	4	1	1.0	3	3	1.00800000000	Hydrogen	H
+Ion_Type2	1	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	3.389953663	3.129350838	3.389999987	0 # molecule nr 0
+Ion_Type1_1	2.500000000	2.500000000	3.389999987	0 # molecule nr 1
+Ion_Type1_2	3.389953663	3.758650829	2.500000000	0 # molecule nr 2
+Ion_Type1_3	3.389953663	3.758650829	4.279999974	0 # molecule nr 3
+Ion_Type1_4	4.279931075	2.500033584	3.389999987	0 # molecule nr 4
Index: tests/regression/Fragmentation/2/post/BondFragment1.xyz
===================================================================
--- tests/regression/Fragmentation/2/post/BondFragment1.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Fragmentation/2/post/BondFragment1.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,7 @@
+5
+	Created by molecuilder on Tue Oct  6 19:01:29 2009
+C	8.53279	4.15859	3.53589	
+H	7.64283	3.52924	3.53589	
+H	8.53279	4.78789	2.64589	
+H	8.53279	4.78789	4.42589	
+H	9.42276	3.52927	3.53589	
Index: tests/regression/Fragmentation/2/post/BondFragment2.conf
===================================================================
--- tests/regression/Fragmentation/2/post/BondFragment2.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Fragmentation/2/post/BondFragment2.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,77 @@
+# ParallelCarParinello - main configuration file - created with molecuilder
+
+mainname	pcp	# programm name (for runtime files)
+defaultpath	not specified/BondFragment2/	# 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	4	# 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	4	# check every ..th steps
+InitMaxMinGapStopStep	1	# check every ..th steps
+
+BoxLength			# (Length of a unit cell)
+6.77991	
+0	6.25865	
+0	0	6.78	
+
+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	4	# here: specifying both maximum number of SpinUp- and -Down-states
+PsiMaxNoUp	4	# here: specifying maximum number of SpinUp-states
+PsiMaxNoDown	4	# 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	4	1	1.0	3	3	1.00800000000	Hydrogen	H
+Ion_Type2	1	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	3.389953664	3.129299990	3.389999987	0 # molecule nr 0
+Ion_Type1_1	4.279907327	3.758650828	3.389999987	0 # molecule nr 1
+Ion_Type1_2	2.500000000	3.758650827	3.389999987	0 # molecule nr 2
+Ion_Type1_3	3.389953664	2.500000000	2.500000000	0 # molecule nr 3
+Ion_Type1_4	3.389953664	2.500000000	4.279999974	0 # molecule nr 4
Index: tests/regression/Fragmentation/2/post/BondFragment2.xyz
===================================================================
--- tests/regression/Fragmentation/2/post/BondFragment2.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Fragmentation/2/post/BondFragment2.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,7 @@
+5
+	Created by molecuilder on Tue Oct  6 19:01:29 2009
+C	7.28359	3.27519	3.53589	
+H	8.17354	3.90454	3.53589	
+H	6.39363	3.90454	3.53589	
+H	7.28359	2.64589	2.64589	
+H	7.28359	2.64589	4.42589	
Index: tests/regression/Fragmentation/2/post/BondFragment3.conf
===================================================================
--- tests/regression/Fragmentation/2/post/BondFragment3.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Fragmentation/2/post/BondFragment3.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,80 @@
+# ParallelCarParinello - main configuration file - created with molecuilder
+
+mainname	pcp	# programm name (for runtime files)
+defaultpath	not specified/BondFragment3/	# 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	7	# 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	7	# check every ..th steps
+InitMaxMinGapStopStep	1	# check every ..th steps
+
+BoxLength			# (Length of a unit cell)
+8.02921	
+0	7.142	
+0	0	6.78	
+
+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	7	# here: specifying both maximum number of SpinUp- and -Down-states
+PsiMaxNoUp	7	# here: specifying maximum number of SpinUp-states
+PsiMaxNoDown	7	# 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	6	1	1.0	3	3	1.00800000000	Hydrogen	H
+Ion_Type2	2	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	4.639253645	3.129299990	3.389999987	0 # molecule nr 0
+Ion_Type2_2	3.389953663	4.012699977	3.389999987	0 # molecule nr 1
+Ion_Type1_1	4.639253645	2.500000000	2.500000000	0 # molecule nr 2
+Ion_Type1_2	4.639253645	2.500000000	4.279999974	0 # molecule nr 3
+Ion_Type1_3	5.529207308	3.758650828	3.389999987	0 # molecule nr 4
+Ion_Type1_4	2.500000000	3.383349139	3.389999987	0 # molecule nr 5
+Ion_Type1_5	3.389953663	4.641999968	2.500000000	0 # molecule nr 6
+Ion_Type1_6	3.389953663	4.641999968	4.279999974	0 # molecule nr 7
Index: tests/regression/Fragmentation/2/post/BondFragment3.xyz
===================================================================
--- tests/regression/Fragmentation/2/post/BondFragment3.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Fragmentation/2/post/BondFragment3.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,10 @@
+8
+	Created by molecuilder on Tue Oct  6 19:01:29 2009
+C	9.78209	3.27519	3.53589	
+C	8.53279	4.15859	3.53589	
+H	9.78209	2.64589	2.64589	
+H	9.78209	2.64589	4.42589	
+H	10.672	3.90454	3.53589	
+H	7.64283	3.52924	3.53589	
+H	8.53279	4.78789	2.64589	
+H	8.53279	4.78789	4.42589	
Index: tests/regression/Fragmentation/2/post/BondFragment4.conf
===================================================================
--- tests/regression/Fragmentation/2/post/BondFragment4.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Fragmentation/2/post/BondFragment4.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,80 @@
+# ParallelCarParinello - main configuration file - created with molecuilder
+
+mainname	pcp	# programm name (for runtime files)
+defaultpath	not specified/BondFragment4/	# 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	7	# 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	7	# check every ..th steps
+InitMaxMinGapStopStep	1	# check every ..th steps
+
+BoxLength			# (Length of a unit cell)
+8.02913	
+0	7.142	
+0	0	6.78	
+
+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	7	# here: specifying both maximum number of SpinUp- and -Down-states
+PsiMaxNoUp	7	# here: specifying maximum number of SpinUp-states
+PsiMaxNoDown	7	# 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	6	1	1.0	3	3	1.00800000000	Hydrogen	H
+Ion_Type2	2	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	4.639153645	4.012699977	3.389999987	0 # molecule nr 0
+Ion_Type2_2	3.389953664	3.129299990	3.389999987	0 # molecule nr 1
+Ion_Type1_1	4.639153645	4.641999968	2.500000000	0 # molecule nr 2
+Ion_Type1_2	4.639153645	4.641999968	4.279999974	0 # molecule nr 3
+Ion_Type1_3	5.529131057	3.383382723	3.389999987	0 # molecule nr 4
+Ion_Type1_4	2.500000000	3.758650827	3.389999987	0 # molecule nr 5
+Ion_Type1_5	3.389953664	2.500000000	2.500000000	0 # molecule nr 6
+Ion_Type1_6	3.389953664	2.500000000	4.279999974	0 # molecule nr 7
Index: tests/regression/Fragmentation/2/post/BondFragment4.xyz
===================================================================
--- tests/regression/Fragmentation/2/post/BondFragment4.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Fragmentation/2/post/BondFragment4.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,10 @@
+8
+	Created by molecuilder on Tue Oct  6 19:01:29 2009
+C	8.53279	4.15859	3.53589	
+C	7.28359	3.27519	3.53589	
+H	8.53279	4.78789	2.64589	
+H	8.53279	4.78789	4.42589	
+H	9.42276	3.52927	3.53589	
+H	6.39363	3.90454	3.53589	
+H	7.28359	2.64589	2.64589	
+H	7.28359	2.64589	4.42589	
Index: tests/regression/Fragmentation/2/post/BondFragmentAdjacency.dat
===================================================================
--- tests/regression/Fragmentation/2/post/BondFragmentAdjacency.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Fragmentation/2/post/BondFragmentAdjacency.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,11 @@
+0	3	4	1	5	
+1	2	6	7	0	
+2	1	8	9	10	
+3	0	
+4	0	
+5	0	
+6	1	
+7	1	
+8	2	
+9	2	
+10	2	
Index: tests/regression/Fragmentation/2/post/BondFragmentForces-Factors.dat
===================================================================
--- tests/regression/Fragmentation/2/post/BondFragmentForces-Factors.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Fragmentation/2/post/BondFragmentForces-Factors.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,5 @@
+0	1	-1	2	8	
+-1	3	4	-1	9	
+-1	5	6	7	10	
+0	1	2	-1	3	4	8	9	
+3	4	-1	5	6	7	9	10	
Index: tests/regression/Fragmentation/2/post/BondFragmentKeySets.dat
===================================================================
--- tests/regression/Fragmentation/2/post/BondFragmentKeySets.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Fragmentation/2/post/BondFragmentKeySets.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,5 @@
+0
+1
+2
+0	1
+1	2
Index: tests/regression/Fragmentation/2/post/BondFragmentOrderAtSite.dat
===================================================================
--- tests/regression/Fragmentation/2/post/BondFragmentOrderAtSite.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Fragmentation/2/post/BondFragmentOrderAtSite.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,11 @@
+0	2	0
+1	2	0
+2	2	1
+3	0	0
+4	0	0
+5	0	0
+6	0	0
+7	0	0
+8	0	0
+9	0	0
+10	0	0
Index: tests/regression/Fragmentation/2/post/BondFragmentTE-Factors.dat
===================================================================
--- tests/regression/Fragmentation/2/post/BondFragmentTE-Factors.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Fragmentation/2/post/BondFragmentTE-Factors.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,5 @@
+1
+1
+1
+1
+1
Index: tests/regression/Fragmentation/2/post/test.conf
===================================================================
--- tests/regression/Fragmentation/2/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Fragmentation/2/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,83 @@
+# 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/Fragmentation/2/pre/test.conf
===================================================================
--- tests/regression/Fragmentation/2/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Fragmentation/2/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,83 @@
+# 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/Fragmentation/3/pre/test.conf
===================================================================
--- tests/regression/Fragmentation/3/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Fragmentation/3/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,83 @@
+# 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/Graph/1/post/test.conf
===================================================================
--- tests/regression/Graph/1/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Graph/1/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,83 @@
+# 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/Graph/1/pre/test.conf
===================================================================
--- tests/regression/Graph/1/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Graph/1/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,83 @@
+# 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/Graph/2/pre/test.conf
===================================================================
--- tests/regression/Graph/2/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Graph/2/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,165 @@
+# 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	62	1	1.0	3	3	1.00800000000	Hydrogen	H
+Ion_Type2	31	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	-3.450000000	-3.450000000	-3.954000000	0 # molecule nr 0
+Ion_Type1_1	-4.020000000	-4.220000000	-3.935000000	0 # molecule nr 1
+Ion_Type1_2	-2.897000000	-3.533000000	-3.176000000	0 # molecule nr 2
+Ion_Type2_2	-0.350000000	-3.450000000	-3.954000000	0 # molecule nr 3
+Ion_Type1_3	-1.186000000	-3.471000000	-3.486000000	0 # molecule nr 4
+Ion_Type1_4	0.283000000	-3.837000000	-3.347000000	0 # molecule nr 5
+Ion_Type2_3	2.750000000	-3.450000000	-3.954000000	0 # molecule nr 6
+Ion_Type1_5	2.181000000	-3.615000000	-4.708000000	0 # molecule nr 7
+Ion_Type1_6	3.035000000	-2.540000000	-4.054000000	0 # molecule nr 8
+Ion_Type2_4	-3.450000000	-0.350000000	-3.954000000	0 # molecule nr 9
+Ion_Type1_7	-3.429000000	0.422000000	-4.521000000	0 # molecule nr 10
+Ion_Type1_8	-3.807000000	-1.050000000	-4.503000000	0 # molecule nr 11
+Ion_Type2_5	-0.350000000	-0.350000000	-3.954000000	0 # molecule nr 12
+Ion_Type1_9	-0.570000000	-0.546000000	-3.042000000	0 # molecule nr 13
+Ion_Type1_10	0.521000000	-0.728000000	-4.084000000	0 # molecule nr 14
+Ion_Type2_6	2.750000000	-0.350000000	-3.954000000	0 # molecule nr 15
+Ion_Type1_11	2.266000000	0.237000000	-4.537000000	0 # molecule nr 16
+Ion_Type1_12	2.900000000	-1.143000000	-4.471000000	0 # molecule nr 17
+Ion_Type2_7	-3.450000000	2.750000000	-3.954000000	0 # molecule nr 18
+Ion_Type1_13	-4.166000000	2.713000000	-3.318000000	0 # molecule nr 19
+Ion_Type1_14	-2.692000000	3.058000000	-3.454000000	0 # molecule nr 20
+Ion_Type2_8	-0.350000000	2.750000000	-3.954000000	0 # molecule nr 21
+Ion_Type1_15	-0.859000000	2.027000000	-4.324000000	0 # molecule nr 22
+Ion_Type1_16	-0.772000000	3.544000000	-4.285000000	0 # molecule nr 23
+Ion_Type2_9	2.750000000	2.750000000	-3.954000000	0 # molecule nr 24
+Ion_Type1_17	2.928000000	3.649000000	-4.236000000	0 # molecule nr 25
+Ion_Type1_18	2.122000000	2.410000000	-4.593000000	0 # molecule nr 26
+Ion_Type2_10	-3.450000000	-3.450000000	-0.854000000	0 # molecule nr 27
+Ion_Type1_19	-3.851000000	-4.287000000	-1.094000000	0 # molecule nr 28
+Ion_Type1_20	-4.062000000	-3.052000000	-0.234000000	0 # molecule nr 29
+Ion_Type2_11	-0.350000000	-3.450000000	-0.854000000	0 # molecule nr 30
+Ion_Type1_21	-0.388000000	-4.167000000	-0.219000000	0 # molecule nr 31
+Ion_Type1_22	-0.224000000	-2.660000000	-0.327000000	0 # molecule nr 32
+Ion_Type2_12	2.750000000	-3.450000000	-0.854000000	0 # molecule nr 33
+Ion_Type1_23	2.734000000	-2.527000000	-0.597000000	0 # molecule nr 34
+Ion_Type1_24	2.410000000	-3.924000000	-0.093000000	0 # molecule nr 35
+Ion_Type2_13	-3.450000000	-0.350000000	-0.854000000	0 # molecule nr 36
+Ion_Type1_25	-3.665000000	0.319000000	-0.202000000	0 # molecule nr 37
+Ion_Type1_26	-3.940000000	-1.127000000	-0.581000000	0 # molecule nr 38
+Ion_Type2_14	-3.450000000	2.750000000	-0.854000000	0 # molecule nr 39
+Ion_Type1_27	-2.864000000	2.026000000	-0.631000000	0 # molecule nr 40
+Ion_Type1_28	-4.262000000	2.330000000	-1.141000000	0 # molecule nr 41
+Ion_Type2_15	2.750000000	2.750000000	-0.854000000	0 # molecule nr 42
+Ion_Type1_29	2.976000000	2.419000000	0.017000000	0 # molecule nr 43
+Ion_Type1_30	3.592000000	2.883000000	-1.293000000	0 # molecule nr 44
+Ion_Type2_16	-3.450000000	-3.450000000	2.246000000	0 # molecule nr 45
+Ion_Type1_31	-3.246000000	-2.771000000	1.601000000	0 # molecule nr 46
+Ion_Type1_32	-4.102000000	-3.053000000	2.825000000	0 # molecule nr 47
+Ion_Type2_17	-0.350000000	-3.450000000	2.246000000	0 # molecule nr 48
+Ion_Type1_33	0.034000000	-4.290000000	2.503000000	0 # molecule nr 49
+Ion_Type1_34	0.067000000	-2.803000000	2.817000000	0 # molecule nr 50
+Ion_Type2_18	2.750000000	-3.450000000	2.246000000	0 # molecule nr 51
+Ion_Type1_35	3.278000000	-2.669000000	2.418000000	0 # molecule nr 52
+Ion_Type1_36	2.248000000	-3.590000000	3.050000000	0 # molecule nr 53
+Ion_Type2_19	-3.450000000	-0.350000000	2.246000000	0 # molecule nr 54
+Ion_Type1_37	-4.009000000	-0.979000000	2.705000000	0 # molecule nr 55
+Ion_Type1_38	-2.618000000	-0.368000000	2.721000000	0 # molecule nr 56
+Ion_Type2_20	-3.450000000	2.750000000	2.246000000	0 # molecule nr 57
+Ion_Type1_39	-2.871000000	2.071000000	2.596000000	0 # molecule nr 58
+Ion_Type1_40	-3.055000000	3.005000000	1.411000000	0 # molecule nr 59
+Ion_Type2_21	-0.350000000	2.750000000	2.246000000	0 # molecule nr 60
+Ion_Type1_41	-0.895000000	2.539000000	3.005000000	0 # molecule nr 61
+Ion_Type1_42	0.474000000	3.071000000	2.615000000	0 # molecule nr 62
+Ion_Type2_22	2.750000000	2.750000000	2.246000000	0 # molecule nr 63
+Ion_Type1_43	2.127000000	2.133000000	2.633000000	0 # molecule nr 64
+Ion_Type1_44	3.614000000	2.395000000	2.461000000	0 # molecule nr 65
+Ion_Type2_23	-3.450000000	-3.450000000	5.346000000	0 # molecule nr 66
+Ion_Type1_45	-4.270000000	-3.580000000	4.868000000	0 # molecule nr 67
+Ion_Type1_46	-2.760000000	-3.612000000	4.701000000	0 # molecule nr 68
+Ion_Type2_24	-0.350000000	-3.450000000	5.346000000	0 # molecule nr 69
+Ion_Type1_47	-0.994000000	-3.755000000	5.987000000	0 # molecule nr 70
+Ion_Type1_48	0.406000000	-3.176000000	5.867000000	0 # molecule nr 71
+Ion_Type2_25	2.750000000	-3.450000000	5.346000000	0 # molecule nr 72
+Ion_Type1_49	3.193000000	-4.217000000	5.712000000	0 # molecule nr 73
+Ion_Type1_50	3.441000000	-2.795000000	5.238000000	0 # molecule nr 74
+Ion_Type2_26	-3.450000000	-0.350000000	5.346000000	0 # molecule nr 75
+Ion_Type1_51	-3.735000000	0.284000000	4.687000000	0 # molecule nr 76
+Ion_Type1_52	-2.556000000	-0.584000000	5.093000000	0 # molecule nr 77
+Ion_Type2_27	-0.350000000	-0.350000000	5.346000000	0 # molecule nr 78
+Ion_Type1_53	0.379000000	-0.556000000	5.933000000	0 # molecule nr 79
+Ion_Type1_54	-1.067000000	-0.088000000	5.926000000	0 # molecule nr 80
+Ion_Type2_28	2.750000000	-0.350000000	5.346000000	0 # molecule nr 81
+Ion_Type1_55	3.611000000	-0.524000000	5.728000000	0 # molecule nr 82
+Ion_Type1_56	2.123000000	-0.695000000	5.984000000	0 # molecule nr 83
+Ion_Type2_29	-3.450000000	2.750000000	5.346000000	0 # molecule nr 84
+Ion_Type1_57	-3.813000000	1.882000000	5.165000000	0 # molecule nr 85
+Ion_Type1_58	-2.500000000	2.638000000	5.286000000	0 # molecule nr 86
+Ion_Type2_30	-0.350000000	2.750000000	5.346000000	0 # molecule nr 87
+Ion_Type1_59	-0.250000000	3.494000000	4.751000000	0 # molecule nr 88
+Ion_Type1_60	-0.717000000	2.049000000	4.805000000	0 # molecule nr 89
+Ion_Type2_31	2.750000000	2.750000000	5.346000000	0 # molecule nr 90
+Ion_Type1_61	3.468000000	3.235000000	5.756000000	0 # molecule nr 91
+Ion_Type1_62	2.276000000	2.347000000	6.075000000	0 # molecule nr 92
Index: tests/regression/Makefile.am
===================================================================
--- tests/regression/Makefile.am	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Makefile.am	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,30 @@
+AUTOM4TE = autom4te
+EXTRA_DIST = testsuite.at $(TESTSUITE) atlocal.in regression
+TESTSUITE = $(srcdir)/testsuite
+
+check-local: atconfig atlocal package.m4 $(TESTSUITE)
+		$(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS)
+
+installcheck-local: atconfig atlocal $(TESTSUITE)
+		$(SHELL) '$(TESTSUITE)' AUTOTEST_PATH='$(bindir)' \
+		$(TESTSUITEFLAGS)
+     
+clean-local:
+		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 $@
+
+# 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'
Index: tests/regression/Molecules/1/pre/test.conf
===================================================================
--- tests/regression/Molecules/1/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Molecules/1/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,83 @@
+# 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/1/pre/test.dbond
===================================================================
--- tests/regression/Molecules/1/pre/test.dbond	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Molecules/1/pre/test.dbond	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,11 @@
+m	n
+0	1
+0	3
+0	4
+0	5
+1	2
+1	6
+1	7
+2	8
+2	9
+2	10
Index: tests/regression/Molecules/2/post/test.adj
===================================================================
--- tests/regression/Molecules/2/post/test.adj	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Molecules/2/post/test.adj	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,12 @@
+m	n
+0	8	
+1	8	
+2	8	
+3	9	
+4	9	
+5	10	
+6	10	
+7	10	
+8	0	9	1	2	
+9	3	10	4	8	
+10	5	6	7	9	
Index: tests/regression/Molecules/2/post/test.dbond
===================================================================
--- tests/regression/Molecules/2/post/test.dbond	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Molecules/2/post/test.dbond	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,11 @@
+m	n
+0	8
+1	8
+2	8
+3	9
+4	9
+5	10
+6	10
+7	10
+8	9
+9	10
Index: tests/regression/Molecules/2/pre/test.conf
===================================================================
--- tests/regression/Molecules/2/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Molecules/2/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,83 @@
+# 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	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_Type1_1	9.782085945	2.645886050	2.645886050	0 # molecule nr 0
+Ion_Type1_2	9.782085945	2.645886050	4.425886024	0 # molecule nr 1
+Ion_Type1_3	10.672039608	3.904536878	3.535886037	0 # molecule nr 2
+Ion_Type1_4	8.532785963	4.787886018	2.645886050	0 # molecule nr 3
+Ion_Type1_5	8.532785963	4.787886018	4.425886024	0 # molecule nr 4
+Ion_Type1_6	6.393632318	3.904536877	3.535886037	0 # molecule nr 5
+Ion_Type1_7	7.283585982	2.645886050	2.645886050	0 # molecule nr 6
+Ion_Type1_8	7.283585982	2.645886050	4.425886024	0 # molecule nr 7
+Ion_Type2_1	9.782085945	3.275186040	3.535886037	0 # molecule nr 8
+Ion_Type2_2	8.532785963	4.158586027	3.535886037	0 # molecule nr 9
+Ion_Type2_3	7.283585982	3.275186040	3.535886037	0 # molecule nr 10
Index: tests/regression/Molecules/3/post/test.ekin
===================================================================
--- tests/regression/Molecules/3/post/test.ekin	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Molecules/3/post/test.ekin	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,4 @@
+# Step Temperature [K] Temperature [a.u.]
+0	139247	0.44097
+1	25464.1	0.08064
+2	0	0
Index: tests/regression/Molecules/3/pre/test.conf
===================================================================
--- tests/regression/Molecules/3/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Molecules/3/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,119 @@
+# 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 0.1 0. 0.
+Ion_Type2_2	8.532785963	4.158586027	3.535886037	0 0.1 0. 0.
+Ion_Type2_3	7.283585982	3.275186040	3.535886037	0 0.1 0. 0.
+Ion_Type1_1	9.782085945	2.645886050	2.645886050	0 0.1 0. 0.
+Ion_Type1_2	9.782085945	2.645886050	4.425886024	0 0.1 0. 0.
+Ion_Type1_3	10.672039608	3.904536878	3.535886037	0 0.1 0. 0.
+Ion_Type1_4	8.532785963	4.787886018	2.645886050	0 0.1 0. 0.
+Ion_Type1_5	8.532785963	4.787886018	4.425886024	0 0.1 0. 0.
+Ion_Type1_6	6.393632318	3.904536877	3.535886037	0 0.1 0. 0.
+Ion_Type1_7	7.283585982	2.645886050	2.645886050	0 0.1 0. 0.
+Ion_Type1_8	7.283585982	2.645886050	4.425886024	0 0.1 0. 0.
+
+Ion_Type2_1	9.882085945	3.275186040	3.535886037	0 0.1 0. 0.
+Ion_Type2_2	8.632785963	4.158586027	3.535886037	0 0.1 0. 0.
+Ion_Type2_3	7.383585982	3.275186040	3.535886037	0 0.1 0. 0.
+Ion_Type1_1	9.882085945	2.645886050	2.645886050	0 0.1 0. 0.
+Ion_Type1_2	9.882085945	2.645886050	4.425886024	0 0.1 0. 0.
+Ion_Type1_3	10.772039608	3.904536878	3.535886037	0 0.1 0. 0.
+Ion_Type1_4	8.632785963	4.787886018	2.645886050	0 0.1 0. 0.
+Ion_Type1_5	8.632785963	4.787886018	4.425886024	0 0.1 0. 0.
+Ion_Type1_6	6.493632318	3.904536877	3.535886037	0 0.1 0. 0.
+Ion_Type1_7	7.383585982	2.645886050	2.645886050	0 0.1 0. 0.
+Ion_Type1_8	7.383585982	2.645886050	4.425886024	0 0.1 0. 0.
+
+Ion_Type2_1	9.982085945	3.275186040	3.535886037	0 0. 0. 0.
+Ion_Type2_2	8.732785963	4.158586027	3.535886037	0 0. 0. 0.
+Ion_Type2_3	7.483585982	3.275186040	3.535886037	0 0. 0. 0.
+Ion_Type1_1	9.982085945	2.645886050	2.645886050	0 0. 0. 0.
+Ion_Type1_2	9.982085945	2.645886050	4.425886024	0 0. 0. 0.
+Ion_Type1_3	10.872039608	3.904536878	3.535886037	0 0. 0. 0.
+Ion_Type1_4	8.732785963	4.787886018	2.645886050	0 0. 0. 0.
+Ion_Type1_5	8.732785963	4.787886018	4.425886024	0 0. 0. 0.
+Ion_Type1_6	6.593632318	3.904536877	3.535886037	0 0. 0. 0.
+Ion_Type1_7	7.483585982	2.645886050	2.645886050	0 0. 0. 0.
+Ion_Type1_8	7.483585982	2.645886050	4.425886024	0 0. 0. 0.
+
+Ion_Type2_1	9.982085945	3.275186040	3.535886037	0 0. 0. 0.
+Ion_Type2_2	8.732785963	4.158586027	3.535886037	0 0. 0. 0.
+Ion_Type2_3	7.483585982	3.275186040	3.535886037	0 0. 0. 0.
+Ion_Type1_1	9.982085945	2.645886050	2.645886050	0 0. 0. 0.
+Ion_Type1_2	9.982085945	2.645886050	4.425886024	0 0. 0. 0.
+Ion_Type1_3	10.872039608	3.904536878	3.535886037	0 0. 0. 0.
+Ion_Type1_4	8.732785963	4.787886018	2.645886050	0 0. 0. 0.
+Ion_Type1_5	8.732785963	4.787886018	4.425886024	0 0. 0. 0.
+Ion_Type1_6	6.593632318	3.904536877	3.535886037	0 0. 0. 0.
+Ion_Type1_7	7.483585982	2.645886050	2.645886050	0 0. 0. 0.
+Ion_Type1_8	7.483585982	2.645886050	4.425886024	0 0. 0. 0.
Index: tests/regression/Molecules/4/post/test.conf
===================================================================
--- tests/regression/Molecules/4/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Molecules/4/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,107 @@
+# 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 0.1 0. 0.
+Ion_Type2_2	8.532785963	4.158586027	3.535886037	0 0.1 0. 0.
+Ion_Type2_3	7.283585982	3.275186040	3.535886037	0 0.1 0. 0.
+Ion_Type1_1	9.782085945	2.645886050	2.645886050	0 0.1 0. 0.
+Ion_Type1_2	9.782085945	2.645886050	4.425886024	0 0.1 0. 0.
+Ion_Type1_3	10.672039608	3.904536878	3.535886037	0 0.1 0. 0.
+Ion_Type1_4	8.532785963	4.787886018	2.645886050	0 0.1 0. 0.
+Ion_Type1_5	8.532785963	4.787886018	4.425886024	0 0.1 0. 0.
+Ion_Type1_6	6.393632318	3.904536877	3.535886037	0 0.1 0. 0.
+Ion_Type1_7	7.283585982	2.645886050	2.645886050	0 0.1 0. 0.
+Ion_Type1_8	7.283585982	2.645886050	4.425886024	0 0.1 0. 0.
+
+Ion_Type2_1	9.882085945	3.275186040	3.535886037	0 0.1 0. 0.
+Ion_Type2_2	8.632785963	4.158586027	3.535886037	0 0.1 0. 0.
+Ion_Type2_3	7.383585982	3.275186040	3.535886037	0 0.1 0. 0.
+Ion_Type1_1	9.882085945	2.645886050	2.645886050	0 0.1 0. 0.
+Ion_Type1_2	9.882085945	2.645886050	4.425886024	0 0.1 0. 0.
+Ion_Type1_3	10.772039608	3.904536878	3.535886037	0 0.1 0. 0.
+Ion_Type1_4	8.632785963	4.787886018	2.645886050	0 0.1 0. 0.
+Ion_Type1_5	8.632785963	4.787886018	4.425886024	0 0.1 0. 0.
+Ion_Type1_6	6.493632318	3.904536877	3.535886037	0 0.1 0. 0.
+Ion_Type1_7	7.383585982	2.645886050	2.645886050	0 0.1 0. 0.
+Ion_Type1_8	7.383585982	2.645886050	4.425886024	0 0.1 0. 0.
+
+Ion_Type2_1	9.982085945	3.275186040	3.535886037	0 0. 0. 0.
+Ion_Type2_2	8.732785963	4.158586027	3.535886037	0 0. 0. 0.
+Ion_Type2_3	7.483585982	3.275186040	3.535886037	0 0. 0. 0.
+Ion_Type1_1	9.982085945	2.645886050	2.645886050	0 0. 0. 0.
+Ion_Type1_2	9.982085945	2.645886050	4.425886024	0 0. 0. 0.
+Ion_Type1_3	10.872039608	3.904536878	3.535886037	0 0. 0. 0.
+Ion_Type1_4	8.732785963	4.787886018	2.645886050	0 0. 0. 0.
+Ion_Type1_5	8.732785963	4.787886018	4.425886024	0 0. 0. 0.
+Ion_Type1_6	6.593632318	3.904536877	3.535886037	0 0. 0. 0.
+Ion_Type1_7	7.483585982	2.645886050	2.645886050	0 0. 0. 0.
+Ion_Type1_8	7.483585982	2.645886050	4.425886024	0 0. 0. 0.
Index: tests/regression/Molecules/4/pre/test.conf
===================================================================
--- tests/regression/Molecules/4/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Molecules/4/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,95 @@
+# 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 0.1 0. 0.
+Ion_Type2_2	8.532785963	4.158586027	3.535886037	0 0.1 0. 0.
+Ion_Type2_3	7.283585982	3.275186040	3.535886037	0 0.1 0. 0.
+Ion_Type1_1	9.782085945	2.645886050	2.645886050	0 0.1 0. 0.
+Ion_Type1_2	9.782085945	2.645886050	4.425886024	0 0.1 0. 0.
+Ion_Type1_3	10.672039608	3.904536878	3.535886037	0 0.1 0. 0.
+Ion_Type1_4	8.532785963	4.787886018	2.645886050	0 0.1 0. 0.
+Ion_Type1_5	8.532785963	4.787886018	4.425886024	0 0.1 0. 0.
+Ion_Type1_6	6.393632318	3.904536877	3.535886037	0 0.1 0. 0.
+Ion_Type1_7	7.283585982	2.645886050	2.645886050	0 0.1 0. 0.
+Ion_Type1_8	7.283585982	2.645886050	4.425886024	0 0.1 0. 0.
+
+Ion_Type2_1	9.982085945	3.275186040	3.535886037	0 0. 0. 0.
+Ion_Type2_2	8.732785963	4.158586027	3.535886037	0 0. 0. 0.
+Ion_Type2_3	7.483585982	3.275186040	3.535886037	0 0. 0. 0.
+Ion_Type1_1	9.982085945	2.645886050	2.645886050	0 0. 0. 0.
+Ion_Type1_2	9.982085945	2.645886050	4.425886024	0 0. 0. 0.
+Ion_Type1_3	10.872039608	3.904536878	3.535886037	0 0. 0. 0.
+Ion_Type1_4	8.732785963	4.787886018	2.645886050	0 0. 0. 0.
+Ion_Type1_5	8.732785963	4.787886018	4.425886024	0 0. 0. 0.
+Ion_Type1_6	6.593632318	3.904536877	3.535886037	0 0. 0. 0.
+Ion_Type1_7	7.483585982	2.645886050	2.645886050	0 0. 0. 0.
+Ion_Type1_8	7.483585982	2.645886050	4.425886024	0 0. 0. 0.
Index: tests/regression/Molecules/5/pre/test.conf
===================================================================
--- tests/regression/Molecules/5/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Molecules/5/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,83 @@
+# 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	10	# 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 0.1 0. 0.
+Ion_Type2_2	8.532785963	4.158586027	3.535886037	0 0.1 0. 0.
+Ion_Type2_3	7.283585982	3.275186040	3.535886037	0 0.1 0. 0.
+Ion_Type1_1	9.782085945	2.645886050	2.645886050	0 0.1 0. 0.
+Ion_Type1_2	9.782085945	2.645886050	4.425886024	0 0.1 0. 0.
+Ion_Type1_3	10.672039608	3.904536878	3.535886037	0 0.1 0. 0.
+Ion_Type1_4	8.532785963	4.787886018	2.645886050	0 0.1 0. 0.
+Ion_Type1_5	8.532785963	4.787886018	4.425886024	0 0.1 0. 0.
+Ion_Type1_6	6.393632318	3.904536877	3.535886037	0 0.1 0. 0.
+Ion_Type1_7	7.283585982	2.645886050	2.645886050	0 0.1 0. 0.
+Ion_Type1_8	7.283585982	2.645886050	4.425886024	0 0.1 0. 0.
Index: tests/regression/Molecules/5/pre/test.forces
===================================================================
--- tests/regression/Molecules/5/pre/test.forces	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Molecules/5/pre/test.forces	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,12 @@
+#atom	x	y	z
+1	0.1	0.1	0.
+2	0.1	0.1	0.
+3	0.1	0.1	0.
+4	0.1	0.1	0.
+5	0.1	0.1	0.
+6	0.1	0.1	0.
+7	0.1	0.1	0.
+8	0.1	0.1	0.
+9	0.1	0.1	0.
+10	0.1	0.1	0.
+11	0.1	0.1	0.
Index: tests/regression/Molecules/6/post/test.conf
===================================================================
--- tests/regression/Molecules/6/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Molecules/6/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,83 @@
+# 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	10	# 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	10	# 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	10	# here: specifying both maximum number of SpinUp- and -Down-states
+PsiMaxNoUp	10	# here: specifying maximum number of SpinUp-states
+PsiMaxNoDown	10	# 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_Type1_1	10.782085945	3.645886050	3.645886050	0 # molecule nr 0
+Ion_Type1_2	10.782085945	3.645886050	5.425886024	0 # molecule nr 1
+Ion_Type1_3	11.672039608	4.904536878	4.535886037	0 # molecule nr 2
+Ion_Type1_4	9.532785963	5.787886018	3.645886050	0 # molecule nr 3
+Ion_Type1_5	9.532785963	5.787886018	5.425886024	0 # molecule nr 4
+Ion_Type1_6	7.393632318	4.904536877	4.535886037	0 # molecule nr 5
+Ion_Type1_7	8.283585982	3.645886050	3.645886050	0 # molecule nr 6
+Ion_Type1_8	8.283585982	3.645886050	5.425886024	0 # molecule nr 7
+Ion_Type2_1	10.782085945	4.275186040	4.535886037	0 # molecule nr 8
+Ion_Type2_2	9.532785963	5.158586027	4.535886037	0 # molecule nr 9
+Ion_Type2_3	8.283585982	4.275186040	4.535886037	0 # molecule nr 10
Index: tests/regression/Molecules/6/post/test2.conf
===================================================================
--- tests/regression/Molecules/6/post/test2.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Molecules/6/post/test2.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,83 @@
+# 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	10	# 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	10	# 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	10	# here: specifying both maximum number of SpinUp- and -Down-states
+PsiMaxNoUp	10	# here: specifying maximum number of SpinUp-states
+PsiMaxNoDown	10	# 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_Type1_1	8.782085945	1.645886050	1.645886050	0 # molecule nr 0
+Ion_Type1_2	8.782085945	1.645886050	3.425886024	0 # molecule nr 1
+Ion_Type1_3	9.672039608	2.904536878	2.535886037	0 # molecule nr 2
+Ion_Type1_4	7.532785963	3.787886018	1.645886050	0 # molecule nr 3
+Ion_Type1_5	7.532785963	3.787886018	3.425886024	0 # molecule nr 4
+Ion_Type1_6	5.393632318	2.904536877	2.535886037	0 # molecule nr 5
+Ion_Type1_7	6.283585982	1.645886050	1.645886050	0 # molecule nr 6
+Ion_Type1_8	6.283585982	1.645886050	3.425886024	0 # molecule nr 7
+Ion_Type2_1	8.782085945	2.275186040	2.535886037	0 # molecule nr 8
+Ion_Type2_2	7.532785963	3.158586027	2.535886037	0 # molecule nr 9
+Ion_Type2_3	6.283585982	2.275186040	2.535886037	0 # molecule nr 10
Index: tests/regression/Molecules/6/pre/test.conf
===================================================================
--- tests/regression/Molecules/6/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Molecules/6/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,83 @@
+# 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_Type1_1	9.782085945	2.645886050	2.645886050	0 # molecule nr 0
+Ion_Type1_2	9.782085945	2.645886050	4.425886024	0 # molecule nr 1
+Ion_Type1_3	10.672039608	3.904536878	3.535886037	0 # molecule nr 2
+Ion_Type1_4	8.532785963	4.787886018	2.645886050	0 # molecule nr 3
+Ion_Type1_5	8.532785963	4.787886018	4.425886024	0 # molecule nr 4
+Ion_Type1_6	6.393632318	3.904536877	3.535886037	0 # molecule nr 5
+Ion_Type1_7	7.283585982	2.645886050	2.645886050	0 # molecule nr 6
+Ion_Type1_8	7.283585982	2.645886050	4.425886024	0 # molecule nr 7
+Ion_Type2_1	9.782085945	3.275186040	3.535886037	0 # molecule nr 8
+Ion_Type2_2	8.532785963	4.158586027	3.535886037	0 # molecule nr 9
+Ion_Type2_3	7.283585982	3.275186040	3.535886037	0 # molecule nr 10
Index: tests/regression/Molecules/6/pre/test2.conf
===================================================================
--- tests/regression/Molecules/6/pre/test2.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Molecules/6/pre/test2.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,83 @@
+# 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_Type1_1	9.782085945	2.645886050	2.645886050	0 # molecule nr 0
+Ion_Type1_2	9.782085945	2.645886050	4.425886024	0 # molecule nr 1
+Ion_Type1_3	10.672039608	3.904536878	3.535886037	0 # molecule nr 2
+Ion_Type1_4	8.532785963	4.787886018	2.645886050	0 # molecule nr 3
+Ion_Type1_5	8.532785963	4.787886018	4.425886024	0 # molecule nr 4
+Ion_Type1_6	6.393632318	3.904536877	3.535886037	0 # molecule nr 5
+Ion_Type1_7	7.283585982	2.645886050	2.645886050	0 # molecule nr 6
+Ion_Type1_8	7.283585982	2.645886050	4.425886024	0 # molecule nr 7
+Ion_Type2_1	9.782085945	3.275186040	3.535886037	0 # molecule nr 8
+Ion_Type2_2	8.532785963	4.158586027	3.535886037	0 # molecule nr 9
+Ion_Type2_3	7.283585982	3.275186040	3.535886037	0 # molecule nr 10
Index: tests/regression/Molecules/7/post/test.conf
===================================================================
--- tests/regression/Molecules/7/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Molecules/7/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,83 @@
+# 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	10	# 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	10	# 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	10	# here: specifying both maximum number of SpinUp- and -Down-states
+PsiMaxNoUp	10	# here: specifying maximum number of SpinUp-states
+PsiMaxNoDown	10	# 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_Type1_1	1.782085945	14.645886050	14.645886050	0 # molecule nr 0
+Ion_Type1_2	1.782085945	14.645886050	16.425886024	0 # molecule nr 1
+Ion_Type1_3	2.672039608	15.904536878	15.535886037	0 # molecule nr 2
+Ion_Type1_4	0.532785963	16.787886018	14.645886050	0 # molecule nr 3
+Ion_Type1_5	0.532785963	16.787886018	16.425886024	0 # molecule nr 4
+Ion_Type1_6	18.393632318	15.904536877	15.535886037	0 # molecule nr 5
+Ion_Type1_7	19.283585982	14.645886050	14.645886050	0 # molecule nr 6
+Ion_Type1_8	19.283585982	14.645886050	16.425886024	0 # molecule nr 7
+Ion_Type2_1	1.782085945	15.275186040	15.535886037	0 # molecule nr 8
+Ion_Type2_2	0.532785963	16.158586027	15.535886037	0 # molecule nr 9
+Ion_Type2_3	19.283585982	15.275186040	15.535886037	0 # molecule nr 10
Index: tests/regression/Molecules/7/pre/test.conf
===================================================================
--- tests/regression/Molecules/7/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Molecules/7/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,83 @@
+# 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_Type1_1	9.782085945	2.645886050	2.645886050	0 # molecule nr 0
+Ion_Type1_2	9.782085945	2.645886050	4.425886024	0 # molecule nr 1
+Ion_Type1_3	10.672039608	3.904536878	3.535886037	0 # molecule nr 2
+Ion_Type1_4	8.532785963	4.787886018	2.645886050	0 # molecule nr 3
+Ion_Type1_5	8.532785963	4.787886018	4.425886024	0 # molecule nr 4
+Ion_Type1_6	6.393632318	3.904536877	3.535886037	0 # molecule nr 5
+Ion_Type1_7	7.283585982	2.645886050	2.645886050	0 # molecule nr 6
+Ion_Type1_8	7.283585982	2.645886050	4.425886024	0 # molecule nr 7
+Ion_Type2_1	9.782085945	3.275186040	3.535886037	0 # molecule nr 8
+Ion_Type2_2	8.532785963	4.158586027	3.535886037	0 # molecule nr 9
+Ion_Type2_3	7.283585982	3.275186040	3.535886037	0 # molecule nr 10
Index: tests/regression/Molecules/8/pre/test.conf
===================================================================
--- tests/regression/Molecules/8/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Molecules/8/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,83 @@
+# 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/Simple_configuration/1/post/test.xyz
===================================================================
--- tests/regression/Simple_configuration/1/post/test.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Simple_configuration/1/post/test.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,3 @@
+1
+ # test configuration, created by molecuilder test suite
+H	10.	10.	10.
Index: tests/regression/Simple_configuration/2/post/test.conf
===================================================================
--- tests/regression/Simple_configuration/2/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Simple_configuration/2/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,72 @@
+# 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	10.000000000	10.000000000	10.000000000	0 # molecule nr 0
Index: tests/regression/Simple_configuration/2/post/test.in
===================================================================
--- tests/regression/Simple_configuration/2/post/test.in	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Simple_configuration/2/post/test.in	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,24 @@
+% 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: tests/regression/Simple_configuration/2/post/test.xyz
===================================================================
--- tests/regression/Simple_configuration/2/post/test.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Simple_configuration/2/post/test.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,3 @@
+1
+	Created by molecuilder on Tue Oct  6 18:34:23 2009
+H	10	10	10
Index: tests/regression/Simple_configuration/2/pre/test.xyz
===================================================================
--- tests/regression/Simple_configuration/2/pre/test.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Simple_configuration/2/pre/test.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,3 @@
+1
+ # test configuration, created by molecuilder test suite
+H	10.	10.	10.
Index: tests/regression/Simple_configuration/3/post/test.conf
===================================================================
--- tests/regression/Simple_configuration/3/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Simple_configuration/3/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,72 @@
+# 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	10.000000000	10.000000000	10.000000000	0 # molecule nr 0
Index: tests/regression/Simple_configuration/3/post/test.in
===================================================================
--- tests/regression/Simple_configuration/3/post/test.in	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Simple_configuration/3/post/test.in	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,24 @@
+% 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: tests/regression/Simple_configuration/3/post/test.xyz
===================================================================
--- tests/regression/Simple_configuration/3/post/test.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Simple_configuration/3/post/test.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,3 @@
+1
+	Created by molecuilder on Tue Oct  6 18:34:23 2009
+H	10	10	10
Index: tests/regression/Simple_configuration/3/post/test2.conf
===================================================================
--- tests/regression/Simple_configuration/3/post/test2.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Simple_configuration/3/post/test2.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,72 @@
+# 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: tests/regression/Simple_configuration/3/post/test2.in
===================================================================
--- tests/regression/Simple_configuration/3/post/test2.in	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Simple_configuration/3/post/test2.in	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,24 @@
+% 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: tests/regression/Simple_configuration/3/post/test2.xyz
===================================================================
--- tests/regression/Simple_configuration/3/post/test2.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Simple_configuration/3/post/test2.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,3 @@
+1
+	Created by molecuilder on Tue Oct  6 18:34:23 2009
+H	0	0	-1
Index: tests/regression/Simple_configuration/4/post/test.xyz
===================================================================
--- tests/regression/Simple_configuration/4/post/test.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Simple_configuration/4/post/test.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,3 @@
+1
+	Created by molecuilder on
+C	10	10	10
Index: tests/regression/Simple_configuration/4/pre/test.xyz
===================================================================
--- tests/regression/Simple_configuration/4/pre/test.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Simple_configuration/4/pre/test.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,3 @@
+1
+	Created by molecuilder on
+H	10	10	10
Index: tests/regression/Simple_configuration/5/post/test.conf
===================================================================
--- tests/regression/Simple_configuration/5/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Simple_configuration/5/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -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	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	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: tests/regression/Simple_configuration/5/post/test.in
===================================================================
--- tests/regression/Simple_configuration/5/post/test.in	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Simple_configuration/5/post/test.in	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,23 @@
+% 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 } = {
+	}
+)
+basis<GaussianBasisSet>: (
+	name = "3-21G"
+	molecule = $:molecule
+)
Index: tests/regression/Simple_configuration/5/post/test.xyz
===================================================================
--- tests/regression/Simple_configuration/5/post/test.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Simple_configuration/5/post/test.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,2 @@
+0
+	Created by molecuilder on Tue Oct  6 19:18:13 2009
Index: tests/regression/Simple_configuration/5/pre/test.conf
===================================================================
--- tests/regression/Simple_configuration/5/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Simple_configuration/5/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,72 @@
+# 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	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	10.000000000	10.000000000	10.000000000	0 # molecule nr 0
Index: tests/regression/Simple_configuration/6/pre/empty.conf
===================================================================
--- tests/regression/Simple_configuration/6/pre/empty.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Simple_configuration/6/pre/empty.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -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: tests/regression/Simple_configuration/7/pre/test.conf
===================================================================
--- tests/regression/Simple_configuration/7/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Simple_configuration/7/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,72 @@
+# 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	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	10.000000000	10.000000000	10.000000000	0 # molecule nr 0
Index: tests/regression/Simple_configuration/8/post/test.xyz
===================================================================
--- tests/regression/Simple_configuration/8/post/test.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Simple_configuration/8/post/test.xyz	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,146 @@
+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 ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Simple_configuration/8/post/test.xyz-sorted	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,145 @@
+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
+144
Index: tests/regression/Simple_configuration/8/pre/test.conf
===================================================================
--- tests/regression/Simple_configuration/8/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Simple_configuration/8/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,1089 @@
+# 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/Tesselation/1/post/NonConvexEnvelope.dat
===================================================================
--- tests/regression/Tesselation/1/post/NonConvexEnvelope.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Tesselation/1/post/NonConvexEnvelope.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,24 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="test", N=8, E=12, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+9.78209 2.64589 2.64589 -9.24443
+9.78209 2.64589 4.42589 -11.4804
+10.672 3.90454 3.53589 -9.35464
+8.53279 4.78789 2.64589 -9.11459
+8.53279 4.78789 4.42589 -9.11459
+6.39363 3.90454 3.53589 -9.35431
+7.28359 2.64589 2.64589 -11.4803
+7.28359 2.64589 4.42589 -9.24433
+
+1 3 4
+1 4 7
+4 6 7
+3 4 5
+4 5 6
+2 3 5
+2 5 8
+5 6 8
+6 7 8
+2 7 8
+1 2 7
+1 2 3
Index: tests/regression/Tesselation/1/post/NonConvexEnvelope.r3d
===================================================================
--- tests/regression/Tesselation/1/post/NonConvexEnvelope.r3d	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Tesselation/1/post/NonConvexEnvelope.r3d	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,63 @@
+# Raster3D object description, created by MoleCuilder
+@header.r3d
+# All atoms as spheres
+2
+  1.24926 -0.870237 -0.89 	0.1	1. 1. 1.
+2
+  1.24926 -0.870237 0.89 	0.1	1. 1. 1.
+2
+  2.13922 0.388414 0 	0.1	1. 1. 1.
+2
+  -3.63639e-05 1.27176 -0.89 	0.1	1. 1. 1.
+2
+  -3.63639e-05 1.27176 0.89 	0.1	1. 1. 1.
+2
+  -2.13919 0.388414 0 	0.1	1. 1. 1.
+2
+  -1.24924 -0.870237 -0.89 	0.1	1. 1. 1.
+2
+  -1.24924 -0.870237 0.89 	0.1	1. 1. 1.
+2
+  1.24926 -0.240937 0 	0.1	1. 1. 1.
+2
+  -3.63639e-05 0.642463 0 	0.1	1. 1. 1.
+2
+  -1.24924 -0.240937 0 	0.1	1. 1. 1.
+# All tesselation triangles
+8
+  25. -1.   1. 1. 1.   0.0    0 0 0 2
+  SOLID     1.0 0.0 0.0
+  BACKFACE  0.3 0.3 1.0   0 0
+1
+  1.24926 -0.870237 -0.89 	2.13922 0.388414 0 	-3.63639e-05 1.27176 -0.89 	1. 0. 0.
+1
+  1.24926 -0.870237 -0.89 	-3.63639e-05 1.27176 -0.89 	-1.24924 -0.870237 -0.89 	1. 0. 0.
+1
+  -3.63639e-05 1.27176 -0.89 	-2.13919 0.388414 0 	-1.24924 -0.870237 -0.89 	1. 0. 0.
+1
+  2.13922 0.388414 0 	-3.63639e-05 1.27176 -0.89 	-3.63639e-05 1.27176 0.89 	1. 0. 0.
+1
+  -3.63639e-05 1.27176 -0.89 	-3.63639e-05 1.27176 0.89 	-2.13919 0.388414 0 	1. 0. 0.
+1
+  1.24926 -0.870237 0.89 	2.13922 0.388414 0 	-3.63639e-05 1.27176 0.89 	1. 0. 0.
+1
+  1.24926 -0.870237 0.89 	-3.63639e-05 1.27176 0.89 	-1.24924 -0.870237 0.89 	1. 0. 0.
+1
+  -3.63639e-05 1.27176 0.89 	-2.13919 0.388414 0 	-1.24924 -0.870237 0.89 	1. 0. 0.
+1
+  -2.13919 0.388414 0 	-1.24924 -0.870237 -0.89 	-1.24924 -0.870237 0.89 	1. 0. 0.
+1
+  1.24926 -0.870237 0.89 	-1.24924 -0.870237 -0.89 	-1.24924 -0.870237 0.89 	1. 0. 0.
+1
+  1.24926 -0.870237 -0.89 	1.24926 -0.870237 0.89 	-1.24924 -0.870237 -0.89 	1. 0. 0.
+1
+  1.24926 -0.870237 -0.89 	1.24926 -0.870237 0.89 	2.13922 0.388414 0 	1. 0. 0.
+9
+#  terminating special property
+# current virtual sphere
+8
+  25.0    0.6     -1.0 -1.0 -1.0     0.2        0 0 0 0
+2
+  1.54591 -0.450686 -4.44089e-16	5	1 0 0
+9
+  terminating special property
Index: tests/regression/Tesselation/1/post/test.conf
===================================================================
--- tests/regression/Tesselation/1/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Tesselation/1/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,83 @@
+# 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/Tesselation/1/pre/test.conf
===================================================================
--- tests/regression/Tesselation/1/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Tesselation/1/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,83 @@
+# 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/Tesselation/2/post/ConvexEnvelope.dat
===================================================================
--- tests/regression/Tesselation/2/post/ConvexEnvelope.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Tesselation/2/post/ConvexEnvelope.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,24 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="test", N=8, E=12, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+9.78209 2.64589 2.64589 -9.24443
+9.78209 2.64589 4.42589 -11.4804
+10.672 3.90454 3.53589 -9.35464
+8.53279 4.78789 2.64589 -9.11459
+8.53279 4.78789 4.42589 -9.11459
+6.39363 3.90454 3.53589 -9.35431
+7.28359 2.64589 2.64589 -11.4803
+7.28359 2.64589 4.42589 -9.24433
+
+1 3 4
+1 4 7
+4 6 7
+3 4 5
+4 5 6
+2 3 5
+2 5 8
+5 6 8
+6 7 8
+2 7 8
+1 2 7
+1 2 3
Index: tests/regression/Tesselation/2/post/ConvexEnvelope.r3d
===================================================================
--- tests/regression/Tesselation/2/post/ConvexEnvelope.r3d	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Tesselation/2/post/ConvexEnvelope.r3d	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,63 @@
+# Raster3D object description, created by MoleCuilder
+@header.r3d
+# All atoms as spheres
+2
+  1.24926 -0.870237 -0.89 	0.1	1. 1. 1.
+2
+  1.24926 -0.870237 0.89 	0.1	1. 1. 1.
+2
+  2.13922 0.388414 0 	0.1	1. 1. 1.
+2
+  -3.63639e-05 1.27176 -0.89 	0.1	1. 1. 1.
+2
+  -3.63639e-05 1.27176 0.89 	0.1	1. 1. 1.
+2
+  -2.13919 0.388414 0 	0.1	1. 1. 1.
+2
+  -1.24924 -0.870237 -0.89 	0.1	1. 1. 1.
+2
+  -1.24924 -0.870237 0.89 	0.1	1. 1. 1.
+2
+  1.24926 -0.240937 0 	0.1	1. 1. 1.
+2
+  -3.63639e-05 0.642463 0 	0.1	1. 1. 1.
+2
+  -1.24924 -0.240937 0 	0.1	1. 1. 1.
+# All tesselation triangles
+8
+  25. -1.   1. 1. 1.   0.0    0 0 0 2
+  SOLID     1.0 0.0 0.0
+  BACKFACE  0.3 0.3 1.0   0 0
+1
+  1.24926 -0.870237 -0.89 	2.13922 0.388414 0 	-3.63639e-05 1.27176 -0.89 	1. 0. 0.
+1
+  1.24926 -0.870237 -0.89 	-3.63639e-05 1.27176 -0.89 	-1.24924 -0.870237 -0.89 	1. 0. 0.
+1
+  -3.63639e-05 1.27176 -0.89 	-2.13919 0.388414 0 	-1.24924 -0.870237 -0.89 	1. 0. 0.
+1
+  2.13922 0.388414 0 	-3.63639e-05 1.27176 -0.89 	-3.63639e-05 1.27176 0.89 	1. 0. 0.
+1
+  -3.63639e-05 1.27176 -0.89 	-3.63639e-05 1.27176 0.89 	-2.13919 0.388414 0 	1. 0. 0.
+1
+  1.24926 -0.870237 0.89 	2.13922 0.388414 0 	-3.63639e-05 1.27176 0.89 	1. 0. 0.
+1
+  1.24926 -0.870237 0.89 	-3.63639e-05 1.27176 0.89 	-1.24924 -0.870237 0.89 	1. 0. 0.
+1
+  -3.63639e-05 1.27176 0.89 	-2.13919 0.388414 0 	-1.24924 -0.870237 0.89 	1. 0. 0.
+1
+  -2.13919 0.388414 0 	-1.24924 -0.870237 -0.89 	-1.24924 -0.870237 0.89 	1. 0. 0.
+1
+  1.24926 -0.870237 0.89 	-1.24924 -0.870237 -0.89 	-1.24924 -0.870237 0.89 	1. 0. 0.
+1
+  1.24926 -0.870237 -0.89 	1.24926 -0.870237 0.89 	-1.24924 -0.870237 -0.89 	1. 0. 0.
+1
+  1.24926 -0.870237 -0.89 	1.24926 -0.870237 0.89 	2.13922 0.388414 0 	1. 0. 0.
+9
+#  terminating special property
+# current virtual sphere
+8
+  25.0    0.6     -1.0 -1.0 -1.0     0.2        0 0 0 0
+2
+  1.54591 -0.450686 -4.44089e-16	5	1 0 0
+9
+  terminating special property
Index: tests/regression/Tesselation/2/post/NonConvexEnvelope.dat
===================================================================
--- tests/regression/Tesselation/2/post/NonConvexEnvelope.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Tesselation/2/post/NonConvexEnvelope.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,24 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="test", N=8, E=12, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+9.78209 2.64589 2.64589 -9.24443
+9.78209 2.64589 4.42589 -11.4804
+10.672 3.90454 3.53589 -9.35464
+8.53279 4.78789 2.64589 -9.11459
+8.53279 4.78789 4.42589 -9.11459
+6.39363 3.90454 3.53589 -9.35431
+7.28359 2.64589 2.64589 -11.4803
+7.28359 2.64589 4.42589 -9.24433
+
+1 3 4
+1 4 7
+4 6 7
+3 4 5
+4 5 6
+2 3 5
+2 5 8
+5 6 8
+6 7 8
+2 7 8
+1 2 7
+1 2 3
Index: tests/regression/Tesselation/2/post/NonConvexEnvelope.r3d
===================================================================
--- tests/regression/Tesselation/2/post/NonConvexEnvelope.r3d	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Tesselation/2/post/NonConvexEnvelope.r3d	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,63 @@
+# Raster3D object description, created by MoleCuilder
+@header.r3d
+# All atoms as spheres
+2
+  1.24926 -0.870237 -0.89 	0.1	1. 1. 1.
+2
+  1.24926 -0.870237 0.89 	0.1	1. 1. 1.
+2
+  2.13922 0.388414 0 	0.1	1. 1. 1.
+2
+  -3.63639e-05 1.27176 -0.89 	0.1	1. 1. 1.
+2
+  -3.63639e-05 1.27176 0.89 	0.1	1. 1. 1.
+2
+  -2.13919 0.388414 0 	0.1	1. 1. 1.
+2
+  -1.24924 -0.870237 -0.89 	0.1	1. 1. 1.
+2
+  -1.24924 -0.870237 0.89 	0.1	1. 1. 1.
+2
+  1.24926 -0.240937 0 	0.1	1. 1. 1.
+2
+  -3.63639e-05 0.642463 0 	0.1	1. 1. 1.
+2
+  -1.24924 -0.240937 0 	0.1	1. 1. 1.
+# All tesselation triangles
+8
+  25. -1.   1. 1. 1.   0.0    0 0 0 2
+  SOLID     1.0 0.0 0.0
+  BACKFACE  0.3 0.3 1.0   0 0
+1
+  1.24926 -0.870237 -0.89 	2.13922 0.388414 0 	-3.63639e-05 1.27176 -0.89 	1. 0. 0.
+1
+  1.24926 -0.870237 -0.89 	-3.63639e-05 1.27176 -0.89 	-1.24924 -0.870237 -0.89 	1. 0. 0.
+1
+  -3.63639e-05 1.27176 -0.89 	-2.13919 0.388414 0 	-1.24924 -0.870237 -0.89 	1. 0. 0.
+1
+  2.13922 0.388414 0 	-3.63639e-05 1.27176 -0.89 	-3.63639e-05 1.27176 0.89 	1. 0. 0.
+1
+  -3.63639e-05 1.27176 -0.89 	-3.63639e-05 1.27176 0.89 	-2.13919 0.388414 0 	1. 0. 0.
+1
+  1.24926 -0.870237 0.89 	2.13922 0.388414 0 	-3.63639e-05 1.27176 0.89 	1. 0. 0.
+1
+  1.24926 -0.870237 0.89 	-3.63639e-05 1.27176 0.89 	-1.24924 -0.870237 0.89 	1. 0. 0.
+1
+  -3.63639e-05 1.27176 0.89 	-2.13919 0.388414 0 	-1.24924 -0.870237 0.89 	1. 0. 0.
+1
+  -2.13919 0.388414 0 	-1.24924 -0.870237 -0.89 	-1.24924 -0.870237 0.89 	1. 0. 0.
+1
+  1.24926 -0.870237 0.89 	-1.24924 -0.870237 -0.89 	-1.24924 -0.870237 0.89 	1. 0. 0.
+1
+  1.24926 -0.870237 -0.89 	1.24926 -0.870237 0.89 	-1.24924 -0.870237 -0.89 	1. 0. 0.
+1
+  1.24926 -0.870237 -0.89 	1.24926 -0.870237 0.89 	2.13922 0.388414 0 	1. 0. 0.
+9
+#  terminating special property
+# current virtual sphere
+8
+  25.0    0.6     -1.0 -1.0 -1.0     0.2        0 0 0 0
+2
+  1.54591 -0.450686 -4.44089e-16	5	1 0 0
+9
+  terminating special property
Index: tests/regression/Tesselation/2/post/test.conf
===================================================================
--- tests/regression/Tesselation/2/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Tesselation/2/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,83 @@
+# 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/Tesselation/2/pre/test.conf
===================================================================
--- tests/regression/Tesselation/2/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Tesselation/2/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,83 @@
+# 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/Tesselation/3/post/NonConvexEnvelope.dat
===================================================================
--- tests/regression/Tesselation/3/post/NonConvexEnvelope.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Tesselation/3/post/NonConvexEnvelope.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,134 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="test", N=44, E=86, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+6.9077 1.1106 0.1214 -6.99715
+0.3612 -3.628 1.323 6.00416
+0.4884 -3.5983 -0.4521 11.8428
+1.4985 -2.5112 0.5308 6.07951
+-1.9534 -3.5752 0.5362 -4.26914
+-1.1883 -0.199 1.5176 14.2992
+-0.7165 -1.6046 2.5129 6.2134
+1.7627 -1.4479 -0.8349 7.15053
+-1.003 -1.3584 -2.8848 32.043
+0.0217 -2.6629 -2.2008 16.8009
+-2.8885 -1.5706 1.7543 -1.77076
+-2.0579 -3.6765 -1.7622 -7.05319
+-2.9259 -2.1146 -1.7672 33.6663
+1.0353 0.1785 2.542 48.8869
+1.6325 -1.3323 1.8306 1.44108
+0.7271 1.177 0.3594 27.9872
+1.3374 -0.2942 -2.961 13.6459
+0.6036 1.0859 -2.1126 98.521
+-3.2034 -0.5041 -1.0881 8.44805
+-5.1809 -1.8679 0.9687 -6.07448
+-4.6025 -2.4721 -0.6025 -6.52057
+-4.3385 -3.4329 0.8725 -4.12716
+3.191 1.3217 -2.8354 -10.5968
+-4.0905 0.6312 1.6028 21.8745
+2.8131 1.4776 2.5103 -0.774194
+3.9137 2.2936 1.3739 -2.51806
+2.159 2.5738 1.2698 151.494
+3.6606 -0.4593 2.1396 2.60004
+3.2007 -1.4419 0.7311 2.29272
+-3.3002 2.3589 0.0094 461.065
+-4.377 1.6962 -1.2433 43.4649
+5.2593 1.4547 -1.7445 -6.26082
+4.6863 2.7674 -0.6775 -8.55931
+5.746 -0.9031 1.204 -1.29544
+5.1212 -0.8867 -0.4582 31.5177
+-5.2641 2.8314 1.4476 21.5516
+5.2727 1.6068 1.2828 -2.57271
+-6.2394 4.6427 0.0632 -9.24392
+-4.4738 4.5591 -0.1458 62.5211
+-5.5506 3.8964 -1.3985 -10.3613
+-6.7081 0.9923 0.6224 -7.08885
+-7.5442 2.5597 0.5118 -11.4252
+-6.8554 1.8134 -0.9499 3.80444
+7.1391 2.0447 0.0264 -7.88713
+
+1 32 44
+1 32 35
+1 34 35
+23 32 35
+17 23 35
+8 17 35
+8 10 17
+3 8 10
+3 8 35
+3 4 35
+4 29 35
+29 34 35
+2 3 4
+2 4 29
+2 15 29
+15 28 29
+28 29 34
+2 7 15
+7 14 15
+14 15 28
+14 25 28
+25 28 37
+28 34 37
+1 34 37
+1 37 44
+25 26 37
+25 26 27
+26 27 33
+26 33 44
+26 37 44
+14 25 27
+14 27 30
+6 14 30
+6 24 30
+24 30 36
+30 36 39
+27 30 39
+27 30 39
+16 27 30
+16 18 30
+16 18 27
+18 27 33
+18 23 33
+6 7 24
+6 7 14
+7 11 24
+11 20 24
+20 24 41
+24 36 41
+36 41 42
+11 20 22
+5 11 22
+5 7 11
+2 5 7
+36 38 39
+36 38 42
+18 30 31
+30 31 39
+31 39 40
+9 18 31
+9 17 18
+17 18 23
+9 19 31
+9 13 19
+13 19 31
+13 21 31
+21 31 43
+31 40 43
+9 12 13
+9 10 12
+9 10 17
+12 13 21
+12 21 22
+5 12 22
+3 5 12
+2 3 5
+3 10 12
+20 21 22
+20 21 41
+21 41 43
+41 42 43
+23 32 33
+32 33 44
+40 42 43
+38 40 42
+38 39 40
Index: tests/regression/Tesselation/3/post/NonConvexEnvelope.r3d
===================================================================
--- tests/regression/Tesselation/3/post/NonConvexEnvelope.r3d	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Tesselation/3/post/NonConvexEnvelope.r3d	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,337 @@
+# Raster3D object description, created by MoleCuilder
+@header.r3d
+# All atoms as spheres
+2
+  0.939662 -3.01666 0.414493 	0.1	1. 1. 1.
+2
+  -0.152738 -1.94716 0.354093 	0.1	1. 1. 1.
+2
+  0.0659622 -1.03376 -0.880907 	0.1	1. 1. 1.
+2
+  -1.50434 -2.59696 0.0723932 	0.1	1. 1. 1.
+2
+  -0.0717378 -1.05346 1.57779 	0.1	1. 1. 1.
+2
+  1.52186 -0.603155 -0.873807 	0.1	1. 1. 1.
+2
+  -0.346038 -1.95996 -2.03011 	0.1	1. 1. 1.
+2
+  -2.63434 -1.74086 0.647893 	0.1	1. 1. 1.
+2
+  -1.61364 -2.66266 -1.47131 	0.1	1. 1. 1.
+2
+  1.36626 -0.519255 1.65039 	0.1	1. 1. 1.
+2
+  1.74646 0.246745 0.389693 	0.1	1. 1. 1.
+2
+  1.78606 0.287745 -2.09451 	0.1	1. 1. 1.
+2
+  -2.65324 -0.381955 -0.0548068 	0.1	1. 1. 1.
+2
+  -3.97304 -2.44796 0.426993 	0.1	1. 1. 1.
+2
+  3.21726 0.635145 0.478793 	0.1	1. 1. 1.
+2
+  3.13516 0.931145 -1.97401 	0.1	1. 1. 1.
+2
+  -3.80794 0.459345 0.492693 	0.1	1. 1. 1.
+2
+  3.34736 1.81094 1.44919 	0.1	1. 1. 1.
+2
+  3.76986 1.05884 -0.855107 	0.1	1. 1. 1.
+2
+  4.05806 -0.522555 1.01199 	0.1	1. 1. 1.
+2
+  -3.82684 1.81824 -0.210007 	0.1	1. 1. 1.
+2
+  5.16496 1.66244 -0.848507 	0.1	1. 1. 1.
+2
+  5.48576 -0.422855 0.476393 	0.1	1. 1. 1.
+2
+  -4.98154 2.65954 0.337493 	0.1	1. 1. 1.
+2
+  5.91796 1.03174 0.331693 	0.1	1. 1. 1.
+2
+  -5.00044 4.01854 -0.365207 	0.1	1. 1. 1.
+2
+  -6.30524 1.93554 0.0833932 	0.1	1. 1. 1.
+2
+  7.32406 1.08574 0.0829932 	0.1	1. 1. 1.
+2
+  0.777562 -3.65286 1.28459 	0.1	1. 1. 1.
+2
+  0.904762 -3.62316 -0.490507 	0.1	1. 1. 1.
+2
+  1.91486 -2.53606 0.492393 	0.1	1. 1. 1.
+2
+  -0.587138 -0.162455 -0.830407 	0.1	1. 1. 1.
+2
+  -1.53704 -3.60006 0.497793 	0.1	1. 1. 1.
+2
+  -0.771938 -0.223855 1.47919 	0.1	1. 1. 1.
+2
+  -0.300138 -1.62946 2.47449 	0.1	1. 1. 1.
+2
+  2.17906 -1.47276 -0.873307 	0.1	1. 1. 1.
+2
+  -0.586638 -1.38326 -2.92321 	0.1	1. 1. 1.
+2
+  0.438062 -2.68776 -2.23921 	0.1	1. 1. 1.
+2
+  -2.47214 -1.59546 1.71589 	0.1	1. 1. 1.
+2
+  -1.64154 -3.70136 -1.80061 	0.1	1. 1. 1.
+2
+  -2.50954 -2.13946 -1.80561 	0.1	1. 1. 1.
+2
+  1.45166 0.153645 2.50359 	0.1	1. 1. 1.
+2
+  2.04886 -1.35716 1.79219 	0.1	1. 1. 1.
+2
+  1.14346 1.15214 0.320993 	0.1	1. 1. 1.
+2
+  1.75376 -0.319055 -2.99941 	0.1	1. 1. 1.
+2
+  1.01996 1.06104 -2.15101 	0.1	1. 1. 1.
+2
+  -1.71014 0.133845 0.126293 	0.1	1. 1. 1.
+2
+  -2.78704 -0.528955 -1.12651 	0.1	1. 1. 1.
+2
+  -4.76454 -1.89276 0.930293 	0.1	1. 1. 1.
+2
+  -4.18614 -2.49696 -0.640907 	0.1	1. 1. 1.
+2
+  -3.92214 -3.45776 0.834093 	0.1	1. 1. 1.
+2
+  3.60736 1.29684 -2.87381 	0.1	1. 1. 1.
+2
+  -4.75094 -0.0564554 0.311693 	0.1	1. 1. 1.
+2
+  -3.67414 0.606345 1.56439 	0.1	1. 1. 1.
+2
+  3.22946 1.45274 2.47189 	0.1	1. 1. 1.
+2
+  4.33006 2.26874 1.33549 	0.1	1. 1. 1.
+2
+  2.57536 2.54894 1.23139 	0.1	1. 1. 1.
+2
+  4.07696 -0.484155 2.10119 	0.1	1. 1. 1.
+2
+  3.61706 -1.46676 0.692693 	0.1	1. 1. 1.
+2
+  -2.88384 2.33404 -0.0290068 	0.1	1. 1. 1.
+2
+  -3.96064 1.67134 -1.28171 	0.1	1. 1. 1.
+2
+  5.67566 1.42984 -1.78291 	0.1	1. 1. 1.
+2
+  5.10266 2.74254 -0.715907 	0.1	1. 1. 1.
+2
+  6.16236 -0.927955 1.16559 	0.1	1. 1. 1.
+2
+  5.53756 -0.911555 -0.496607 	0.1	1. 1. 1.
+2
+  -4.84774 2.80654 1.40919 	0.1	1. 1. 1.
+2
+  5.68906 1.58194 1.24439 	0.1	1. 1. 1.
+2
+  -5.82304 4.61784 0.0247932 	0.1	1. 1. 1.
+2
+  -4.05744 4.53424 -0.184207 	0.1	1. 1. 1.
+2
+  -5.13424 3.87154 -1.43691 	0.1	1. 1. 1.
+2
+  -6.29174 0.967445 0.583993 	0.1	1. 1. 1.
+2
+  -7.12784 2.53484 0.473393 	0.1	1. 1. 1.
+2
+  -6.43904 1.78854 -0.988307 	0.1	1. 1. 1.
+2
+  7.55546 2.01984 -0.0120068 	0.1	1. 1. 1.
+# All tesselation triangles
+8
+  25. -1.   1. 1. 1.   0.0    0 0 0 2
+  SOLID     1.0 0.0 0.0
+  BACKFACE  0.3 0.3 1.0   0 0
+1
+  7.32406 1.08574 0.0829932 	5.67566 1.42984 -1.78291 	7.55546 2.01984 -0.0120068 	1. 0. 0.
+1
+  7.32406 1.08574 0.0829932 	5.67566 1.42984 -1.78291 	5.53756 -0.911555 -0.496607 	1. 0. 0.
+1
+  7.32406 1.08574 0.0829932 	6.16236 -0.927955 1.16559 	5.53756 -0.911555 -0.496607 	1. 0. 0.
+1
+  3.60736 1.29684 -2.87381 	5.67566 1.42984 -1.78291 	5.53756 -0.911555 -0.496607 	1. 0. 0.
+1
+  1.75376 -0.319055 -2.99941 	3.60736 1.29684 -2.87381 	5.53756 -0.911555 -0.496607 	1. 0. 0.
+1
+  2.17906 -1.47276 -0.873307 	1.75376 -0.319055 -2.99941 	5.53756 -0.911555 -0.496607 	1. 0. 0.
+1
+  2.17906 -1.47276 -0.873307 	0.438062 -2.68776 -2.23921 	1.75376 -0.319055 -2.99941 	1. 0. 0.
+1
+  0.904762 -3.62316 -0.490507 	2.17906 -1.47276 -0.873307 	0.438062 -2.68776 -2.23921 	1. 0. 0.
+1
+  0.904762 -3.62316 -0.490507 	2.17906 -1.47276 -0.873307 	5.53756 -0.911555 -0.496607 	1. 0. 0.
+1
+  0.904762 -3.62316 -0.490507 	1.91486 -2.53606 0.492393 	5.53756 -0.911555 -0.496607 	1. 0. 0.
+1
+  1.91486 -2.53606 0.492393 	3.61706 -1.46676 0.692693 	5.53756 -0.911555 -0.496607 	1. 0. 0.
+1
+  3.61706 -1.46676 0.692693 	6.16236 -0.927955 1.16559 	5.53756 -0.911555 -0.496607 	1. 0. 0.
+1
+  0.777562 -3.65286 1.28459 	0.904762 -3.62316 -0.490507 	1.91486 -2.53606 0.492393 	1. 0. 0.
+1
+  0.777562 -3.65286 1.28459 	1.91486 -2.53606 0.492393 	3.61706 -1.46676 0.692693 	1. 0. 0.
+1
+  0.777562 -3.65286 1.28459 	2.04886 -1.35716 1.79219 	3.61706 -1.46676 0.692693 	1. 0. 0.
+1
+  2.04886 -1.35716 1.79219 	4.07696 -0.484155 2.10119 	3.61706 -1.46676 0.692693 	1. 0. 0.
+1
+  4.07696 -0.484155 2.10119 	3.61706 -1.46676 0.692693 	6.16236 -0.927955 1.16559 	1. 0. 0.
+1
+  0.777562 -3.65286 1.28459 	-0.300138 -1.62946 2.47449 	2.04886 -1.35716 1.79219 	1. 0. 0.
+1
+  -0.300138 -1.62946 2.47449 	1.45166 0.153645 2.50359 	2.04886 -1.35716 1.79219 	1. 0. 0.
+1
+  1.45166 0.153645 2.50359 	2.04886 -1.35716 1.79219 	4.07696 -0.484155 2.10119 	1. 0. 0.
+1
+  1.45166 0.153645 2.50359 	3.22946 1.45274 2.47189 	4.07696 -0.484155 2.10119 	1. 0. 0.
+1
+  3.22946 1.45274 2.47189 	4.07696 -0.484155 2.10119 	5.68906 1.58194 1.24439 	1. 0. 0.
+1
+  4.07696 -0.484155 2.10119 	6.16236 -0.927955 1.16559 	5.68906 1.58194 1.24439 	1. 0. 0.
+1
+  7.32406 1.08574 0.0829932 	6.16236 -0.927955 1.16559 	5.68906 1.58194 1.24439 	1. 0. 0.
+1
+  7.32406 1.08574 0.0829932 	5.68906 1.58194 1.24439 	7.55546 2.01984 -0.0120068 	1. 0. 0.
+1
+  3.22946 1.45274 2.47189 	4.33006 2.26874 1.33549 	5.68906 1.58194 1.24439 	1. 0. 0.
+1
+  3.22946 1.45274 2.47189 	4.33006 2.26874 1.33549 	2.57536 2.54894 1.23139 	1. 0. 0.
+1
+  4.33006 2.26874 1.33549 	2.57536 2.54894 1.23139 	5.10266 2.74254 -0.715907 	1. 0. 0.
+1
+  4.33006 2.26874 1.33549 	5.10266 2.74254 -0.715907 	7.55546 2.01984 -0.0120068 	1. 0. 0.
+1
+  4.33006 2.26874 1.33549 	5.68906 1.58194 1.24439 	7.55546 2.01984 -0.0120068 	1. 0. 0.
+1
+  1.45166 0.153645 2.50359 	3.22946 1.45274 2.47189 	2.57536 2.54894 1.23139 	1. 0. 0.
+1
+  1.45166 0.153645 2.50359 	2.57536 2.54894 1.23139 	-2.88384 2.33404 -0.0290068 	1. 0. 0.
+1
+  -0.771938 -0.223855 1.47919 	1.45166 0.153645 2.50359 	-2.88384 2.33404 -0.0290068 	1. 0. 0.
+1
+  -0.771938 -0.223855 1.47919 	-3.67414 0.606345 1.56439 	-2.88384 2.33404 -0.0290068 	1. 0. 0.
+1
+  -3.67414 0.606345 1.56439 	-2.88384 2.33404 -0.0290068 	-4.84774 2.80654 1.40919 	1. 0. 0.
+1
+  -2.88384 2.33404 -0.0290068 	-4.84774 2.80654 1.40919 	-4.05744 4.53424 -0.184207 	1. 0. 0.
+1
+  2.57536 2.54894 1.23139 	-2.88384 2.33404 -0.0290068 	-4.05744 4.53424 -0.184207 	1. 0. 0.
+1
+  2.57536 2.54894 1.23139 	-2.88384 2.33404 -0.0290068 	-4.05744 4.53424 -0.184207 	1. 0. 0.
+1
+  1.14346 1.15214 0.320993 	2.57536 2.54894 1.23139 	-2.88384 2.33404 -0.0290068 	1. 0. 0.
+1
+  1.14346 1.15214 0.320993 	1.01996 1.06104 -2.15101 	-2.88384 2.33404 -0.0290068 	1. 0. 0.
+1
+  1.14346 1.15214 0.320993 	1.01996 1.06104 -2.15101 	2.57536 2.54894 1.23139 	1. 0. 0.
+1
+  1.01996 1.06104 -2.15101 	2.57536 2.54894 1.23139 	5.10266 2.74254 -0.715907 	1. 0. 0.
+1
+  1.01996 1.06104 -2.15101 	3.60736 1.29684 -2.87381 	5.10266 2.74254 -0.715907 	1. 0. 0.
+1
+  -0.771938 -0.223855 1.47919 	-0.300138 -1.62946 2.47449 	-3.67414 0.606345 1.56439 	1. 0. 0.
+1
+  -0.771938 -0.223855 1.47919 	-0.300138 -1.62946 2.47449 	1.45166 0.153645 2.50359 	1. 0. 0.
+1
+  -0.300138 -1.62946 2.47449 	-2.47214 -1.59546 1.71589 	-3.67414 0.606345 1.56439 	1. 0. 0.
+1
+  -2.47214 -1.59546 1.71589 	-4.76454 -1.89276 0.930293 	-3.67414 0.606345 1.56439 	1. 0. 0.
+1
+  -4.76454 -1.89276 0.930293 	-3.67414 0.606345 1.56439 	-6.29174 0.967445 0.583993 	1. 0. 0.
+1
+  -3.67414 0.606345 1.56439 	-4.84774 2.80654 1.40919 	-6.29174 0.967445 0.583993 	1. 0. 0.
+1
+  -4.84774 2.80654 1.40919 	-6.29174 0.967445 0.583993 	-7.12784 2.53484 0.473393 	1. 0. 0.
+1
+  -2.47214 -1.59546 1.71589 	-4.76454 -1.89276 0.930293 	-3.92214 -3.45776 0.834093 	1. 0. 0.
+1
+  -1.53704 -3.60006 0.497793 	-2.47214 -1.59546 1.71589 	-3.92214 -3.45776 0.834093 	1. 0. 0.
+1
+  -1.53704 -3.60006 0.497793 	-0.300138 -1.62946 2.47449 	-2.47214 -1.59546 1.71589 	1. 0. 0.
+1
+  0.777562 -3.65286 1.28459 	-1.53704 -3.60006 0.497793 	-0.300138 -1.62946 2.47449 	1. 0. 0.
+1
+  -4.84774 2.80654 1.40919 	-5.82304 4.61784 0.0247932 	-4.05744 4.53424 -0.184207 	1. 0. 0.
+1
+  -4.84774 2.80654 1.40919 	-5.82304 4.61784 0.0247932 	-7.12784 2.53484 0.473393 	1. 0. 0.
+1
+  1.01996 1.06104 -2.15101 	-2.88384 2.33404 -0.0290068 	-3.96064 1.67134 -1.28171 	1. 0. 0.
+1
+  -2.88384 2.33404 -0.0290068 	-3.96064 1.67134 -1.28171 	-4.05744 4.53424 -0.184207 	1. 0. 0.
+1
+  -3.96064 1.67134 -1.28171 	-4.05744 4.53424 -0.184207 	-5.13424 3.87154 -1.43691 	1. 0. 0.
+1
+  -0.586638 -1.38326 -2.92321 	1.01996 1.06104 -2.15101 	-3.96064 1.67134 -1.28171 	1. 0. 0.
+1
+  -0.586638 -1.38326 -2.92321 	1.75376 -0.319055 -2.99941 	1.01996 1.06104 -2.15101 	1. 0. 0.
+1
+  1.75376 -0.319055 -2.99941 	1.01996 1.06104 -2.15101 	3.60736 1.29684 -2.87381 	1. 0. 0.
+1
+  -0.586638 -1.38326 -2.92321 	-2.78704 -0.528955 -1.12651 	-3.96064 1.67134 -1.28171 	1. 0. 0.
+1
+  -0.586638 -1.38326 -2.92321 	-2.50954 -2.13946 -1.80561 	-2.78704 -0.528955 -1.12651 	1. 0. 0.
+1
+  -2.50954 -2.13946 -1.80561 	-2.78704 -0.528955 -1.12651 	-3.96064 1.67134 -1.28171 	1. 0. 0.
+1
+  -2.50954 -2.13946 -1.80561 	-4.18614 -2.49696 -0.640907 	-3.96064 1.67134 -1.28171 	1. 0. 0.
+1
+  -4.18614 -2.49696 -0.640907 	-3.96064 1.67134 -1.28171 	-6.43904 1.78854 -0.988307 	1. 0. 0.
+1
+  -3.96064 1.67134 -1.28171 	-5.13424 3.87154 -1.43691 	-6.43904 1.78854 -0.988307 	1. 0. 0.
+1
+  -0.586638 -1.38326 -2.92321 	-1.64154 -3.70136 -1.80061 	-2.50954 -2.13946 -1.80561 	1. 0. 0.
+1
+  -0.586638 -1.38326 -2.92321 	0.438062 -2.68776 -2.23921 	-1.64154 -3.70136 -1.80061 	1. 0. 0.
+1
+  -0.586638 -1.38326 -2.92321 	0.438062 -2.68776 -2.23921 	1.75376 -0.319055 -2.99941 	1. 0. 0.
+1
+  -1.64154 -3.70136 -1.80061 	-2.50954 -2.13946 -1.80561 	-4.18614 -2.49696 -0.640907 	1. 0. 0.
+1
+  -1.64154 -3.70136 -1.80061 	-4.18614 -2.49696 -0.640907 	-3.92214 -3.45776 0.834093 	1. 0. 0.
+1
+  -1.53704 -3.60006 0.497793 	-1.64154 -3.70136 -1.80061 	-3.92214 -3.45776 0.834093 	1. 0. 0.
+1
+  0.904762 -3.62316 -0.490507 	-1.53704 -3.60006 0.497793 	-1.64154 -3.70136 -1.80061 	1. 0. 0.
+1
+  0.777562 -3.65286 1.28459 	0.904762 -3.62316 -0.490507 	-1.53704 -3.60006 0.497793 	1. 0. 0.
+1
+  0.904762 -3.62316 -0.490507 	0.438062 -2.68776 -2.23921 	-1.64154 -3.70136 -1.80061 	1. 0. 0.
+1
+  -4.76454 -1.89276 0.930293 	-4.18614 -2.49696 -0.640907 	-3.92214 -3.45776 0.834093 	1. 0. 0.
+1
+  -4.76454 -1.89276 0.930293 	-4.18614 -2.49696 -0.640907 	-6.29174 0.967445 0.583993 	1. 0. 0.
+1
+  -4.18614 -2.49696 -0.640907 	-6.29174 0.967445 0.583993 	-6.43904 1.78854 -0.988307 	1. 0. 0.
+1
+  -6.29174 0.967445 0.583993 	-7.12784 2.53484 0.473393 	-6.43904 1.78854 -0.988307 	1. 0. 0.
+1
+  3.60736 1.29684 -2.87381 	5.67566 1.42984 -1.78291 	5.10266 2.74254 -0.715907 	1. 0. 0.
+1
+  5.67566 1.42984 -1.78291 	5.10266 2.74254 -0.715907 	7.55546 2.01984 -0.0120068 	1. 0. 0.
+1
+  -5.13424 3.87154 -1.43691 	-7.12784 2.53484 0.473393 	-6.43904 1.78854 -0.988307 	1. 0. 0.
+1
+  -5.82304 4.61784 0.0247932 	-5.13424 3.87154 -1.43691 	-7.12784 2.53484 0.473393 	1. 0. 0.
+1
+  -5.82304 4.61784 0.0247932 	-4.05744 4.53424 -0.184207 	-5.13424 3.87154 -1.43691 	1. 0. 0.
+9
+#  terminating special property
+# current virtual sphere
+8
+  25.0    0.6     -1.0 -1.0 -1.0     0.2        0 0 0 0
+2
+  -5.0049 4.34121 -0.532107	5	1 0 0
+9
+  terminating special property
Index: tests/regression/Tesselation/3/post/tecplot.phy
===================================================================
--- tests/regression/Tesselation/3/post/tecplot.phy	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Tesselation/3/post/tecplot.phy	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,7 @@
+#!PHY 700
+800 600 3.8929440389294406e+01 3.8585209003215432e+01 401
+
+
+
+
+
Index: tests/regression/Tesselation/3/post/test.conf
===================================================================
--- tests/regression/Tesselation/3/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Tesselation/3/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,147 @@
+# 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	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	46	1	1.0	3	3	1.00800000000	Hydrogen	H
+Ion_Type2	27	6	1.0	3	3	12.01100000000	Carbon	C
+Ion_Type3	1	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	0.523300000	-2.991800000	0.452900000	0 # molecule nr 0
+Ion_Type2_2	-0.569100000	-1.922300000	0.392500000	0 # molecule nr 1
+Ion_Type2_3	-0.350400000	-1.008900000	-0.842500000	0 # molecule nr 2
+Ion_Type2_4	-1.920700000	-2.572100000	0.110800000	0 # molecule nr 3
+Ion_Type2_5	-0.488100000	-1.028600000	1.616200000	0 # molecule nr 4
+Ion_Type2_6	1.105500000	-0.578300000	-0.835400000	0 # molecule nr 5
+Ion_Type2_7	-0.762400000	-1.935100000	-1.991700000	0 # molecule nr 6
+Ion_Type2_8	-3.050700000	-1.716000000	0.686300000	0 # molecule nr 7
+Ion_Type2_9	-2.030000000	-2.637800000	-1.432900000	0 # molecule nr 8
+Ion_Type2_10	0.949900000	-0.494400000	1.688800000	0 # molecule nr 9
+Ion_Type2_11	1.330100000	0.271600000	0.428100000	0 # molecule nr 10
+Ion_Type2_12	1.369700000	0.312600000	-2.056100000	0 # molecule nr 11
+Ion_Type2_13	-3.069600000	-0.357100000	-0.016400000	0 # molecule nr 12
+Ion_Type2_14	-4.389400000	-2.423100000	0.465400000	0 # molecule nr 13
+Ion_Type2_15	2.800900000	0.660000000	0.517200000	0 # molecule nr 14
+Ion_Type2_16	2.718800000	0.956000000	-1.935600000	0 # molecule nr 15
+Ion_Type2_17	-4.224300000	0.484200000	0.531100000	0 # molecule nr 16
+Ion_Type2_18	2.931000000	1.835800000	1.487600000	0 # molecule nr 17
+Ion_Type2_19	3.353500000	1.083700000	-0.816700000	0 # molecule nr 18
+Ion_Type2_20	3.641700000	-0.497700000	1.050400000	0 # molecule nr 19
+Ion_Type2_21	-4.243200000	1.843100000	-0.171600000	0 # molecule nr 20
+Ion_Type2_22	4.748600000	1.687300000	-0.810100000	0 # molecule nr 21
+Ion_Type2_23	5.069400000	-0.398000000	0.514800000	0 # molecule nr 22
+Ion_Type2_24	-5.397900000	2.684400000	0.375900000	0 # molecule nr 23
+Ion_Type2_25	5.501600000	1.056600000	0.370100000	0 # molecule nr 24
+Ion_Type2_26	-5.416800000	4.043400000	-0.326800000	0 # molecule nr 25
+Ion_Type2_27	-6.721600000	1.960400000	0.121800000	0 # molecule nr 26
+Ion_Type3_1	6.907700000	1.110600000	0.121400000	0 # molecule nr 27
+Ion_Type1_1	0.361200000	-3.628000000	1.323000000	0 # molecule nr 28
+Ion_Type1_2	0.488400000	-3.598300000	-0.452100000	0 # molecule nr 29
+Ion_Type1_3	1.498500000	-2.511200000	0.530800000	0 # molecule nr 30
+Ion_Type1_4	-1.003500000	-0.137600000	-0.792000000	0 # molecule nr 31
+Ion_Type1_5	-1.953400000	-3.575200000	0.536200000	0 # molecule nr 32
+Ion_Type1_6	-1.188300000	-0.199000000	1.517600000	0 # molecule nr 33
+Ion_Type1_7	-0.716500000	-1.604600000	2.512900000	0 # molecule nr 34
+Ion_Type1_8	1.762700000	-1.447900000	-0.834900000	0 # molecule nr 35
+Ion_Type1_9	-1.003000000	-1.358400000	-2.884800000	0 # molecule nr 36
+Ion_Type1_10	0.021700000	-2.662900000	-2.200800000	0 # molecule nr 37
+Ion_Type1_11	-2.888500000	-1.570600000	1.754300000	0 # molecule nr 38
+Ion_Type1_12	-2.057900000	-3.676500000	-1.762200000	0 # molecule nr 39
+Ion_Type1_13	-2.925900000	-2.114600000	-1.767200000	0 # molecule nr 40
+Ion_Type1_14	1.035300000	0.178500000	2.542000000	0 # molecule nr 41
+Ion_Type1_15	1.632500000	-1.332300000	1.830600000	0 # molecule nr 42
+Ion_Type1_16	0.727100000	1.177000000	0.359400000	0 # molecule nr 43
+Ion_Type1_17	1.337400000	-0.294200000	-2.961000000	0 # molecule nr 44
+Ion_Type1_18	0.603600000	1.085900000	-2.112600000	0 # molecule nr 45
+Ion_Type1_19	-2.126500000	0.158700000	0.164700000	0 # molecule nr 46
+Ion_Type1_20	-3.203400000	-0.504100000	-1.088100000	0 # molecule nr 47
+Ion_Type1_21	-5.180900000	-1.867900000	0.968700000	0 # molecule nr 48
+Ion_Type1_22	-4.602500000	-2.472100000	-0.602500000	0 # molecule nr 49
+Ion_Type1_23	-4.338500000	-3.432900000	0.872500000	0 # molecule nr 50
+Ion_Type1_24	3.191000000	1.321700000	-2.835400000	0 # molecule nr 51
+Ion_Type1_25	-5.167300000	-0.031600000	0.350100000	0 # molecule nr 52
+Ion_Type1_26	-4.090500000	0.631200000	1.602800000	0 # molecule nr 53
+Ion_Type1_27	2.813100000	1.477600000	2.510300000	0 # molecule nr 54
+Ion_Type1_28	3.913700000	2.293600000	1.373900000	0 # molecule nr 55
+Ion_Type1_29	2.159000000	2.573800000	1.269800000	0 # molecule nr 56
+Ion_Type1_30	3.660600000	-0.459300000	2.139600000	0 # molecule nr 57
+Ion_Type1_31	3.200700000	-1.441900000	0.731100000	0 # molecule nr 58
+Ion_Type1_32	-3.300200000	2.358900000	0.009400000	0 # molecule nr 59
+Ion_Type1_33	-4.377000000	1.696200000	-1.243300000	0 # molecule nr 60
+Ion_Type1_34	5.259300000	1.454700000	-1.744500000	0 # molecule nr 61
+Ion_Type1_35	4.686300000	2.767400000	-0.677500000	0 # molecule nr 62
+Ion_Type1_36	5.746000000	-0.903100000	1.204000000	0 # molecule nr 63
+Ion_Type1_37	5.121200000	-0.886700000	-0.458200000	0 # molecule nr 64
+Ion_Type1_38	-5.264100000	2.831400000	1.447600000	0 # molecule nr 65
+Ion_Type1_39	5.272700000	1.606800000	1.282800000	0 # molecule nr 66
+Ion_Type1_40	-6.239400000	4.642700000	0.063200000	0 # molecule nr 67
+Ion_Type1_41	-4.473800000	4.559100000	-0.145800000	0 # molecule nr 68
+Ion_Type1_42	-5.550600000	3.896400000	-1.398500000	0 # molecule nr 69
+Ion_Type1_43	-6.708100000	0.992300000	0.622400000	0 # molecule nr 70
+Ion_Type1_44	-7.544200000	2.559700000	0.511800000	0 # molecule nr 71
+Ion_Type1_45	-6.855400000	1.813400000	-0.949900000	0 # molecule nr 72
+Ion_Type1_46	7.139100000	2.044700000	0.026400000	0 # molecule nr 73
Index: tests/regression/Tesselation/3/pre/test.conf
===================================================================
--- tests/regression/Tesselation/3/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Tesselation/3/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,147 @@
+# 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	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	46	1	1.0	3	3	1.00800000000	Hydrogen	H
+Ion_Type2	27	6	1.0	3	3	12.01100000000	Carbon	C
+Ion_Type3	1	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	0.523300000	-2.991800000	0.452900000	0 # molecule nr 0
+Ion_Type2_2	-0.569100000	-1.922300000	0.392500000	0 # molecule nr 1
+Ion_Type2_3	-0.350400000	-1.008900000	-0.842500000	0 # molecule nr 2
+Ion_Type2_4	-1.920700000	-2.572100000	0.110800000	0 # molecule nr 3
+Ion_Type2_5	-0.488100000	-1.028600000	1.616200000	0 # molecule nr 4
+Ion_Type2_6	1.105500000	-0.578300000	-0.835400000	0 # molecule nr 5
+Ion_Type2_7	-0.762400000	-1.935100000	-1.991700000	0 # molecule nr 6
+Ion_Type2_8	-3.050700000	-1.716000000	0.686300000	0 # molecule nr 7
+Ion_Type2_9	-2.030000000	-2.637800000	-1.432900000	0 # molecule nr 8
+Ion_Type2_10	0.949900000	-0.494400000	1.688800000	0 # molecule nr 9
+Ion_Type2_11	1.330100000	0.271600000	0.428100000	0 # molecule nr 10
+Ion_Type2_12	1.369700000	0.312600000	-2.056100000	0 # molecule nr 11
+Ion_Type2_13	-3.069600000	-0.357100000	-0.016400000	0 # molecule nr 12
+Ion_Type2_14	-4.389400000	-2.423100000	0.465400000	0 # molecule nr 13
+Ion_Type2_15	2.800900000	0.660000000	0.517200000	0 # molecule nr 14
+Ion_Type2_16	2.718800000	0.956000000	-1.935600000	0 # molecule nr 15
+Ion_Type2_17	-4.224300000	0.484200000	0.531100000	0 # molecule nr 16
+Ion_Type2_18	2.931000000	1.835800000	1.487600000	0 # molecule nr 17
+Ion_Type2_19	3.353500000	1.083700000	-0.816700000	0 # molecule nr 18
+Ion_Type2_20	3.641700000	-0.497700000	1.050400000	0 # molecule nr 19
+Ion_Type2_21	-4.243200000	1.843100000	-0.171600000	0 # molecule nr 20
+Ion_Type2_22	4.748600000	1.687300000	-0.810100000	0 # molecule nr 21
+Ion_Type2_23	5.069400000	-0.398000000	0.514800000	0 # molecule nr 22
+Ion_Type2_24	-5.397900000	2.684400000	0.375900000	0 # molecule nr 23
+Ion_Type2_25	5.501600000	1.056600000	0.370100000	0 # molecule nr 24
+Ion_Type2_26	-5.416800000	4.043400000	-0.326800000	0 # molecule nr 25
+Ion_Type2_27	-6.721600000	1.960400000	0.121800000	0 # molecule nr 26
+Ion_Type3_1	6.907700000	1.110600000	0.121400000	0 # molecule nr 27
+Ion_Type1_1	0.361200000	-3.628000000	1.323000000	0 # molecule nr 28
+Ion_Type1_2	0.488400000	-3.598300000	-0.452100000	0 # molecule nr 29
+Ion_Type1_3	1.498500000	-2.511200000	0.530800000	0 # molecule nr 30
+Ion_Type1_4	-1.003500000	-0.137600000	-0.792000000	0 # molecule nr 31
+Ion_Type1_5	-1.953400000	-3.575200000	0.536200000	0 # molecule nr 32
+Ion_Type1_6	-1.188300000	-0.199000000	1.517600000	0 # molecule nr 33
+Ion_Type1_7	-0.716500000	-1.604600000	2.512900000	0 # molecule nr 34
+Ion_Type1_8	1.762700000	-1.447900000	-0.834900000	0 # molecule nr 35
+Ion_Type1_9	-1.003000000	-1.358400000	-2.884800000	0 # molecule nr 36
+Ion_Type1_10	0.021700000	-2.662900000	-2.200800000	0 # molecule nr 37
+Ion_Type1_11	-2.888500000	-1.570600000	1.754300000	0 # molecule nr 38
+Ion_Type1_12	-2.057900000	-3.676500000	-1.762200000	0 # molecule nr 39
+Ion_Type1_13	-2.925900000	-2.114600000	-1.767200000	0 # molecule nr 40
+Ion_Type1_14	1.035300000	0.178500000	2.542000000	0 # molecule nr 41
+Ion_Type1_15	1.632500000	-1.332300000	1.830600000	0 # molecule nr 42
+Ion_Type1_16	0.727100000	1.177000000	0.359400000	0 # molecule nr 43
+Ion_Type1_17	1.337400000	-0.294200000	-2.961000000	0 # molecule nr 44
+Ion_Type1_18	0.603600000	1.085900000	-2.112600000	0 # molecule nr 45
+Ion_Type1_19	-2.126500000	0.158700000	0.164700000	0 # molecule nr 46
+Ion_Type1_20	-3.203400000	-0.504100000	-1.088100000	0 # molecule nr 47
+Ion_Type1_21	-5.180900000	-1.867900000	0.968700000	0 # molecule nr 48
+Ion_Type1_22	-4.602500000	-2.472100000	-0.602500000	0 # molecule nr 49
+Ion_Type1_23	-4.338500000	-3.432900000	0.872500000	0 # molecule nr 50
+Ion_Type1_24	3.191000000	1.321700000	-2.835400000	0 # molecule nr 51
+Ion_Type1_25	-5.167300000	-0.031600000	0.350100000	0 # molecule nr 52
+Ion_Type1_26	-4.090500000	0.631200000	1.602800000	0 # molecule nr 53
+Ion_Type1_27	2.813100000	1.477600000	2.510300000	0 # molecule nr 54
+Ion_Type1_28	3.913700000	2.293600000	1.373900000	0 # molecule nr 55
+Ion_Type1_29	2.159000000	2.573800000	1.269800000	0 # molecule nr 56
+Ion_Type1_30	3.660600000	-0.459300000	2.139600000	0 # molecule nr 57
+Ion_Type1_31	3.200700000	-1.441900000	0.731100000	0 # molecule nr 58
+Ion_Type1_32	-3.300200000	2.358900000	0.009400000	0 # molecule nr 59
+Ion_Type1_33	-4.377000000	1.696200000	-1.243300000	0 # molecule nr 60
+Ion_Type1_34	5.259300000	1.454700000	-1.744500000	0 # molecule nr 61
+Ion_Type1_35	4.686300000	2.767400000	-0.677500000	0 # molecule nr 62
+Ion_Type1_36	5.746000000	-0.903100000	1.204000000	0 # molecule nr 63
+Ion_Type1_37	5.121200000	-0.886700000	-0.458200000	0 # molecule nr 64
+Ion_Type1_38	-5.264100000	2.831400000	1.447600000	0 # molecule nr 65
+Ion_Type1_39	5.272700000	1.606800000	1.282800000	0 # molecule nr 66
+Ion_Type1_40	-6.239400000	4.642700000	0.063200000	0 # molecule nr 67
+Ion_Type1_41	-4.473800000	4.559100000	-0.145800000	0 # molecule nr 68
+Ion_Type1_42	-5.550600000	3.896400000	-1.398500000	0 # molecule nr 69
+Ion_Type1_43	-6.708100000	0.992300000	0.622400000	0 # molecule nr 70
+Ion_Type1_44	-7.544200000	2.559700000	0.511800000	0 # molecule nr 71
+Ion_Type1_45	-6.855400000	1.813400000	-0.949900000	0 # molecule nr 72
+Ion_Type1_46	7.139100000	2.044700000	0.026400000	0 # molecule nr 73
Index: tests/regression/Tesselation/4/post/NonConvexEnvelope.dat
===================================================================
--- tests/regression/Tesselation/4/post/NonConvexEnvelope.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Tesselation/4/post/NonConvexEnvelope.dat	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,123 @@
+TITLE = "3D CONVEX SHELL"
+VARIABLES = "X" "Y" "Z" "U"
+ZONE T="0- H39_ H49_ H51", N=41, E=78, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+6.9077 1.1106 0.1214 1
+0.3612 -3.628 1.323 2
+0.4884 -3.5983 -0.4521 3
+1.4985 -2.5112 0.5308 4
+-1.9534 -3.5752 0.5362 2
+-0.7165 -1.6046 2.5129 1
+1.7627 -1.4479 -0.8349 3
+-1.003 -1.3584 -2.8848 1
+0.0217 -2.6629 -2.2008 1
+-2.8885 -1.5706 1.7543 2
+-2.0579 -3.6765 -1.7622 0
+-2.9259 -2.1146 -1.7672 2
+1.0353 0.1785 2.542 3
+1.6325 -1.3323 1.8306 3
+1.3374 -0.2942 -2.961 1
+0.6036 1.0859 -2.1126 4
+-5.1809 -1.8679 0.9687 1
+-4.6025 -2.4721 -0.6025 2
+-4.3385 -3.4329 0.8725 1
+3.191 1.3217 -2.8354 1
+-4.0905 0.6312 1.6028 3
+2.8131 1.4776 2.5103 0
+3.9137 2.2936 1.3739 0
+2.159 2.5738 1.2698 3
+3.6606 -0.4593 2.1396 3
+3.2007 -1.4419 0.7311 3
+-3.3002 2.3589 0.0094 3
+-4.377 1.6962 -1.2433 4
+5.2593 1.4547 -1.7445 0
+4.6863 2.7674 -0.6775 0
+5.746 -0.9031 1.204 0
+5.1212 -0.8867 -0.4582 4
+-5.2641 2.8314 1.4476 1
+5.2727 1.6068 1.2828 2
+-6.2394 4.6427 0.0632 0
+-4.4738 4.5591 -0.1458 1
+-5.5506 3.8964 -1.3985 1
+-6.7081 0.9923 0.6224 2
+-7.5442 2.5597 0.5118 0
+-6.8554 1.8134 -0.9499 2
+7.1391 2.0447 0.0264 0
+
+1 29 41
+1 29 32
+29 30 41
+1 31 32
+20 29 32
+20 29 30
+23 30 41
+1 31 34
+26 31 32
+15 20 32
+16 20 30
+23 24 30
+23 34 41
+1 34 41
+25 31 34
+25 26 31
+4 26 32
+15 16 20
+9 15 32
+16 24 30
+22 23 24
+22 23 34
+22 25 34
+2 25 26
+2 4 26
+3 4 32
+8 15 16
+8 9 15
+7 9 32
+16 24 36
+13 22 24
+13 22 25
+2 14 25
+2 3 4
+3 7 32
+8 16 28
+8 9 11
+3 7 9
+16 36 37
+24 27 36
+13 24 33
+13 14 25
+2 6 14
+2 3 5
+8 12 28
+16 28 37
+8 11 12
+3 9 11
+35 36 37
+24 27 33
+27 33 36
+13 21 33
+6 13 14
+2 5 6
+3 5 11
+12 28 40
+28 37 40
+11 12 18
+33 35 36
+35 37 39
+6 13 21
+21 33 38
+5 6 19
+5 11 19
+12 18 40
+37 39 40
+11 18 19
+33 35 39
+6 10 21
+17 21 38
+33 38 39
+6 10 19
+18 38 40
+38 39 40
+17 18 19
+10 17 21
+17 18 38
+10 17 19
Index: tests/regression/Tesselation/4/post/NonConvexEnvelope.r3d
===================================================================
--- tests/regression/Tesselation/4/post/NonConvexEnvelope.r3d	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Tesselation/4/post/NonConvexEnvelope.r3d	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,321 @@
+# Raster3D object description, created by MoleCuilder
+@header.r3d
+# All atoms as spheres
+2
+  0.952534 -3.05798 0.420171 	0.1	1. 1. 1.
+2
+  -0.139866 -1.98848 0.359771 	0.1	1. 1. 1.
+2
+  0.0788342 -1.07508 -0.875229 	0.1	1. 1. 1.
+2
+  -1.49147 -2.63828 0.0780712 	0.1	1. 1. 1.
+2
+  -0.0588658 -1.09478 1.58347 	0.1	1. 1. 1.
+2
+  1.53473 -0.644479 -0.868129 	0.1	1. 1. 1.
+2
+  -0.333166 -2.00128 -2.02443 	0.1	1. 1. 1.
+2
+  -2.62147 -1.78218 0.653571 	0.1	1. 1. 1.
+2
+  -1.60077 -2.70398 -1.46563 	0.1	1. 1. 1.
+2
+  1.37913 -0.560579 1.65607 	0.1	1. 1. 1.
+2
+  1.75933 0.205421 0.395371 	0.1	1. 1. 1.
+2
+  1.79893 0.246421 -2.08883 	0.1	1. 1. 1.
+2
+  -2.64037 -0.423279 -0.0491288 	0.1	1. 1. 1.
+2
+  -3.96017 -2.48928 0.432671 	0.1	1. 1. 1.
+2
+  3.23013 0.593821 0.484471 	0.1	1. 1. 1.
+2
+  3.14803 0.889821 -1.96833 	0.1	1. 1. 1.
+2
+  -3.79507 0.418021 0.498371 	0.1	1. 1. 1.
+2
+  3.36023 1.76962 1.45487 	0.1	1. 1. 1.
+2
+  3.78273 1.01752 -0.849429 	0.1	1. 1. 1.
+2
+  4.07093 -0.563879 1.01767 	0.1	1. 1. 1.
+2
+  -3.81397 1.77692 -0.204329 	0.1	1. 1. 1.
+2
+  5.17783 1.62112 -0.842829 	0.1	1. 1. 1.
+2
+  5.49863 -0.464179 0.482071 	0.1	1. 1. 1.
+2
+  -4.96867 2.61822 0.343171 	0.1	1. 1. 1.
+2
+  5.93083 0.990421 0.337371 	0.1	1. 1. 1.
+2
+  -4.98757 3.97722 -0.359529 	0.1	1. 1. 1.
+2
+  -6.29237 1.89422 0.0890712 	0.1	1. 1. 1.
+2
+  7.33693 1.04442 0.0886712 	0.1	1. 1. 1.
+2
+  0.790434 -3.69418 1.29027 	0.1	1. 1. 1.
+2
+  0.917634 -3.66448 -0.484829 	0.1	1. 1. 1.
+2
+  1.92773 -2.57738 0.498071 	0.1	1. 1. 1.
+2
+  -0.574266 -0.203779 -0.824729 	0.1	1. 1. 1.
+2
+  -1.52417 -3.64138 0.503471 	0.1	1. 1. 1.
+2
+  -0.759066 -0.265179 1.48487 	0.1	1. 1. 1.
+2
+  -0.287266 -1.67078 2.48017 	0.1	1. 1. 1.
+2
+  2.19193 -1.51408 -0.867629 	0.1	1. 1. 1.
+2
+  -0.573766 -1.42458 -2.91753 	0.1	1. 1. 1.
+2
+  0.450934 -2.72908 -2.23353 	0.1	1. 1. 1.
+2
+  -2.45927 -1.63678 1.72157 	0.1	1. 1. 1.
+2
+  -1.62867 -3.74268 -1.79493 	0.1	1. 1. 1.
+2
+  -2.49667 -2.18078 -1.79993 	0.1	1. 1. 1.
+2
+  1.46453 0.112321 2.50927 	0.1	1. 1. 1.
+2
+  2.06173 -1.39848 1.79787 	0.1	1. 1. 1.
+2
+  1.15633 1.11082 0.326671 	0.1	1. 1. 1.
+2
+  1.76663 -0.360379 -2.99373 	0.1	1. 1. 1.
+2
+  1.03283 1.01972 -2.14533 	0.1	1. 1. 1.
+2
+  -1.69727 0.0925205 0.131971 	0.1	1. 1. 1.
+2
+  -2.77417 -0.570279 -1.12083 	0.1	1. 1. 1.
+2
+  -4.75167 -1.93408 0.935971 	0.1	1. 1. 1.
+2
+  -4.17327 -2.53828 -0.635229 	0.1	1. 1. 1.
+2
+  -3.90927 -3.49908 0.839771 	0.1	1. 1. 1.
+2
+  3.62023 1.25552 -2.86813 	0.1	1. 1. 1.
+2
+  -4.73807 -0.0977795 0.317371 	0.1	1. 1. 1.
+2
+  -3.66127 0.565021 1.57007 	0.1	1. 1. 1.
+2
+  3.24233 1.41142 2.47757 	0.1	1. 1. 1.
+2
+  4.34293 2.22742 1.34117 	0.1	1. 1. 1.
+2
+  2.58823 2.50762 1.23707 	0.1	1. 1. 1.
+2
+  4.08983 -0.525479 2.10687 	0.1	1. 1. 1.
+2
+  3.62993 -1.50808 0.698371 	0.1	1. 1. 1.
+2
+  -2.87097 2.29272 -0.0233288 	0.1	1. 1. 1.
+2
+  -3.94777 1.63002 -1.27603 	0.1	1. 1. 1.
+2
+  5.68853 1.38852 -1.77723 	0.1	1. 1. 1.
+2
+  5.11553 2.70122 -0.710229 	0.1	1. 1. 1.
+2
+  6.17523 -0.969279 1.17127 	0.1	1. 1. 1.
+2
+  5.55043 -0.952879 -0.490929 	0.1	1. 1. 1.
+2
+  -4.83487 2.76522 1.41487 	0.1	1. 1. 1.
+2
+  5.70193 1.54062 1.25007 	0.1	1. 1. 1.
+2
+  -5.81017 4.57652 0.0304712 	0.1	1. 1. 1.
+2
+  -4.04457 4.49292 -0.178529 	0.1	1. 1. 1.
+2
+  -5.12137 3.83022 -1.43123 	0.1	1. 1. 1.
+2
+  -6.27887 0.926121 0.589671 	0.1	1. 1. 1.
+2
+  -7.11497 2.49352 0.479071 	0.1	1. 1. 1.
+2
+  -6.42617 1.74722 -0.982629 	0.1	1. 1. 1.
+2
+  7.56833 1.97852 -0.00632877 	0.1	1. 1. 1.
+# All tesselation triangles
+8
+  25. -1.   1. 1. 1.   0.0    0 0 0 2
+  SOLID     1.0 0.0 0.0
+  BACKFACE  0.3 0.3 1.0   0 0
+1
+  7.33693 1.04442 0.0886712 	5.68853 1.38852 -1.77723 	7.56833 1.97852 -0.00632877 	1. 0. 0.
+1
+  7.33693 1.04442 0.0886712 	5.68853 1.38852 -1.77723 	5.55043 -0.952879 -0.490929 	1. 0. 0.
+1
+  5.68853 1.38852 -1.77723 	5.11553 2.70122 -0.710229 	7.56833 1.97852 -0.00632877 	1. 0. 0.
+1
+  7.33693 1.04442 0.0886712 	6.17523 -0.969279 1.17127 	5.55043 -0.952879 -0.490929 	1. 0. 0.
+1
+  3.62023 1.25552 -2.86813 	5.68853 1.38852 -1.77723 	5.55043 -0.952879 -0.490929 	1. 0. 0.
+1
+  3.62023 1.25552 -2.86813 	5.68853 1.38852 -1.77723 	5.11553 2.70122 -0.710229 	1. 0. 0.
+1
+  4.34293 2.22742 1.34117 	5.11553 2.70122 -0.710229 	7.56833 1.97852 -0.00632877 	1. 0. 0.
+1
+  7.33693 1.04442 0.0886712 	6.17523 -0.969279 1.17127 	5.70193 1.54062 1.25007 	1. 0. 0.
+1
+  3.62993 -1.50808 0.698371 	6.17523 -0.969279 1.17127 	5.55043 -0.952879 -0.490929 	1. 0. 0.
+1
+  1.76663 -0.360379 -2.99373 	3.62023 1.25552 -2.86813 	5.55043 -0.952879 -0.490929 	1. 0. 0.
+1
+  1.03283 1.01972 -2.14533 	3.62023 1.25552 -2.86813 	5.11553 2.70122 -0.710229 	1. 0. 0.
+1
+  4.34293 2.22742 1.34117 	2.58823 2.50762 1.23707 	5.11553 2.70122 -0.710229 	1. 0. 0.
+1
+  4.34293 2.22742 1.34117 	5.70193 1.54062 1.25007 	7.56833 1.97852 -0.00632877 	1. 0. 0.
+1
+  7.33693 1.04442 0.0886712 	5.70193 1.54062 1.25007 	7.56833 1.97852 -0.00632877 	1. 0. 0.
+1
+  4.08983 -0.525479 2.10687 	6.17523 -0.969279 1.17127 	5.70193 1.54062 1.25007 	1. 0. 0.
+1
+  4.08983 -0.525479 2.10687 	3.62993 -1.50808 0.698371 	6.17523 -0.969279 1.17127 	1. 0. 0.
+1
+  1.92773 -2.57738 0.498071 	3.62993 -1.50808 0.698371 	5.55043 -0.952879 -0.490929 	1. 0. 0.
+1
+  1.76663 -0.360379 -2.99373 	1.03283 1.01972 -2.14533 	3.62023 1.25552 -2.86813 	1. 0. 0.
+1
+  0.450934 -2.72908 -2.23353 	1.76663 -0.360379 -2.99373 	5.55043 -0.952879 -0.490929 	1. 0. 0.
+1
+  1.03283 1.01972 -2.14533 	2.58823 2.50762 1.23707 	5.11553 2.70122 -0.710229 	1. 0. 0.
+1
+  3.24233 1.41142 2.47757 	4.34293 2.22742 1.34117 	2.58823 2.50762 1.23707 	1. 0. 0.
+1
+  3.24233 1.41142 2.47757 	4.34293 2.22742 1.34117 	5.70193 1.54062 1.25007 	1. 0. 0.
+1
+  3.24233 1.41142 2.47757 	4.08983 -0.525479 2.10687 	5.70193 1.54062 1.25007 	1. 0. 0.
+1
+  0.790434 -3.69418 1.29027 	4.08983 -0.525479 2.10687 	3.62993 -1.50808 0.698371 	1. 0. 0.
+1
+  0.790434 -3.69418 1.29027 	1.92773 -2.57738 0.498071 	3.62993 -1.50808 0.698371 	1. 0. 0.
+1
+  0.917634 -3.66448 -0.484829 	1.92773 -2.57738 0.498071 	5.55043 -0.952879 -0.490929 	1. 0. 0.
+1
+  -0.573766 -1.42458 -2.91753 	1.76663 -0.360379 -2.99373 	1.03283 1.01972 -2.14533 	1. 0. 0.
+1
+  -0.573766 -1.42458 -2.91753 	0.450934 -2.72908 -2.23353 	1.76663 -0.360379 -2.99373 	1. 0. 0.
+1
+  2.19193 -1.51408 -0.867629 	0.450934 -2.72908 -2.23353 	5.55043 -0.952879 -0.490929 	1. 0. 0.
+1
+  1.03283 1.01972 -2.14533 	2.58823 2.50762 1.23707 	-4.04457 4.49292 -0.178529 	1. 0. 0.
+1
+  1.46453 0.112321 2.50927 	3.24233 1.41142 2.47757 	2.58823 2.50762 1.23707 	1. 0. 0.
+1
+  1.46453 0.112321 2.50927 	3.24233 1.41142 2.47757 	4.08983 -0.525479 2.10687 	1. 0. 0.
+1
+  0.790434 -3.69418 1.29027 	2.06173 -1.39848 1.79787 	4.08983 -0.525479 2.10687 	1. 0. 0.
+1
+  0.790434 -3.69418 1.29027 	0.917634 -3.66448 -0.484829 	1.92773 -2.57738 0.498071 	1. 0. 0.
+1
+  0.917634 -3.66448 -0.484829 	2.19193 -1.51408 -0.867629 	5.55043 -0.952879 -0.490929 	1. 0. 0.
+1
+  -0.573766 -1.42458 -2.91753 	1.03283 1.01972 -2.14533 	-3.94777 1.63002 -1.27603 	1. 0. 0.
+1
+  -0.573766 -1.42458 -2.91753 	0.450934 -2.72908 -2.23353 	-1.62867 -3.74268 -1.79493 	1. 0. 0.
+1
+  0.917634 -3.66448 -0.484829 	2.19193 -1.51408 -0.867629 	0.450934 -2.72908 -2.23353 	1. 0. 0.
+1
+  1.03283 1.01972 -2.14533 	-4.04457 4.49292 -0.178529 	-5.12137 3.83022 -1.43123 	1. 0. 0.
+1
+  2.58823 2.50762 1.23707 	-2.87097 2.29272 -0.0233288 	-4.04457 4.49292 -0.178529 	1. 0. 0.
+1
+  1.46453 0.112321 2.50927 	2.58823 2.50762 1.23707 	-4.83487 2.76522 1.41487 	1. 0. 0.
+1
+  1.46453 0.112321 2.50927 	2.06173 -1.39848 1.79787 	4.08983 -0.525479 2.10687 	1. 0. 0.
+1
+  0.790434 -3.69418 1.29027 	-0.287266 -1.67078 2.48017 	2.06173 -1.39848 1.79787 	1. 0. 0.
+1
+  0.790434 -3.69418 1.29027 	0.917634 -3.66448 -0.484829 	-1.52417 -3.64138 0.503471 	1. 0. 0.
+1
+  -0.573766 -1.42458 -2.91753 	-2.49667 -2.18078 -1.79993 	-3.94777 1.63002 -1.27603 	1. 0. 0.
+1
+  1.03283 1.01972 -2.14533 	-3.94777 1.63002 -1.27603 	-5.12137 3.83022 -1.43123 	1. 0. 0.
+1
+  -0.573766 -1.42458 -2.91753 	-1.62867 -3.74268 -1.79493 	-2.49667 -2.18078 -1.79993 	1. 0. 0.
+1
+  0.917634 -3.66448 -0.484829 	0.450934 -2.72908 -2.23353 	-1.62867 -3.74268 -1.79493 	1. 0. 0.
+1
+  -5.81017 4.57652 0.0304712 	-4.04457 4.49292 -0.178529 	-5.12137 3.83022 -1.43123 	1. 0. 0.
+1
+  2.58823 2.50762 1.23707 	-2.87097 2.29272 -0.0233288 	-4.83487 2.76522 1.41487 	1. 0. 0.
+1
+  -2.87097 2.29272 -0.0233288 	-4.83487 2.76522 1.41487 	-4.04457 4.49292 -0.178529 	1. 0. 0.
+1
+  1.46453 0.112321 2.50927 	-3.66127 0.565021 1.57007 	-4.83487 2.76522 1.41487 	1. 0. 0.
+1
+  -0.287266 -1.67078 2.48017 	1.46453 0.112321 2.50927 	2.06173 -1.39848 1.79787 	1. 0. 0.
+1
+  0.790434 -3.69418 1.29027 	-1.52417 -3.64138 0.503471 	-0.287266 -1.67078 2.48017 	1. 0. 0.
+1
+  0.917634 -3.66448 -0.484829 	-1.52417 -3.64138 0.503471 	-1.62867 -3.74268 -1.79493 	1. 0. 0.
+1
+  -2.49667 -2.18078 -1.79993 	-3.94777 1.63002 -1.27603 	-6.42617 1.74722 -0.982629 	1. 0. 0.
+1
+  -3.94777 1.63002 -1.27603 	-5.12137 3.83022 -1.43123 	-6.42617 1.74722 -0.982629 	1. 0. 0.
+1
+  -1.62867 -3.74268 -1.79493 	-2.49667 -2.18078 -1.79993 	-4.17327 -2.53828 -0.635229 	1. 0. 0.
+1
+  -4.83487 2.76522 1.41487 	-5.81017 4.57652 0.0304712 	-4.04457 4.49292 -0.178529 	1. 0. 0.
+1
+  -5.81017 4.57652 0.0304712 	-5.12137 3.83022 -1.43123 	-7.11497 2.49352 0.479071 	1. 0. 0.
+1
+  -0.287266 -1.67078 2.48017 	1.46453 0.112321 2.50927 	-3.66127 0.565021 1.57007 	1. 0. 0.
+1
+  -3.66127 0.565021 1.57007 	-4.83487 2.76522 1.41487 	-6.27887 0.926121 0.589671 	1. 0. 0.
+1
+  -1.52417 -3.64138 0.503471 	-0.287266 -1.67078 2.48017 	-3.90927 -3.49908 0.839771 	1. 0. 0.
+1
+  -1.52417 -3.64138 0.503471 	-1.62867 -3.74268 -1.79493 	-3.90927 -3.49908 0.839771 	1. 0. 0.
+1
+  -2.49667 -2.18078 -1.79993 	-4.17327 -2.53828 -0.635229 	-6.42617 1.74722 -0.982629 	1. 0. 0.
+1
+  -5.12137 3.83022 -1.43123 	-7.11497 2.49352 0.479071 	-6.42617 1.74722 -0.982629 	1. 0. 0.
+1
+  -1.62867 -3.74268 -1.79493 	-4.17327 -2.53828 -0.635229 	-3.90927 -3.49908 0.839771 	1. 0. 0.
+1
+  -4.83487 2.76522 1.41487 	-5.81017 4.57652 0.0304712 	-7.11497 2.49352 0.479071 	1. 0. 0.
+1
+  -0.287266 -1.67078 2.48017 	-2.45927 -1.63678 1.72157 	-3.66127 0.565021 1.57007 	1. 0. 0.
+1
+  -4.75167 -1.93408 0.935971 	-3.66127 0.565021 1.57007 	-6.27887 0.926121 0.589671 	1. 0. 0.
+1
+  -4.83487 2.76522 1.41487 	-6.27887 0.926121 0.589671 	-7.11497 2.49352 0.479071 	1. 0. 0.
+1
+  -0.287266 -1.67078 2.48017 	-2.45927 -1.63678 1.72157 	-3.90927 -3.49908 0.839771 	1. 0. 0.
+1
+  -4.17327 -2.53828 -0.635229 	-6.27887 0.926121 0.589671 	-6.42617 1.74722 -0.982629 	1. 0. 0.
+1
+  -6.27887 0.926121 0.589671 	-7.11497 2.49352 0.479071 	-6.42617 1.74722 -0.982629 	1. 0. 0.
+1
+  -4.75167 -1.93408 0.935971 	-4.17327 -2.53828 -0.635229 	-3.90927 -3.49908 0.839771 	1. 0. 0.
+1
+  -2.45927 -1.63678 1.72157 	-4.75167 -1.93408 0.935971 	-3.66127 0.565021 1.57007 	1. 0. 0.
+1
+  -4.75167 -1.93408 0.935971 	-4.17327 -2.53828 -0.635229 	-6.27887 0.926121 0.589671 	1. 0. 0.
+1
+  -2.45927 -1.63678 1.72157 	-4.75167 -1.93408 0.935971 	-3.90927 -3.49908 0.839771 	1. 0. 0.
+9
+#  terminating special property
+# current virtual sphere
+8
+  25.0    0.6     -1.0 -1.0 -1.0     0.2        0 0 0 0
+2
+  -3.70673 -2.35665 1.16577	5	1 0 0
+9
+  terminating special property
Index: tests/regression/Tesselation/4/post/test.conf
===================================================================
--- tests/regression/Tesselation/4/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Tesselation/4/post/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,147 @@
+# 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	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	46	1	1.0	3	3	1.00800000000	Hydrogen	H
+Ion_Type2	27	6	1.0	3	3	12.01100000000	Carbon	C
+Ion_Type3	1	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	0.523300000	-2.991800000	0.452900000	0 # molecule nr 0
+Ion_Type2_2	-0.569100000	-1.922300000	0.392500000	0 # molecule nr 1
+Ion_Type2_3	-0.350400000	-1.008900000	-0.842500000	0 # molecule nr 2
+Ion_Type2_4	-1.920700000	-2.572100000	0.110800000	0 # molecule nr 3
+Ion_Type2_5	-0.488100000	-1.028600000	1.616200000	0 # molecule nr 4
+Ion_Type2_6	1.105500000	-0.578300000	-0.835400000	0 # molecule nr 5
+Ion_Type2_7	-0.762400000	-1.935100000	-1.991700000	0 # molecule nr 6
+Ion_Type2_8	-3.050700000	-1.716000000	0.686300000	0 # molecule nr 7
+Ion_Type2_9	-2.030000000	-2.637800000	-1.432900000	0 # molecule nr 8
+Ion_Type2_10	0.949900000	-0.494400000	1.688800000	0 # molecule nr 9
+Ion_Type2_11	1.330100000	0.271600000	0.428100000	0 # molecule nr 10
+Ion_Type2_12	1.369700000	0.312600000	-2.056100000	0 # molecule nr 11
+Ion_Type2_13	-3.069600000	-0.357100000	-0.016400000	0 # molecule nr 12
+Ion_Type2_14	-4.389400000	-2.423100000	0.465400000	0 # molecule nr 13
+Ion_Type2_15	2.800900000	0.660000000	0.517200000	0 # molecule nr 14
+Ion_Type2_16	2.718800000	0.956000000	-1.935600000	0 # molecule nr 15
+Ion_Type2_17	-4.224300000	0.484200000	0.531100000	0 # molecule nr 16
+Ion_Type2_18	2.931000000	1.835800000	1.487600000	0 # molecule nr 17
+Ion_Type2_19	3.353500000	1.083700000	-0.816700000	0 # molecule nr 18
+Ion_Type2_20	3.641700000	-0.497700000	1.050400000	0 # molecule nr 19
+Ion_Type2_21	-4.243200000	1.843100000	-0.171600000	0 # molecule nr 20
+Ion_Type2_22	4.748600000	1.687300000	-0.810100000	0 # molecule nr 21
+Ion_Type2_23	5.069400000	-0.398000000	0.514800000	0 # molecule nr 22
+Ion_Type2_24	-5.397900000	2.684400000	0.375900000	0 # molecule nr 23
+Ion_Type2_25	5.501600000	1.056600000	0.370100000	0 # molecule nr 24
+Ion_Type2_26	-5.416800000	4.043400000	-0.326800000	0 # molecule nr 25
+Ion_Type2_27	-6.721600000	1.960400000	0.121800000	0 # molecule nr 26
+Ion_Type3_1	6.907700000	1.110600000	0.121400000	0 # molecule nr 27
+Ion_Type1_1	0.361200000	-3.628000000	1.323000000	0 # molecule nr 28
+Ion_Type1_2	0.488400000	-3.598300000	-0.452100000	0 # molecule nr 29
+Ion_Type1_3	1.498500000	-2.511200000	0.530800000	0 # molecule nr 30
+Ion_Type1_4	-1.003500000	-0.137600000	-0.792000000	0 # molecule nr 31
+Ion_Type1_5	-1.953400000	-3.575200000	0.536200000	0 # molecule nr 32
+Ion_Type1_6	-1.188300000	-0.199000000	1.517600000	0 # molecule nr 33
+Ion_Type1_7	-0.716500000	-1.604600000	2.512900000	0 # molecule nr 34
+Ion_Type1_8	1.762700000	-1.447900000	-0.834900000	0 # molecule nr 35
+Ion_Type1_9	-1.003000000	-1.358400000	-2.884800000	0 # molecule nr 36
+Ion_Type1_10	0.021700000	-2.662900000	-2.200800000	0 # molecule nr 37
+Ion_Type1_11	-2.888500000	-1.570600000	1.754300000	0 # molecule nr 38
+Ion_Type1_12	-2.057900000	-3.676500000	-1.762200000	0 # molecule nr 39
+Ion_Type1_13	-2.925900000	-2.114600000	-1.767200000	0 # molecule nr 40
+Ion_Type1_14	1.035300000	0.178500000	2.542000000	0 # molecule nr 41
+Ion_Type1_15	1.632500000	-1.332300000	1.830600000	0 # molecule nr 42
+Ion_Type1_16	0.727100000	1.177000000	0.359400000	0 # molecule nr 43
+Ion_Type1_17	1.337400000	-0.294200000	-2.961000000	0 # molecule nr 44
+Ion_Type1_18	0.603600000	1.085900000	-2.112600000	0 # molecule nr 45
+Ion_Type1_19	-2.126500000	0.158700000	0.164700000	0 # molecule nr 46
+Ion_Type1_20	-3.203400000	-0.504100000	-1.088100000	0 # molecule nr 47
+Ion_Type1_21	-5.180900000	-1.867900000	0.968700000	0 # molecule nr 48
+Ion_Type1_22	-4.602500000	-2.472100000	-0.602500000	0 # molecule nr 49
+Ion_Type1_23	-4.338500000	-3.432900000	0.872500000	0 # molecule nr 50
+Ion_Type1_24	3.191000000	1.321700000	-2.835400000	0 # molecule nr 51
+Ion_Type1_25	-5.167300000	-0.031600000	0.350100000	0 # molecule nr 52
+Ion_Type1_26	-4.090500000	0.631200000	1.602800000	0 # molecule nr 53
+Ion_Type1_27	2.813100000	1.477600000	2.510300000	0 # molecule nr 54
+Ion_Type1_28	3.913700000	2.293600000	1.373900000	0 # molecule nr 55
+Ion_Type1_29	2.159000000	2.573800000	1.269800000	0 # molecule nr 56
+Ion_Type1_30	3.660600000	-0.459300000	2.139600000	0 # molecule nr 57
+Ion_Type1_31	3.200700000	-1.441900000	0.731100000	0 # molecule nr 58
+Ion_Type1_32	-3.300200000	2.358900000	0.009400000	0 # molecule nr 59
+Ion_Type1_33	-4.377000000	1.696200000	-1.243300000	0 # molecule nr 60
+Ion_Type1_34	5.259300000	1.454700000	-1.744500000	0 # molecule nr 61
+Ion_Type1_35	4.686300000	2.767400000	-0.677500000	0 # molecule nr 62
+Ion_Type1_36	5.746000000	-0.903100000	1.204000000	0 # molecule nr 63
+Ion_Type1_37	5.121200000	-0.886700000	-0.458200000	0 # molecule nr 64
+Ion_Type1_38	-5.264100000	2.831400000	1.447600000	0 # molecule nr 65
+Ion_Type1_39	5.272700000	1.606800000	1.282800000	0 # molecule nr 66
+Ion_Type1_40	-6.239400000	4.642700000	0.063200000	0 # molecule nr 67
+Ion_Type1_41	-4.473800000	4.559100000	-0.145800000	0 # molecule nr 68
+Ion_Type1_42	-5.550600000	3.896400000	-1.398500000	0 # molecule nr 69
+Ion_Type1_43	-6.708100000	0.992300000	0.622400000	0 # molecule nr 70
+Ion_Type1_44	-7.544200000	2.559700000	0.511800000	0 # molecule nr 71
+Ion_Type1_45	-6.855400000	1.813400000	-0.949900000	0 # molecule nr 72
+Ion_Type1_46	7.139100000	2.044700000	0.026400000	0 # molecule nr 73
Index: tests/regression/Tesselation/4/pre/test.conf
===================================================================
--- tests/regression/Tesselation/4/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/Tesselation/4/pre/test.conf	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,147 @@
+# 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	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	46	1	1.0	3	3	1.00800000000	Hydrogen	H
+Ion_Type2	27	6	1.0	3	3	12.01100000000	Carbon	C
+Ion_Type3	1	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	0.523300000	-2.991800000	0.452900000	0 # molecule nr 0
+Ion_Type2_2	-0.569100000	-1.922300000	0.392500000	0 # molecule nr 1
+Ion_Type2_3	-0.350400000	-1.008900000	-0.842500000	0 # molecule nr 2
+Ion_Type2_4	-1.920700000	-2.572100000	0.110800000	0 # molecule nr 3
+Ion_Type2_5	-0.488100000	-1.028600000	1.616200000	0 # molecule nr 4
+Ion_Type2_6	1.105500000	-0.578300000	-0.835400000	0 # molecule nr 5
+Ion_Type2_7	-0.762400000	-1.935100000	-1.991700000	0 # molecule nr 6
+Ion_Type2_8	-3.050700000	-1.716000000	0.686300000	0 # molecule nr 7
+Ion_Type2_9	-2.030000000	-2.637800000	-1.432900000	0 # molecule nr 8
+Ion_Type2_10	0.949900000	-0.494400000	1.688800000	0 # molecule nr 9
+Ion_Type2_11	1.330100000	0.271600000	0.428100000	0 # molecule nr 10
+Ion_Type2_12	1.369700000	0.312600000	-2.056100000	0 # molecule nr 11
+Ion_Type2_13	-3.069600000	-0.357100000	-0.016400000	0 # molecule nr 12
+Ion_Type2_14	-4.389400000	-2.423100000	0.465400000	0 # molecule nr 13
+Ion_Type2_15	2.800900000	0.660000000	0.517200000	0 # molecule nr 14
+Ion_Type2_16	2.718800000	0.956000000	-1.935600000	0 # molecule nr 15
+Ion_Type2_17	-4.224300000	0.484200000	0.531100000	0 # molecule nr 16
+Ion_Type2_18	2.931000000	1.835800000	1.487600000	0 # molecule nr 17
+Ion_Type2_19	3.353500000	1.083700000	-0.816700000	0 # molecule nr 18
+Ion_Type2_20	3.641700000	-0.497700000	1.050400000	0 # molecule nr 19
+Ion_Type2_21	-4.243200000	1.843100000	-0.171600000	0 # molecule nr 20
+Ion_Type2_22	4.748600000	1.687300000	-0.810100000	0 # molecule nr 21
+Ion_Type2_23	5.069400000	-0.398000000	0.514800000	0 # molecule nr 22
+Ion_Type2_24	-5.397900000	2.684400000	0.375900000	0 # molecule nr 23
+Ion_Type2_25	5.501600000	1.056600000	0.370100000	0 # molecule nr 24
+Ion_Type2_26	-5.416800000	4.043400000	-0.326800000	0 # molecule nr 25
+Ion_Type2_27	-6.721600000	1.960400000	0.121800000	0 # molecule nr 26
+Ion_Type3_1	6.907700000	1.110600000	0.121400000	0 # molecule nr 27
+Ion_Type1_1	0.361200000	-3.628000000	1.323000000	0 # molecule nr 28
+Ion_Type1_2	0.488400000	-3.598300000	-0.452100000	0 # molecule nr 29
+Ion_Type1_3	1.498500000	-2.511200000	0.530800000	0 # molecule nr 30
+Ion_Type1_4	-1.003500000	-0.137600000	-0.792000000	0 # molecule nr 31
+Ion_Type1_5	-1.953400000	-3.575200000	0.536200000	0 # molecule nr 32
+Ion_Type1_6	-1.188300000	-0.199000000	1.517600000	0 # molecule nr 33
+Ion_Type1_7	-0.716500000	-1.604600000	2.512900000	0 # molecule nr 34
+Ion_Type1_8	1.762700000	-1.447900000	-0.834900000	0 # molecule nr 35
+Ion_Type1_9	-1.003000000	-1.358400000	-2.884800000	0 # molecule nr 36
+Ion_Type1_10	0.021700000	-2.662900000	-2.200800000	0 # molecule nr 37
+Ion_Type1_11	-2.888500000	-1.570600000	1.754300000	0 # molecule nr 38
+Ion_Type1_12	-2.057900000	-3.676500000	-1.762200000	0 # molecule nr 39
+Ion_Type1_13	-2.925900000	-2.114600000	-1.767200000	0 # molecule nr 40
+Ion_Type1_14	1.035300000	0.178500000	2.542000000	0 # molecule nr 41
+Ion_Type1_15	1.632500000	-1.332300000	1.830600000	0 # molecule nr 42
+Ion_Type1_16	0.727100000	1.177000000	0.359400000	0 # molecule nr 43
+Ion_Type1_17	1.337400000	-0.294200000	-2.961000000	0 # molecule nr 44
+Ion_Type1_18	0.603600000	1.085900000	-2.112600000	0 # molecule nr 45
+Ion_Type1_19	-2.126500000	0.158700000	0.164700000	0 # molecule nr 46
+Ion_Type1_20	-3.203400000	-0.504100000	-1.088100000	0 # molecule nr 47
+Ion_Type1_21	-5.180900000	-1.867900000	0.968700000	0 # molecule nr 48
+Ion_Type1_22	-4.602500000	-2.472100000	-0.602500000	0 # molecule nr 49
+Ion_Type1_23	-4.338500000	-3.432900000	0.872500000	0 # molecule nr 50
+Ion_Type1_24	3.191000000	1.321700000	-2.835400000	0 # molecule nr 51
+Ion_Type1_25	-5.167300000	-0.031600000	0.350100000	0 # molecule nr 52
+Ion_Type1_26	-4.090500000	0.631200000	1.602800000	0 # molecule nr 53
+Ion_Type1_27	2.813100000	1.477600000	2.510300000	0 # molecule nr 54
+Ion_Type1_28	3.913700000	2.293600000	1.373900000	0 # molecule nr 55
+Ion_Type1_29	2.159000000	2.573800000	1.269800000	0 # molecule nr 56
+Ion_Type1_30	3.660600000	-0.459300000	2.139600000	0 # molecule nr 57
+Ion_Type1_31	3.200700000	-1.441900000	0.731100000	0 # molecule nr 58
+Ion_Type1_32	-3.300200000	2.358900000	0.009400000	0 # molecule nr 59
+Ion_Type1_33	-4.377000000	1.696200000	-1.243300000	0 # molecule nr 60
+Ion_Type1_34	5.259300000	1.454700000	-1.744500000	0 # molecule nr 61
+Ion_Type1_35	4.686300000	2.767400000	-0.677500000	0 # molecule nr 62
+Ion_Type1_36	5.746000000	-0.903100000	1.204000000	0 # molecule nr 63
+Ion_Type1_37	5.121200000	-0.886700000	-0.458200000	0 # molecule nr 64
+Ion_Type1_38	-5.264100000	2.831400000	1.447600000	0 # molecule nr 65
+Ion_Type1_39	5.272700000	1.606800000	1.282800000	0 # molecule nr 66
+Ion_Type1_40	-6.239400000	4.642700000	0.063200000	0 # molecule nr 67
+Ion_Type1_41	-4.473800000	4.559100000	-0.145800000	0 # molecule nr 68
+Ion_Type1_42	-5.550600000	3.896400000	-1.398500000	0 # molecule nr 69
+Ion_Type1_43	-6.708100000	0.992300000	0.622400000	0 # molecule nr 70
+Ion_Type1_44	-7.544200000	2.559700000	0.511800000	0 # molecule nr 71
+Ion_Type1_45	-6.855400000	1.813400000	-0.949900000	0 # molecule nr 72
+Ion_Type1_46	7.139100000	2.044700000	0.026400000	0 # molecule nr 73
Index: tests/regression/atlocal.in
===================================================================
--- tests/regression/atlocal.in	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/atlocal.in	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,4 @@
+prefix='@prefix@'
+exec_prefix='@prefix@'
+topdir='@topdir@'
+bindir='@bindir@'
Index: tests/regression/molecuilder.in
===================================================================
--- tests/regression/molecuilder.in	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/molecuilder.in	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,11 @@
+#!/bin/sh
+#
+# wrapper for testing molecuilder
+
+. ../../atconfig
+
+"${abs_top_builddir}/src/molecuilder" \
+	${1+"$@"}
+status=$?
+
+exit $status
Index: tests/regression/testsuite-analysis.at
===================================================================
--- tests/regression/testsuite-analysis.at	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/testsuite-analysis.at	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,55 @@
+AT_BANNER([MoleCuilder - Analysis])
+# 1. pair correlation analysis
+AT_SETUP([Analysis - pair correlation])
+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([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])
+AT_CHECK([file=bin_output.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/1/post/$file], 0, [ignore], [ignore])
+AT_CLEANUP
+
+# 2. pair correlation analysis - range test
+AT_SETUP([Analysis - pair correlation range test])
+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([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([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([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])
+AT_CLEANUP
+
+# 3. pair correlation analysis to point
+AT_SETUP([Analysis - point correlation])
+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([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])
+AT_CHECK([file=bin_output.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/3/post/$file], 0, [ignore], [ignore])
+AT_CLEANUP
+
+# 4. pair correlation analysis to surface
+AT_SETUP([Analysis - surface correlation])
+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([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])
+AT_CHECK([file=bin_output.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/4/post/$file], 0, [ignore], [ignore])
+AT_CLEANUP
+
+# 5. principal axis system
+#AT_SETUP([Analysis - principal axis system])
+#AT_KEYWORDS([analysis])
+#AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/5/pre/test.conf .], 0)
+#AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -m 0], 0, [stdout], [stderr])
+#AT_CHECK([fgrep "eigenvalue = 4382.53," stdout], 0, [ignore], [ignore])
+#AT_CHECK([fgrep "eigenvalue = 4369.24," stdout], 0, [ignore], [ignore])
+#AT_CHECK([fgrep "eigenvalue = 28.9359," stdout], 0, [ignore], [ignore])
+#AT_CLEANUP
Index: tests/regression/testsuite-domain.at
===================================================================
--- tests/regression/testsuite-domain.at	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/testsuite-domain.at	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,66 @@
+AT_BANNER([MoleCuilder - simulation domain])
+# 1. define box setting
+AT_SETUP([Domain - defining simulation domain])
+AT_KEYWORDS([domain])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -o pcp -B "10, 0, 10, 0, 0, 10"], 0, [stdout], [stderr])
+AT_CHECK([fgrep "BoxLength" test.conf], 0, [stdout], [stderr])
+AT_CHECK([diff test.conf ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/1/post/test.conf], 0, [stdout], [stderr])
+AT_CLEANUP
+
+# 2. center atoms in defined domain
+AT_SETUP([Domain - setting and centering in domain])
+AT_KEYWORDS([domain])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/2/pre/test.conf .], 0)
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -b "15, 0, 15, 0, 0, 15"], 0, [stdout], [stderr])
+AT_CHECK([diff test.conf ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/2/post/test.conf], 0, [stdout], [stderr])
+AT_CLEANUP
+
+# 3. center atoms with defined boundary
+AT_SETUP([Domain - centering with defined boundary])
+AT_KEYWORDS([domain])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/3/pre/test.conf .], 0)
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -c "5, 10, 15"], 0, [stdout], [stderr])
+AT_CHECK([diff test.conf ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/3/post/test.conf], 0, [stdout], [stderr])
+AT_CLEANUP
+
+# 4. center atoms and adjusting boundary
+AT_SETUP([Domain - centering and setting domain])
+AT_KEYWORDS([domain])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/4/pre/test.conf .], 0)
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -O], 0, [stdout], [stderr])
+AT_CHECK([diff test.conf ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/4/post/test.conf], 0, [stdout], [stderr])
+AT_CLEANUP
+
+# 5. scaling box
+AT_SETUP([Domain - scaling box])
+AT_KEYWORDS([domain])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/5/pre/test.conf .], 0)
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -s "0.5, 1., 0.9"], 0, [stdout], [stderr])
+AT_CHECK([diff test.conf ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/5/post/test.conf], 0, [stdout], [stderr])
+AT_CLEANUP
+
+# 6. duplicating box
+AT_SETUP([Domain - duplicating box])
+AT_KEYWORDS([domain])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/pre/test.conf .], 0)
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -o xyz -d "1, 1, 1"], 0, [stdout], [stderr])
+AT_CHECK([file=test.xyz;sort -n $file | grep -v "Created by" >$file-sorted], 0, [ignore], [ignore])
+AT_CHECK([file=test.xyz;sort -n ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/post/$file  | grep -v "Created by" >$file-sorted2], 0, [ignore], [ignore])
+AT_CHECK([file=test.xyz; diff $file-sorted $file-sorted2], 0, [ignore], [ignore])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/pre/test.conf test-x.conf], 0)
+AT_CHECK([../../molecuilder -i test-x.conf -e ${abs_top_srcdir}/src/ -o xyz -d "2, 1, 1"], 0, [stdout], [stderr])
+AT_CHECK([file=test-x.xyz;sort -n $file | grep -v "Created by" >$file-sorted], 0, [ignore], [ignore])
+AT_CHECK([file=test-x.xyz;sort -n ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/post/$file  | grep -v "Created by" >$file-sorted2], 0, [ignore], [ignore])
+AT_CHECK([file=test-x.xyz; diff $file-sorted $file-sorted2], 0, [ignore], [ignore])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/pre/test.conf test-y.conf], 0)
+AT_CHECK([../../molecuilder -i test-y.conf -e ${abs_top_srcdir}/src/ -o xyz -d "1, 2, 1"], 0, [stdout], [stderr])
+AT_CHECK([file=test-y.xyz;sort -n $file | grep -v "Created by" >$file-sorted], 0, [ignore], [ignore])
+AT_CHECK([file=test-y.xyz;sort -n ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/post/$file  | grep -v "Created by" >$file-sorted2], 0, [ignore], [ignore])
+AT_CHECK([file=test-y.xyz; diff $file-sorted $file-sorted2], 0, [ignore], [ignore])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/pre/test.conf test-z.conf], 0)
+AT_CHECK([../../molecuilder -i test-z.conf -e ${abs_top_srcdir}/src/ -o xyz -d "1, 1, 2"], 0, [stdout], [stderr])
+AT_CHECK([file=test-z.xyz;sort -n $file | grep -v "Created by" >$file-sorted], 0, [ignore], [ignore])
+AT_CHECK([file=test-z.xyz;sort -n ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/post/$file  | grep -v "Created by" >$file-sorted2], 0, [ignore], [ignore])
+AT_CHECK([file=test-z.xyz; diff $file-sorted $file-sorted2], 0, [ignore], [ignore])
+#AT_CHECK([/bin/false], 12, [ignore], [ignore])
+AT_CLEANUP
Index: tests/regression/testsuite-filling.at
===================================================================
--- tests/regression/testsuite-filling.at	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/testsuite-filling.at	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,23 @@
+AT_BANNER([MoleCuilder - Filling in molecules])
+# 1. filling box
+AT_SETUP([Filling - filling empty box])
+AT_KEYWORDS([filling])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Filling/1/pre/test.conf .], 0)
+AT_DATA([water.xyz], [[3
+ # test configuration, created by molecuilder test suite
+O       0.      0.      0.
+H       0.758602 0.     0.504284 
+H       0.758602 0.     -0.504284 
+]])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -F water.xyz --MaxDistance -1 --distances "3.1, 3.1, 3.1"  --lengths "2.1, 0., 0." --DoRotate 0], 0, [stdout], [stderr])
+AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Filling/1/post/$file], 0, [ignore], [ignore])
+AT_CLEANUP
+
+# 2. suspend in water with certain density
+AT_SETUP([Filling - BROKEN: suspend in water])
+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([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 ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/testsuite-fragmentation.at	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,25 @@
+AT_BANNER([MoleCuilder - Fragmentation and Re-fragmentation test])
+# 1. check config
+AT_SETUP([Fragmentation - Checking present config])
+AT_KEYWORDS([fragmentation])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Fragmentation/1/pre/test.conf .], 0)
+AT_CHECK([fgrep "Ion_Type1_4" test.conf], 0, [Ion_Type1_4	8.532785963	4.787886018	2.645886050	0 # molecule nr 6
+], [ignore])
+AT_CHECK([fgrep "Ion_Type2_4" test.conf], 1, [ignore], [ignore])
+AT_CLEANUP
+
+# 2. fragment the molecule and check the number of configs
+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([ls -l BondFragment*.conf | wc -l], 0, [5
+], [ignore])
+AT_CLEANUP
+
+# 3. check whether parsing of BondFragment files and re-rwriting config files is working (exit code is 2 as we don't need to continue wrt to ...OrderAtSite)
+# NOTE: Result code of 2 is not returned if "-v 1" is missing, then sequence of atoms is changed all the time and Adjacency files never match.
+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_CLEANUP
Index: tests/regression/testsuite-graph.at
===================================================================
--- tests/regression/testsuite-graph.at	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/testsuite-graph.at	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,17 @@
+AT_BANNER([MoleCuilder - Graph routines test])
+# 1. DFS analysis
+AT_SETUP([Graph - DFS analysis])
+AT_KEYWORDS([graph])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Graph/1/pre/test.conf .], 0)
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -D 2.], 0, [stdout], [stderr])
+AT_CHECK([fgrep -c "No rings were detected in the molecular structure." stdout], 0, [1
+], [ignore])
+AT_CLEANUP
+
+AT_SETUP([Graph - subgraph dissection])
+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_CLEANUP
+
Index: tests/regression/testsuite-molecules.at
===================================================================
--- tests/regression/testsuite-molecules.at	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/testsuite-molecules.at	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,69 @@
+AT_BANNER([MoleCuilder - Molecules])
+# 1. Bonds from file
+AT_SETUP([Molecules - Bonds from file])
+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([fgrep "Looking for atoms 2 and 9." stdout], 0, [ignore], [ignore])
+AT_CLEANUP
+
+# 2. Storing adjacency info
+AT_SETUP([Molecules - Storing bond info])
+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([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([file=test.adj; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/2/post/$file], 0, [ignore], [ignore])
+AT_CLEANUP
+
+# 3. Storing temperature
+AT_SETUP([Molecules - Storing temperature])
+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([file=test.ekin; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/3/post/$file], 0, [ignore], [ignore])
+AT_CLEANUP
+
+# 4. linear interpolation
+AT_SETUP([Molecules - BROKEN: Linear interpolation])
+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_CLEANUP
+
+# 5. Verlet force integration
+AT_SETUP([Molecules - BROKEN: Verlet force integration])
+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([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/5/post/$file], 0, [ignore], [ignore])
+AT_CLEANUP
+
+# 6. Translation
+AT_SETUP([Molecules - Translation])
+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([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([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])
+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_CLEANUP
+
+# 8. Rotate to PAS
+AT_SETUP([Molecules - BROKEN: Rotate to PAS])
+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_CLEANUP
+
Index: tests/regression/testsuite-simple_configuration.at
===================================================================
--- tests/regression/testsuite-simple_configuration.at	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/testsuite-simple_configuration.at	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,85 @@
+AT_BANNER([MoleCuilder - molecular config creation from xyz file and atom adding])
+# 1. create some simplest molecular geometry
+AT_SETUP([Simple configuration - xyz file generation])
+AT_KEYWORDS([configuration])
+AT_DATA([test.xyz], [[1
+ # test configuration, created by molecuilder test suite
+H	10.	10.	10.
+]])
+AT_CHECK([file=test.xyz; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/1/post/$file], 0, [ignore], [ignore])
+AT_CLEANUP
+
+# 2. parsing an xyz
+AT_SETUP([Simple configuration - parsing xyz file])
+AT_KEYWORDS([configuration])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/2/pre/test.xyz .], 0)
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -o mpqc pcp xyz -p test.xyz], 0, [ignore], [ignore])
+AT_CHECK([fgrep "Ion_Type1_1" test.conf], 0, [Ion_Type1_1	10.000000000	10.000000000	10.000000000	0 # molecule nr 0
+], [ignore])
+AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/2/post/$file], 0, [ignore], [ignore])
+AT_CHECK([file=test.in; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/2/post/$file], 0, [ignore], [ignore])
+AT_CHECK([file=test.xyz; diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/2/post/$file], 0, [ignore], [ignore])
+AT_CLEANUP
+
+# 3a. add atom
+AT_SETUP([Simple configuration - adding atom])
+AT_KEYWORDS([configuration])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -o mpqc pcp xyz -a 1 --position "10., 10., 10."], 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_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_CLEANUP
+
+# 4. change the element
+AT_SETUP([Simple configuration - Changing element])
+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([file=test.xyz; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/4/post/$file], 0, [ignore], [ignore])
+AT_CLEANUP
+
+# 5. remove atom
+AT_SETUP([Simple configuration - Atom removal])
+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([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
+
+# 6. test some more configuration that all desire parameters and count how many complain
+AT_SETUP([Simple configuration - invalid commands on empty configs])
+AT_KEYWORDS([configuration])
+AT_CHECK([../../molecuilder -i empty.conf -e ${abs_top_srcdir}/src/ -t -s -b -E -c -b -a -U -T -u], 134, [ignore], [stderr])
+AT_CLEANUP
+
+# 7. test some more configuration that all need parameters and count how many complain
+AT_SETUP([Simple configuration - invalid commands on present configs])
+AT_KEYWORDS([configuration])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/7/pre/test.conf .], 0)
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -t], 134, [ignore], [stderr])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -s -b -E -c -b -a -U -T -u], 134, [ignore], [stderr])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -b -E -c -b -a -U -T -u], 134, [ignore], [stderr])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -E -c -b -a -U -T -u], 134, [ignore], [stderr])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -c -b -a -U -T -u], 134, [ignore], [stderr])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -b -a -U -T -u], 134, [ignore], [stderr])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -a -U -T -u], 134, [ignore], [stderr])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -U -T -u], 134, [ignore], [stderr])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -T -u], 134, [ignore], [stderr])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -u], 134, [ignore], [stderr])
+AT_CLEANUP
+
+# 8. Removing sphere 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([file=test.xyz-sorted; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/post/$file], 0, [ignore], [ignore])
+AT_CLEANUP
Index: tests/regression/testsuite-specifics.at
===================================================================
--- tests/regression/testsuite-specifics.at	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/testsuite-specifics.at	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,8 @@
+AT_BANNER([MoleCuilder - Specifics])
+# 1. MPQC basis
+AT_SETUP([Specifics - MPQC basis])
+AT_KEYWORDS([options])
+AT_CHECK([pwd],[ignore],[ignore])
+AT_CHECK([../../molecuilder -i test.conf -v 1 -M test], 0, [stdout], [ignore])
+AT_CHECK([fgrep "Setting MPQC basis to test." stdout], 0, [ignore], [ignore])
+AT_CLEANUP
Index: tests/regression/testsuite-standard_options.at
===================================================================
--- tests/regression/testsuite-standard_options.at	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/testsuite-standard_options.at	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,61 @@
+AT_BANNER([MoleCuilder - standard options])
+# 1. verbosity
+AT_SETUP([Standard Options - verbosity])
+AT_KEYWORDS([options])
+AT_CHECK([pwd],[ignore],[ignore])
+AT_CHECK([../../molecuilder -v 1], 0, [stdout], [ignore])
+AT_CHECK([fgrep olecuilder stdout], 0, [ignore], [ignore])
+AT_CLEANUP
+
+# 2. help screen
+AT_SETUP([Standard Options - help screen])
+AT_KEYWORDS([options])
+AT_CHECK([../../molecuilder -h], 0, [stdout], [ignore])
+AT_CHECK([fgrep "Give this help screen" stdout], 0, [ignore], [ignore])
+AT_CLEANUP
+
+# 3. no element database
+AT_SETUP([Standard Options - no element database])
+AT_KEYWORDS([options])
+AT_CHECK([../../molecuilder -e], 134, [ignore], [stderr])
+AT_CLEANUP
+
+# 4. element database
+AT_SETUP([Standard Options - element database])
+AT_KEYWORDS([options])
+AT_DATA([elements.db], [[#	Covalent	radius	of	each	element	in	Angstroem	from	CSD	(binding	is:	[Rcov(A)+Rcov(B)-t,Rcov(A)+Rcov(B)+t]	with	t	=	0.4A
+#Element	Name	Symbol	Period	Group	Block	Atomic	Number	AtomicWeight	Covalent	Radius	vdW	Radius
+Hydrogen	H	1	1	s	1	1.008	0.23	1.09
+Helium	He	1	18	p	2	4.003	1.5	1.4
+]])
+AT_CHECK([../../molecuilder -i test.conf -e ./], 0, [stdout], [stderr])
+AT_CHECK([grep -E "Using.*as elements database." stdout], 0, [ignore], [ignore])
+AT_CHECK([fgrep "Element list loaded successfully." stdout], 0, [ignore], [ignore])
+AT_CHECK([fgrep "Something went wrong while parsing the other databases!" stderr], 0, [ignore], [ignore])
+AT_CLEANUP
+
+# 5. bond length database
+AT_SETUP([Standard Options - bond length table])
+AT_KEYWORDS([options])
+AT_DATA([bondlength.db], [[# bond length database
+	1	2
+1	1.	0.
+2	0.	0.
+]])
+AT_CHECK([../../molecuilder -i test.conf -g bondlength.db], 0, [stdout], [stderr])
+AT_CHECK([grep -E "Using.*as bond length table." stdout], 0, [ignore], [ignore])
+AT_CLEANUP
+
+# 6. fast trajectories
+AT_SETUP([Standard Options - fast trajectories])
+AT_KEYWORDS([options])
+AT_CHECK([../../molecuilder -i test.conf -n 1], 0, [stdout], [stderr])
+AT_CHECK([fgrep "I won't parse trajectories" stdout], 0, [ignore], [ignore])
+AT_CLEANUP
+
+# 7. molecule default name
+AT_SETUP([Standard Options - molecule default name])
+AT_KEYWORDS([options])
+AT_CHECK([../../molecuilder -i test.conf -X test], 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 ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/testsuite-tesselation.at	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,36 @@
+AT_BANNER([MoleCuilder - Tesselation test])
+# 1. Non convex tesselation
+AT_SETUP([Tesselation - Non-Convex Envelope])
+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([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])
+AT_CLEANUP
+
+# 2. convex tesselation (where the non-convex is already convex)
+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([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])
+AT_CHECK([fgrep "tesselated volume area is 16.4016 angstrom^3" stdout], 0, [ignore], [ignore])
+AT_CHECK([diff ConvexEnvelope.dat NonConvexEnvelope.dat], 0, [ignore], [ignore])
+AT_CLEANUP
+
+# 3. Big Non convex tesselation
+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([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])
+AT_CLEANUP
+
+# 4. Big convex tesselation - is not working yet 
+#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([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])
+#AT_CHECK([fgrep "tesselated volume area is 16.4016 angstrom^3" stdout], 0, [ignore], [ignore])
+#AT_CLEANUP
Index: tests/regression/testsuite.at
===================================================================
--- tests/regression/testsuite.at	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
+++ tests/regression/testsuite.at	(revision ba9f5bcda4dd421dcb79d4ccff0dc34cfc072a6e)
@@ -0,0 +1,28 @@
+# Process with autom4te to create an -*- Autotest -*- test suite.
+#
+# see regression/... subdirs wherein for each of the cases and each check (enumerated) is a pre and post dir. 
+# In pre initial files are placed, in post results can be found to be checked by diff in this testsuite.
+
+AT_INIT([Molecular Builder])
+AT_TESTED(diff fgrep grep)
+
+
+m4_include(testsuite-standard_options.at)
+
+m4_include(testsuite-specifics.at)
+
+m4_include(testsuite-simple_configuration.at)
+
+m4_include(testsuite-domain.at)
+
+m4_include(testsuite-graph.at)
+
+m4_include(testsuite-molecules.at)
+
+m4_include(testsuite-fragmentation.at)
+
+m4_include(testsuite-tesselation.at)
+
+m4_include(testsuite-filling.at)
+
+m4_include(testsuite-analysis.at)
