Index: molecuilder/src/builder.cpp
===================================================================
--- molecuilder/src/builder.cpp	(revision 534899671826c272dfc1083da79550e66c67838e)
+++ molecuilder/src/builder.cpp	(revision f89a9e6b14a98b1efdf4d04ad1a5d6ccdba71e5b)
@@ -699,18 +699,21 @@
   mol->CalculateOrbitals(*configuration);
   configuration->InitMaxMinStopStep = configuration->MaxMinStopStep = configuration->MaxPsiDouble;
-  if (ConfigFileName != NULL) {
+  strcpy(filename, ConfigFileName);
+  if (ConfigFileName != NULL) { // test the file name
     output.open(ConfigFileName, ios::trunc);
   } else if (strlen(configuration->configname) != 0) {
+    strcpy(filename, configuration->configname);
     output.open(configuration->configname, ios::trunc);
     } else {
+      strcpy(filename, DEFAULTCONFIG);
       output.open(DEFAULTCONFIG, ios::trunc);
     }
+  output.close();
+  output.clear();
   cout << Verbose(0) << "Saving of config file ";
-  if (configuration->Save(&output, periode, mol))
+  if (configuration->Save(filename, periode, mol))
     cout << "successful." << endl;
   else
     cout << "failed." << endl;
-  output.close();
-  output.clear();
   
   // and save to xyz file
@@ -741,21 +744,13 @@
   
   // and save as MPQC configuration
-  if (ConfigFileName != NULL) {
+  if (ConfigFileName != NULL)
     strcpy(filename, ConfigFileName);
-    strcat(filename, ".in");
-    output.open(filename, ios::trunc);
-  }
-  if (output == NULL) {
+  if (output == NULL)
     strcpy(filename,"main_pcp_linux");
-    strcat(filename, ".in");
-    output.open(filename, ios::trunc);
-  } 
   cout << Verbose(0) << "Saving as mpqc input ";
-  if (configuration->SaveMPQC(&output, mol))
+  if (configuration->SaveMPQC(filename, mol))
     cout << "done." << endl;
   else
     cout << "failed." << endl;
-  output.close();
-  output.clear();
   
   if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) {
@@ -919,4 +914,5 @@
               ExitFlag = 1;
               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
+                ExitFlag = 255;
                 cerr << "Not enough arguments for parsing: -p <xyz file>" << endl;
               } else {
@@ -934,4 +930,5 @@
               ExitFlag = 1;
               if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr+1]))) {
+                ExitFlag = 255;
                 cerr << "Not enough or invalid arguments for adding atom: -a <element> <x> <y> <z>" << endl;
               } else {
@@ -995,4 +992,5 @@
               ExitFlag = 1;
               if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (argv[argptr+1][0] == '-')) {
+                ExitFlag = 255;
                 cerr << "Not enough or invalid arguments given for changing element: -E <atom nr.> <element>" << endl;
               } else {
@@ -1007,4 +1005,5 @@
               ExitFlag = 1;
               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
+                ExitFlag = 255;
                 cerr << "Not enough or invalid arguments given for storing tempature: -T <temperature file>" << endl;
               } else {
@@ -1023,4 +1022,5 @@
               ExitFlag = 1;
               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
+                ExitFlag = 255;
                 cerr << "Not enough or invalid arguments given for parsing and integrating forces: -P <forces file>" << endl;
               } else {
@@ -1037,4 +1037,5 @@
               ExitFlag = 1;
               if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
+                ExitFlag = 255;
                 cerr << "Not enough or invalid arguments given for translation: -t <x> <y> <z>" << endl;
               } else {
@@ -1051,4 +1052,5 @@
               ExitFlag = 1;
               if ((argptr >= argc) || (!IsValidNumber(argv[argptr])) ) {
+                ExitFlag = 255;
                 cerr << "Not enough or invalid arguments given for scaling: -s <factor/[factor_x]> [factor_y] [factor_z]" << endl;
               } else {
@@ -1077,4 +1079,5 @@
               ExitFlag = 1;
               if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
+                ExitFlag = 255;
                 cerr << "Not enough or invalid arguments given for centering in box: -b <length_x> <length_y> <length_z>" << endl;
               } else {
@@ -1097,4 +1100,5 @@
               ExitFlag = 1;
               if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
+                ExitFlag = 255;
                 cerr << "Not enough or invalid arguments given for centering with boundary: -c <boundary_x> <boundary_y> <boundary_z>" << endl;
               } else {
@@ -1132,4 +1136,5 @@
               ExitFlag = 1;
               if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1]))) {
+                ExitFlag = 255;
                 cerr << "Not enough or invalid arguments for fragmentation: -f <max. bond distance> <bond order>" << endl;
               } else {
@@ -1170,4 +1175,5 @@
               ExitFlag = 1;
               if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) ) {
+                ExitFlag = 255;
                 cerr << "Not enough or invalid arguments given for suspension with specified volume: -U <volume> <density>" << endl;
                 volume = -1; // for case 'u': don't print error again
@@ -1180,4 +1186,5 @@
               if ((argptr >= argc) || (!IsValidNumber(argv[argptr])) ) {
                 if (volume != -1)
+                  ExitFlag = 255;
                   cerr << "Not enough arguments given for suspension: -u <density>" << endl;
               } else {
@@ -1202,4 +1209,5 @@
               ExitFlag = 1;
               if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
+                ExitFlag = 255;
                 cerr << "Not enough or invalid arguments given for repeating cells: -d <repeat_x> <repeat_y> <repeat_z>" << endl;
               } else {
Index: molecuilder/src/config.cpp
===================================================================
--- molecuilder/src/config.cpp	(revision 534899671826c272dfc1083da79550e66c67838e)
+++ molecuilder/src/config.cpp	(revision f89a9e6b14a98b1efdf4d04ad1a5d6ccdba71e5b)
@@ -971,13 +971,15 @@
 
 /** Stores all elements of config structure from which they can be re-read.
- * \param output open output *file stream to write to
+ * \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(ofstream *output, periodentafel *periode, molecule *mol) const
+bool config::Save(const char *filename, periodentafel *periode, molecule *mol) const
 {
   bool result = true;
 	// bring MaxTypes up to date
 	mol->CountElements();
+  ofstream *output = NULL;
+  output = new ofstream(filename, ios::out);
   if (output != NULL) {
     *output << "# ParallelCarParinello - main configuration file - created with molecuilder" << endl;
@@ -1067,4 +1069,7 @@
     else
       result = result && mol->OutputTrajectories(output);
+    output->close();
+    output->clear();
+    delete(output);
     return result;
   } else
@@ -1074,15 +1079,21 @@
 /** Stores all elements in a MPQC input file.
  * Note that this format cannot be parsed again.
- * \param output open output *file stream to write to
+ * \param *filename name of file (without ".in" suffix!)
  * \param *mol pointer to molecule containing all atoms of the molecule 
  */
-bool config::SaveMPQC(ofstream *output, molecule *mol) const
+bool config::SaveMPQC(const char *filename, molecule *mol) const
 {
   int ElementNo = 0;
   int AtomNo;
   atom *Walker = NULL;
-  element *runner = mol->elemente->start;
+  element *runner = NULL;
   Vector *center = NULL;
-
+  ofstream *output = NULL;
+  stringstream *fname = NULL;
+  
+  // first without hessian
+  fname = new stringstream;
+  *fname << filename << ".in";
+  output = new ofstream(fname->str().c_str(), ios::out);
   *output << "% Created by MoleCuilder" << endl;
   *output << "mpqc: (" << endl;
@@ -1100,4 +1111,5 @@
   center = mol->DetermineCenterOfAll(output);
   // output of atoms
+  runner = mol->elemente->start;
   while (runner->next != mol->elemente->end) { // go through every element
     runner = runner->next;
@@ -1122,4 +1134,57 @@
   *output << "\tmolecule = $:molecule" << endl;
   *output << ")" << endl;
+  output->close();
+  delete(output);
+  delete(fname);
+
+  // second with hessian
+  fname = new stringstream;
+  *fname << filename << ".hess.in";
+  output = new ofstream(fname->str().c_str(), ios::out);
+  *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);
+  // output of atoms
+  runner = mol->elemente->start;
+  while (runner->next != mol->elemente->end) { // go through every element
+    runner = runner->next;
+    if (mol->ElementsInMolecule[runner->Z]) { // if this element got atoms
+      ElementNo++;
+      AtomNo = 0;
+      Walker = mol->start;
+      while (Walker->next != mol->end) { // go through every atom of this element
+        Walker = Walker->next;
+        if (Walker->type == runner) { // if this atom fits to element
+          AtomNo++;
+          *output << "\t\t" << Walker->type->symbol << " [ " << Walker->x.x[0]-center->x[0] << "\t" << Walker->x.x[1]-center->x[1] << "\t" << Walker->x.x[2]-center->x[2] << " ]" << endl;
+        }
+      }
+    }
+  }
+  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;
 };
Index: molecuilder/src/moleculelist.cpp
===================================================================
--- molecuilder/src/moleculelist.cpp	(revision 534899671826c272dfc1083da79550e66c67838e)
+++ molecuilder/src/moleculelist.cpp	(revision f89a9e6b14a98b1efdf4d04ad1a5d6ccdba71e5b)
@@ -450,23 +450,19 @@
     // and save as config
     sprintf(FragmentName, "%s/%s%s.conf", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);
-    outputFragment.open(FragmentName, ios::out);
     *out << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter-1 << " as config ...";
-    if ((intermediateResult = configuration->Save(&outputFragment, ListOfMolecules[i]->elemente, ListOfMolecules[i])))
+    if ((intermediateResult = configuration->Save(FragmentName, ListOfMolecules[i]->elemente, ListOfMolecules[i])))
       *out << " done." << endl;
     else
       *out << " failed." << endl;
+    result = result && intermediateResult;
 
     // restore old config
     configuration->SetDefaultPath(PathBackup);
 
-    result = result && intermediateResult;
-    outputFragment.close();
-    outputFragment.clear();
 
     // and save as mpqc input file
-    sprintf(FragmentName, "%s/%s%s.in", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);
-    outputFragment.open(FragmentName, ios::out);
+    sprintf(FragmentName, "%s/%s%s.conf", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);
     *out << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter-1 << " as mpqc input ...";
-    if ((intermediateResult = configuration->SaveMPQC(&outputFragment, ListOfMolecules[i])))
+    if ((intermediateResult = configuration->SaveMPQC(FragmentName, ListOfMolecules[i])))
       *out << " done." << endl;
     else
@@ -474,6 +470,6 @@
        
     result = result && intermediateResult;
-    outputFragment.close();
-    outputFragment.clear();
+    //outputFragment.close();
+    //outputFragment.clear();
     delete(FragmentNumber);
     //Free((void **)&FragmentNumber, "MoleculeListClass::OutputConfigForListOfFragments: *FragmentNumber");
Index: molecuilder/src/molecules.hpp
===================================================================
--- molecuilder/src/molecules.hpp	(revision 534899671826c272dfc1083da79550e66c67838e)
+++ molecuilder/src/molecules.hpp	(revision f89a9e6b14a98b1efdf4d04ad1a5d6ccdba71e5b)
@@ -452,6 +452,6 @@
   void LoadOld(char *filename, periodentafel *periode, molecule *mol);
   void RetrieveConfigPathAndName(string filename);
-  bool Save(ofstream *file, periodentafel *periode, molecule *mol) const;
-  bool SaveMPQC(ofstream *file, molecule *mol) const;
+  bool Save(const char *filename, periodentafel *periode, molecule *mol) const;
+  bool SaveMPQC(const char *filename, molecule *mol) const;
   void Edit(molecule *mol);
   bool GetIsAngstroem() const;
