diff --git a/src/Structure/DataSink.cpp b/src/Structure/DataSink.cpp
index 26eb7bc145f2c0fe23af4f5bb6e26991fc7655a0..d2c36c8ff3bba035a6976d58e70fb93a094488aa 100644
--- a/src/Structure/DataSink.cpp
+++ b/src/Structure/DataSink.cpp
@@ -666,385 +666,6 @@ void DataSink::writeSDDSHeader(std::ofstream &outputFile) {
 }
 void DataSink::writeSDDSHeader(std::ofstream &outputFile,
                                const losses_t &losses) {
-    OPALTimer::Timer simtimer;
-
-    std::string dateStr(simtimer.date());
-    std::string timeStr(simtimer.time());
-    std::string indent("        ");
-
-    outputFile << "SDDS1" << std::endl;
-    outputFile << "&description\n"
-               << indent << "text=\"Statistics data '" << OpalData::getInstance()->getInputFn()
-               << "' " << dateStr << " " << timeStr << "\",\n"
-               << indent << "contents=\"stat parameters\"\n"
-               << "&end\n";
-    outputFile << "&parameter\n"
-               << indent << "name=processors,\n"
-               << indent << "type=long,\n"
-               << indent << "description=\"Number of Cores used\"\n"
-               << "&end\n";
-    outputFile << "&parameter\n"
-               << indent << "name=revision,\n"
-               << indent << "type=string,\n"
-               << indent << "description=\"git revision of opal\"\n"
-               << "&end\n";
-    outputFile << "&parameter\n"
-               << indent << "name=flavor,\n"
-               << indent << "type=string,\n"
-               << indent << "description=\"OPAL flavor that wrote file\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=t,\n"
-               << indent << "type=double,\n"
-               << indent << "units=ns,\n"
-               << indent << "description=\"1 Time\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=s,\n"
-               << indent << "type=double,\n"
-               << indent << "units=m,\n"
-               << indent << "description=\"2 Path length\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=numParticles,\n"
-               << indent << "type=long,\n"
-               << indent << "units=1,\n"
-               << indent << "description=\"3 Number of Macro Particles\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=charge,\n"
-               << indent << "type=double,\n"
-               << indent << "units=1,\n"
-               << indent << "description=\"4 Bunch Charge\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=energy,\n"
-               << indent << "type=double,\n"
-               << indent << "units=MeV,\n"
-               << indent << "description=\"5 Mean Bunch Energy\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=rms_x,\n"
-               << indent << "type=double,\n"
-               << indent << "units=m,\n"
-               << indent << "description=\"6 RMS Beamsize in x\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=rms_y,\n"
-               << indent << "type=double,\n"
-               << indent << "units=m,\n"
-               << indent << "description=\"7 RMS Beamsize in y\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=rms_s,\n"
-               << indent << "type=double,\n"
-               << indent << "units=m,\n"
-               << indent << "description=\"8 RMS Beamsize in s\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=rms_px,\n"
-               << indent << "type=double,\n"
-               << indent << "units=1,\n"
-               << indent << "description=\"9 RMS Normalized Momenta in x\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=rms_py,\n"
-               << indent << "type=double,\n"
-               << indent << "units=1,\n"
-               << indent << "description=\"10 RMS Normalized Momenta in y\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=rms_ps,\n"
-               << indent << "type=double,\n"
-               << indent << "units=1,\n"
-               << indent << "description=\"11 RMS Normalized Momenta in s\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=emit_x,\n"
-               << indent << "type=double,\n"
-               << indent << "units=m,\n"
-               << indent << "description=\"12 Normalized Emittance x\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=emit_y,\n"
-               << indent << "type=double,\n"
-               << indent << "units=m,\n"
-               << indent << "description=\"13 Normalized Emittance y\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=emit_s,\n"
-               << indent << "type=double,\n"
-               << indent << "units=m,\n"
-               << indent << "description=\"14 Normalized Emittance s\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=mean_x,\n"
-               << indent << "type=double,\n"
-               << indent << "units=m,\n"
-               << indent << "description=\"15 Mean Beam Position in x\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=mean_y,\n"
-               << indent << "type=double,\n"
-               << indent << "units=m,\n"
-               << indent << "description=\"16 Mean Beam Position in y\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=mean_s,\n"
-               << indent << "type=double,\n"
-               << indent << "units=m,\n"
-               << indent << "description=\"17 Mean Beam Position in s\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=ref_x,\n"
-               << indent << "type=double,\n"
-               << indent << "units=m,\n"
-               << indent << "description=\"18 x coordinate of reference particle in lab cs\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=ref_y,\n"
-               << indent << "type=double,\n"
-               << indent << "units=m,\n"
-               << indent << "description=\"19 y coordinate of reference particle in lab cs\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=ref_z,\n"
-               << indent << "type=double,\n"
-               << indent << "units=m,\n"
-               << indent << "description=\"20 z coordinate of reference particle in lab cs\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=ref_px,\n"
-               << indent << "type=double,\n"
-               << indent << "units=1,\n"
-               << indent << "description=\"21 x momentum of reference particle in lab cs\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=ref_py,\n"
-               << indent << "type=double,\n"
-               << indent << "units=1,\n"
-               << indent << "description=\"22 y momentum of reference particle in lab cs\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=ref_pz,\n"
-               << indent << "type=double,\n"
-               << indent << "units=1,\n"
-               << indent << "description=\"23 z momentum of reference particle in lab cs\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=max_x,\n"
-               << indent << "type=double,\n"
-               << indent << "units=m,\n"
-               << indent << "description=\"24 Max Beamsize in x\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=max_y,\n"
-               << indent << "type=double,\n"
-               << indent << "units=m,\n"
-               << indent << "description=\"25 Max Beamsize in y\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=max_s,\n"
-               << indent << "type=double,\n"
-               << indent << "units=m,\n"
-               << indent << "description=\"26 Max Beamsize in s\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=xpx,\n"
-               << indent << "type=double,\n"
-               << indent << "units=1,\n"
-               << indent << "description=\"27 Correlation xpx\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=ypy,\n"
-               << indent << "type=double,\n"
-               << indent << "units=1,\n"
-               << indent << "description=\"28 Correlation ypy\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=zpz,\n"
-               << indent << "type=double,\n"
-               << indent << "units=1,\n"
-               << indent << "description=\"29 Correlation zpz\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=Dx,\n"
-               << indent << "type=double,\n"
-               << indent << "units=m,\n"
-               << indent << "description=\"30 Dispersion in x\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=DDx,\n"
-               << indent << "type=double,\n"
-               << indent << "units=1,\n"
-               << indent << "description=\"31 Derivative of dispersion in x\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=Dy,\n"
-               << indent << "type=double,\n"
-               << indent << "units=m,\n"
-               << indent << "description=\"32 Dispersion in y\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=DDy,\n"
-               << indent << "type=double,\n"
-               << indent << "units=1,\n"
-               << indent << "description=\"33 Derivative of dispersion in y\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=Bx_ref,\n"
-               << indent << "type=double,\n"
-               << indent << "units=T,\n"
-               << indent << "description=\"34 Bx-Field component of ref particle\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=By_ref,\n"
-               << indent << "type=double,\n"
-               << indent << "units=T,\n"
-               << indent << "description=\"35 By-Field component of ref particle\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=Bz_ref,\n"
-               << indent << "type=double,\n"
-               << indent << "units=T,\n"
-               << indent << "description=\"36 Bz-Field component of ref particle\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=Ex_ref,\n"
-               << indent << "type=double,\n"
-               << indent << "units=MV/m,\n"
-               << indent << "description=\"37 Ex-Field component of ref particle\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=Ey_ref,\n"
-               << indent << "type=double,\n"
-               << indent << "units=MV/m,\n"
-               << indent << "description=\"38 Ey-Field component of ref particle\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=Ez_ref,\n"
-               << indent << "type=double,\n"
-               << indent << "units=MV/m,\n"
-               << indent << "description=\"39 Ez-Field component of ref particle\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=dE,\n"
-               << indent << "type=double,\n"
-               << indent << "units=MeV,\n"
-               << indent << "description=\"40 energy spread of the beam\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=dt,\n"
-               << indent << "type=double,\n"
-               << indent << "units=ns,\n"
-               << indent << "description=\"41 time step size\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=partsOutside,\n"
-               << indent << "type=double,\n"
-               << indent << "units=1,\n"
-               << indent << "description=\"42 outside n*sigma of the beam\"\n"
-               << "&end\n";
-
-    unsigned int columnStart = 43;
-    if(Ippl::getNodes() == 1) {
-        outputFile << "&column\n"
-                   << indent << "name=R0_x,\n"
-                   << indent << "type=double,\n"
-                   << indent << "units=m,\n"
-                   << indent << "description=\"43 R0 Particle position in x\"\n"
-                   << "&end\n";
-        outputFile << "&column\n"
-                   << indent << "name=R0_y,\n"
-                   << indent << "type=double,\n"
-                   << indent << "units=m,\n"
-                   << indent << "description=\"44 R0 Particle position in y\"\n"
-                   << "&end\n";
-        outputFile << "&column\n"
-                   << indent << "name=R0_s,\n"
-                   << indent << "type=double,\n"
-                   << indent << "units=m,\n"
-                   << indent << "description=\"45 R0 Particle position in z\"\n"
-                   << "&end\n";
-        outputFile << "&column\n"
-                   << indent << "name=P0_x,\n"
-                   << indent << "type=double,\n"
-                   << indent << "units=1,\n"
-                   << indent << "description=\"46 R0 Particle momentum in x\"\n"
-                   << "&end\n";
-        outputFile << "&column\n"
-                   << indent << "name=P0_y,\n"
-                   << indent << "type=double,\n"
-                   << indent << "units=1,\n"
-                   << indent << "description=\"47 R0 Particle momentum in y\"\n"
-                   << "&end\n";
-        outputFile << "&column\n"
-                   << indent << "name=P0_s,\n"
-                   << indent << "type=double,\n"
-                   << indent << "units=1,\n"
-                   << indent << "description=\"48 R0 Particle momentum in z\"\n"
-                   << "&end\n";
-        columnStart = 49;
-    }
-
-    if (OpalData::getInstance()->isInOPALCyclMode()) {
-        char dir[] = { 'x', 'y', 'z' };
-
-        for (int i = 0; i < 3; ++i) {
-            std::stringstream ss;
-            ss << "&column\n" << indent << "name=halo_" << dir[i] << ",\n"
-               << indent << "type=double,\n"
-               << indent << "units=1,\n"
-               << indent << "description=\"" << columnStart++ << " Halo in "
-               << dir[i] << "\"\n"
-               << "&end\n";
-               outputFile << ss.str();
-        }
-        std::stringstream ss;
-        ss << "&column\n" << indent << "name=azimuth,\n"
-           << indent << "type=double,\n"
-           << indent << "units=deg,\n"
-           << indent << "description=\"" << columnStart++ << " Azimuth in "
-           << "global coordinates\"\n"
-           << "&end\n";
-        outputFile << ss.str();
-    }
-
-    for (size_t i = 0; i < losses.size(); ++ i) {
-        outputFile << "&column\n"
-                   << indent << "name=" << losses[i].first << ",\n"
-                   << indent << "type=long,\n"
-                   << indent << "units=1,\n"
-                   << indent << "description=\"" << columnStart ++ << "Number of lost particles in element\"\n"
-                   << "&end\n";
-    }
-
-//    std::string method = Util::toUpper(Attributes::getString(itsAttr[METHOD])); //<--
-//    if (method == "THICK") {
-//        outputFile << "&column\n"
-//               << indent << "name=mapD_x,\n"
-//               << indent << "type=double,\n"
-//               << indent << "units=1,\n"
-//               << indent << "description=\"49 Dx dispersion of beamline"\n"
-//               << "&end\n";
-//        outputFile << "&column\n"
-//               << indent << "name=mapD_y,\n"
-//               << indent << "type=double,\n"
-//               << indent << "units=1,\n"
-//               << indent << "description=\"50 Dy dispersion of beamline"\n"
-//               << "&end\n";
-//        columnStart = 51;
-//    }
-
-    outputFile << "&data\n"
-               << indent << "mode=ascii,\n"
-               << indent << "no_row_counts=1\n"
-               << "&end\n";
-
-    outputFile << Ippl::getNodes() << std::endl;
-    outputFile << OPAL_PROJECT_NAME << " " << OPAL_PROJECT_VERSION << " git rev. #" << Util::getGitRevision() << std::endl;
-    outputFile << (OpalData::getInstance()->isInOPALTMode()? "opal-t":
-                   (OpalData::getInstance()->isInOPALCyclMode()? "opal-cycl": "opal-env")) << std::endl;
 }
 
 
@@ -1376,80 +997,6 @@ bool DataSink::doHDF5() {
 }
 
 
-/** \brief
- *  delete the last 'numberOfLines' lines of the file 'fileName'
- */
-void DataSink::rewindLines(const std::string &fileName, size_t numberOfLines) const {
-    if (numberOfLines == 0) return;
-
-    std::string line;
-    std::queue<std::string> allLines;
-    std::fstream fs;
-
-    fs.open (fileName.c_str(), std::fstream::in);
-
-    if (!fs.is_open()) return;
-
-    while (getline(fs, line)) {
-        allLines.push(line);
-    }
-    fs.close();
-
-
-    fs.open (fileName.c_str(), std::fstream::out);
-
-    if (!fs.is_open()) return;
-
-    while (allLines.size() > numberOfLines) {
-        fs << allLines.front() << "\n";
-        allLines.pop();
-    }
-    fs.close();
-}
-
-void DataSink::replaceVersionString(const std::string &fileName) const {
-
-    if (Ippl::myNode() == 0) {
-        std::string versionFile;
-        SDDS::SDDSParser parser(fileName);
-        parser.run();
-        parser.getParameterValue("revision", versionFile);
-
-        std::string line;
-        std::queue<std::string> allLines;
-        std::fstream fs;
-
-        fs.open (fileName.c_str(), std::fstream::in);
-
-        if (!fs.is_open()) return;
-
-        while (getline(fs, line)) {
-            allLines.push(line);
-        }
-        fs.close();
-
-
-        fs.open (fileName.c_str(), std::fstream::out);
-
-        if (!fs.is_open()) return;
-
-        while (allLines.size() > 0) {
-            line = allLines.front();
-
-            if (line != versionFile) {
-                fs << line << "\n";
-            } else {
-                fs << OPAL_PROJECT_NAME << " " << OPAL_PROJECT_VERSION << " git rev. #" << Util::getGitRevision() << "\n";
-            }
-
-            allLines.pop();
-        }
-
-        fs.close();
-    }
-}
-
-
 void DataSink::open_m(std::ofstream& os, const std::string& fileName) const {
     os.open(fileName.c_str(), mode_m);
     os.precision(15);
@@ -1457,215 +1004,6 @@ void DataSink::open_m(std::ofstream& os, const std::string& fileName) const {
 }
 
 
-void DataSink::writeLBalHeader(PartBunchBase<double, 3> *beam,
-                               std::ofstream &outputFile)
-{
-    OPALTimer::Timer simtimer;
-
-    std::string dateStr(simtimer.date());
-    std::string timeStr(simtimer.time());
-    std::string indent("        ");
-
-    outputFile << "SDDS1" << std::endl;
-    outputFile << "&description\n"
-               << indent << "text=\"Processor statistics '"
-               << OpalData::getInstance()->getInputFn() << "' "
-               << dateStr << "" << timeStr << "\",\n"
-               << indent << "contents=\"stat parameters\"\n"
-               << "&end\n";
-    outputFile << "&parameter\n"
-               << indent << "name=processors,\n"
-               << indent << "type=long,\n"
-               << indent << "description=\"Number of Cores used\"\n"
-               << "&end\n";
-    outputFile << "&parameter\n"
-               << indent << "name=revision,\n"
-               << indent << "type=string,\n"
-               << indent << "description=\"git revision of opal\"\n"
-               << "&end\n";
-    outputFile << "&parameter\n"
-               << indent << "name=flavor,\n"
-               << indent << "type=string,\n"
-               << indent << "description=\"OPAL flavor that wrote file\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=t,\n"
-               << indent << "type=double,\n"
-               << indent << "units=ns,\n"
-               << indent << "description=\"1 Time\"\n"
-               << "&end\n";
-
-    unsigned int columnStart = 2;
-
-
-    for (int p = 0; p < Ippl::getNodes(); ++p) {
-        outputFile << "&column\n"
-                   << indent << "name=processor-" << p << ",\n"
-                   << indent << "type=long,\n"
-                   << indent << "units=1,\n"
-                   << indent << "description=\"" << columnStart
-                   << " Number of particles of processor " << p << "\"\n"
-                   << "&end\n";
-        ++columnStart;
-    }
-
-#ifdef ENABLE_AMR
-    if ( AmrPartBunch* amrbeam = dynamic_cast<AmrPartBunch*>(beam) ) {
-
-        int nLevel = (amrbeam->getAmrObject())->maxLevel() + 1;
-
-        for (int lev = 0; lev < nLevel; ++lev) {
-            outputFile << "&column\n"
-                   << indent << "name=level-" << lev << ",\n"
-                   << indent << "type=long,\n"
-                   << indent << "units=1,\n"
-                   << indent << "description=\"" << columnStart
-                   << " Number of particles at level " << lev << "\"\n"
-                   << "&end\n";
-            ++columnStart;
-        }
-    }
-#endif
-
-    outputFile << "&data\n"
-               << indent << "mode=ascii,\n"
-               << indent << "no_row_counts=1\n"
-               << "&end\n";
-
-    outputFile << Ippl::getNodes() << std::endl;
-    outputFile << OPAL_PROJECT_NAME << " " << OPAL_PROJECT_VERSION << " git rev. #" << Util::getGitRevision() << std::endl;
-    outputFile << (OpalData::getInstance()->isInOPALTMode()? "opal-t":
-                   (OpalData::getInstance()->isInOPALCyclMode()? "opal-cycl": "opal-env")) << std::endl;
-
-
-}
-
-void DataSink::writeLBalData(PartBunchBase<double, 3> *beam,
-                             std::ofstream &os_lBalData,
-                             unsigned int pwi)
-{
-    os_lBalData << beam->getT() * 1e9 << std::setw(pwi) << "\t";     // 1
-
-    size_t nProcs = Ippl::getNodes();
-    for (size_t p = 0; p < nProcs; ++ p) {
-        os_lBalData << beam->getLoadBalance(p)  << std::setw(pwi);
-
-        if ( p + 1 < nProcs )
-            os_lBalData << "\t";
-
-    }
-
-#ifdef ENABLE_AMR
-    if ( AmrPartBunch* amrbeam = dynamic_cast<AmrPartBunch*>(beam) ) {
-        os_lBalData << "\t";
-        int nLevel = (amrbeam->getAmrObject())->maxLevel() + 1;
-        for (int lev = 0; lev < nLevel; ++lev) {
-            os_lBalData << amrbeam->getLevelStatistics(lev) << std::setw(pwi);
-
-            if ( lev < nLevel - 1 )
-                os_lBalData << "\t";
-        }
-    }
-#endif
-    os_lBalData << std::endl;
-}
-
-
-void DataSink::writeMemoryHeader(std::ofstream &outputFile)
-{
-    OPALTimer::Timer simtimer;
-
-    std::string dateStr(simtimer.date());
-    std::string timeStr(simtimer.time());
-    std::string indent("        ");
-
-    IpplMemoryUsage::IpplMemory_p memory = IpplMemoryUsage::getInstance();
-
-    outputFile << "SDDS1" << std::endl;
-    outputFile << "&description\n"
-               << indent << "text=\"Memory statistics '"
-               << OpalData::getInstance()->getInputFn() << "' "
-               << dateStr << "" << timeStr << "\",\n"
-               << indent << "contents=\"stat parameters\"\n"
-               << "&end\n";
-    outputFile << "&parameter\n"
-               << indent << "name=processors,\n"
-               << indent << "type=long,\n"
-               << indent << "description=\"Number of Cores used\"\n"
-               << "&end\n";
-    outputFile << "&parameter\n"
-               << indent << "name=revision,\n"
-               << indent << "type=string,\n"
-               << indent << "description=\"git revision of opal\"\n"
-               << "&end\n";
-    outputFile << "&parameter\n"
-               << indent << "name=flavor,\n"
-               << indent << "type=string,\n"
-               << indent << "description=\"OPAL flavor that wrote file\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=t,\n"
-               << indent << "type=double,\n"
-               << indent << "units=ns,\n"
-               << indent << "description=\"1 Time\"\n"
-               << "&end\n";
-    outputFile << "&column\n"
-               << indent << "name=memory,\n"
-               << indent << "type=double,\n"
-               << indent << "units=" + memory->getUnit() + ",\n"
-               << indent << "description=\"2 Total Memory\"\n"
-               << "&end\n";
-
-    unsigned int columnStart = 3;
-
-    for (int p = 0; p < Ippl::getNodes(); ++p) {
-        outputFile << "&column\n"
-                   << indent << "name=processor-" << p << ",\n"
-                   << indent << "type=double,\n"
-                   << indent << "units=" + memory->getUnit() + ",\n"
-                   << indent << "description=\"" << columnStart
-                   << " Memory per processor " << p << "\"\n"
-                   << "&end\n";
-        ++columnStart;
-    }
-
-    outputFile << "&data\n"
-               << indent << "mode=ascii,\n"
-               << indent << "no_row_counts=1\n"
-               << "&end\n";
-
-    outputFile << Ippl::getNodes() << std::endl;
-    outputFile << OPAL_PROJECT_NAME << " " << OPAL_PROJECT_VERSION << " git rev. #" << Util::getGitRevision() << std::endl;
-    outputFile << (OpalData::getInstance()->isInOPALTMode()? "opal-t":
-                   (OpalData::getInstance()->isInOPALCyclMode()? "opal-cycl": "opal-env")) << std::endl;
-}
-
-
-void DataSink::writeMemoryData(PartBunchBase<double, 3> *beam,
-                               std::ofstream &os_memData,
-                               unsigned int pwi)
-{
-    os_memData << beam->getT() * 1e9 << std::setw(pwi) << "\t";     // 1
-
-    IpplMemoryUsage::IpplMemory_p memory = IpplMemoryUsage::getInstance();
-
-    int nProcs = Ippl::getNodes();
-    double total = 0.0;
-    for (int p = 0; p < nProcs; ++p) {
-        total += memory->getMemoryUsage(p);
-    }
-
-    os_memData << total << std::setw(pwi) << "\t";
-
-    for (int p = 0; p < nProcs; p++) {
-        os_memData << memory->getMemoryUsage(p)  << std::setw(pwi);
-
-        if ( p < nProcs - 1 )
-            os_memData << "\t";
-
-    }
-    os_memData << std::endl;
-}
 
 #ifdef ENABLE_AMR
 void DataSink::writeGridLBalHeader(PartBunchBase<double, 3> *beam,
diff --git a/src/Structure/LBalWriter.cpp b/src/Structure/LBalWriter.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f39252d9e25437f2ff220172e4416af80fc8c5ac
--- /dev/null
+++ b/src/Structure/LBalWriter.cpp
@@ -0,0 +1,81 @@
+#include "LBalWriter.h"
+
+void LBalWriter::writeHeader(PartBunchBase<double, 3> *beam) {
+    OPALTimer::Timer simtimer;
+
+    std::string dateStr(simtimer.date());
+    std::string timeStr(simtimer.time());
+
+    os_m << "SDDS1" << std::endl;
+    
+    std::stringstream ss;
+    ss << "Processor statistics '"
+       << OpalData::getInstance()->getInputFn() << "' "
+       << dateStr << "" << timeStr;
+    
+    this->addDescription(ss.str(), "lbal parameters");
+    
+    this->addParameter("processors", "long", "Number of Cores used");
+
+    this->addParameter("revision", "string", "git revision of opal");
+
+    this->addParameter("flavor", "string", "OPAL flavor that wrote file");
+    
+    this->addColumn("t", "double", "ns", "Time");
+
+    for (int p = 0; p < Ippl::getNodes(); ++p) {
+        std::stringstream tmp1;
+        tmp1 << "processor-" << p;
+        
+        std::stringstream tmp2;
+        tmp2 << "Number of particles of processor " << p;
+        
+        this->addColumn(ss.str(), "long", "1", tmp2.str());
+    }
+
+#ifdef ENABLE_AMR
+    if ( AmrPartBunch* amrbeam = dynamic_cast<AmrPartBunch*>(beam) ) {
+
+        int nLevel = (amrbeam->getAmrObject())->maxLevel() + 1;
+
+        for (int lev = 0; lev < nLevel; ++lev) {
+            std::stringstream tmp1;
+            tmp1 << "level-" << lev;
+            
+            std::stringstream tmp2;
+            tmps2 << "Number of particles at level " << lev;
+            this->addColumn(tmp1.str(), "long", "1", tmp2.str());
+        }
+    }
+#endif
+
+    this->addData("ascii", "1");
+
+    os_m << Ippl::getNodes()
+         << OPAL_PROJECT_NAME << " "
+         << OPAL_PROJECT_VERSION << " git rev. #" << Util::getGitRevision() << "\n"
+         << (OpalData::getInstance()->isInOPALTMode()? "opal-t":
+                (OpalData::getInstance()->isInOPALCyclMode()? "opal-cycl": "opal-env"))
+         << std::endl;
+}
+
+
+void LBalWriter::writeData(PartBunchBase<double, 3> *beam) {
+    
+    this->writeValue(beam->getT() * 1e9);   // 1
+
+    size_t nProcs = Ippl::getNodes();
+    for (size_t p = 0; p < nProcs; ++ p) {
+        this->writeValue(beam->getLoadBalance(p));
+    }
+
+#ifdef ENABLE_AMR
+    if ( AmrPartBunch* amrbeam = dynamic_cast<AmrPartBunch*>(beam) ) {
+        int nLevel = (amrbeam->getAmrObject())->maxLevel() + 1;
+        for (int lev = 0; lev < nLevel; ++lev) {
+            this->writeValue(amrbeam->getLevelStatistics(lev));
+        }
+    }
+#endif
+    os_m << std::endl;
+}
diff --git a/src/Structure/LBalWriter.h b/src/Structure/LBalWriter.h
new file mode 100644
index 0000000000000000000000000000000000000000..a89357d2e83718a5019840a6db7b0b9fd7fcb764
--- /dev/null
+++ b/src/Structure/LBalWriter.h
@@ -0,0 +1,12 @@
+#ifndef OPAL_LBAL_WRITER_H
+#define OPAL_LBAL_WRITER_H
+
+#include "SDDSWriter.h"
+
+class LBalWriter : public SDDSWriter {
+    
+private:
+    void writeHeader(PartBunchBase<double, 3> *beam);
+    void writeData(PartBunchBase<double, 3> *beam);
+}
+#endif
diff --git a/src/Structure/MemoryWriter.cpp b/src/Structure/MemoryWriter.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9141c84ce96f3fac04af63f4b4f9acf7376b8a85
--- /dev/null
+++ b/src/Structure/MemoryWriter.cpp
@@ -0,0 +1,65 @@
+#include "MemoryWriter.h"
+
+void MemoryWriter::writeHeader() {
+    OPALTimer::Timer simtimer;
+
+    std::string dateStr(simtimer.date());
+    std::string timeStr(simtimer.time());
+
+    IpplMemoryUsage::IpplMemory_p memory = IpplMemoryUsage::getInstance();
+
+    os_m << "SDDS1" << std::endl;
+    
+    std::stringstream ss;
+    
+    ss << "Memory statistics '"
+       << OpalData::getInstance()->getInputFn() << "' "
+       << dateStr << "" << timeStr;
+    
+    this->addDescription(ss.str(), "memory parameters");
+    
+    this->addParameter("processors", "long", "Number of Cores used");
+    
+    this->addParameter("revision", "string", "git revision of opal");
+    
+    this->addParameter("flavor", "string", "OPAL flavor that wrote file");
+    
+    this->addColumn("t", "double", "ns", "Time");
+    
+    this->addColumn("memory", "double", memory->getUnit(), "Total Memory");
+
+    for (int p = 0; p < Ippl::getNodes(); ++p) {
+        std::stringstream tmp1;
+        tmp1 << "processor-" << p;
+        
+        std::stringstream tmp2;
+        tmp2 << "Memory per processor " << p;
+        this->addColumn(tmp1.str(), "double", memory->getUnit(), tmp2.str());
+    }
+    
+    this->addData("ascii", 1);
+    
+    os_m << Ippl::getNodes() << std::endl
+         << OPAL_PROJECT_NAME << " " << OPAL_PROJECT_VERSION << " git rev. #" << Util::getGitRevision() << std::endl
+         << (OpalData::getInstance()->isInOPALTMode()? "opal-t":
+                (OpalData::getInstance()->isInOPALCyclMode()? "opal-cycl": "opal-env")) << std::endl;
+}
+
+
+void MemoryWriter::writeData(PartBunchBase<double, 3> *beam) {
+    
+    this->writeValue(beam->getT() * 1e9);   // 1
+
+    IpplMemoryUsage::IpplMemory_p memory = IpplMemoryUsage::getInstance();
+
+    int nProcs = Ippl::getNodes();
+    double total = 0.0;
+    for (int p = 0; p < nProcs; ++p) {
+        total += memory->getMemoryUsage(p);
+    }
+
+    this->writeValue(total);
+    
+    for (int p = 0; p < nProcs; p++) {
+        this->writeValue(memory->getMemoryUsage(p));
+}
diff --git a/src/Structure/MemoryWriter.h b/src/Structure/MemoryWriter.h
new file mode 100644
index 0000000000000000000000000000000000000000..f8c6b9aef6a0b9a7d90aefda12282fbc24d1c3ee
--- /dev/null
+++ b/src/Structure/MemoryWriter.h
@@ -0,0 +1,11 @@
+#ifndef OPAL_MEMORY_WRITER_H
+#define OPAL_MEMORY_WRITER_H
+
+#include "SDDSWriter.h"
+
+class MemoryWriter : public SDDSWriter {
+    
+    
+};
+
+#endif
diff --git a/src/Structure/SDDSWriter.cpp b/src/Structure/SDDSWriter.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a2bec83068270443151fb604fadc05e96e2ecebd
--- /dev/null
+++ b/src/Structure/SDDSWriter.cpp
@@ -0,0 +1,135 @@
+#include "SDDSWriter.h"
+
+#include <queue>
+
+SDDSWriter(const std::string& fname)
+    : DataSink()
+    , os_m(fname.c_str(), std::ios::out)
+    , indent_m("        ")
+{ }
+
+
+void SDDSWriter::rewindLines(const std::string &fname, size_t numberOfLines) const {
+    if (numberOfLines == 0) return;
+
+    std::string line;
+    std::queue<std::string> allLines;
+    std::fstream fs;
+
+    fs.open (fname.c_str(), std::fstream::in);
+
+    if (!fs.is_open()) return;
+
+    while (getline(fs, line)) {
+        allLines.push(line);
+    }
+    fs.close();
+
+
+    fs.open (fname.c_str(), std::fstream::out);
+
+    if (!fs.is_open()) return;
+
+    while (allLines.size() > numberOfLines) {
+        fs << allLines.front() << "\n";
+        allLines.pop();
+    }
+    fs.close();
+}
+
+
+void SDDSWriter::replaceVersionString(const std::string &fname) const {
+
+    if (Ippl::myNode() == 0) {
+        std::string versionFile;
+        SDDS::SDDSParser parser(fname);
+        parser.run();
+        parser.getParameterValue("revision", versionFile);
+
+        std::string line;
+        std::queue<std::string> allLines;
+        std::fstream fs;
+
+        fs.open (fname.c_str(), std::fstream::in);
+
+        if (!fs.is_open()) return;
+
+        while (getline(fs, line)) {
+            allLines.push(line);
+        }
+        fs.close();
+
+
+        fs.open (fname.c_str(), std::fstream::out);
+
+        if (!fs.is_open()) return;
+
+        while (allLines.size() > 0) {
+            line = allLines.front();
+
+            if (line != versionFile) {
+                fs << line << "\n";
+            } else {
+                fs << OPAL_PROJECT_NAME << " " << OPAL_PROJECT_VERSION << " git rev. #" << Util::getGitRevision() << "\n";
+            }
+
+            allLines.pop();
+        }
+
+        fs.close();
+    }
+}
+
+
+void SDDSWriter::addDescription(const std::string& text,
+                                const std::string& content)
+{
+    os_m << "&description\n"
+         << indent_m << "text=\"" << text << "\",\n"
+         << indent_m << "contents=\"" << content << "\"\n"
+         << "&end\n";
+}
+
+
+void SDDSWriter::addParameter(const std::string& name,
+                              const std::string& type,
+                              const std::string& desc)
+{
+    os_m << "&parameter\n"
+         << indent_m << "name=" << name << ",\n"
+         << indent_m << "type=" << type << ",\n"
+         << indent_m << "description=\"" << desc << "\"\n"
+         << "&end\n";
+}
+
+
+void SDDSWriter::addColumn(const std::string& name,
+                           const std::string& type,
+                           const std::string& unit,
+                           const std::string& desc)
+{
+    static short column = 1;
+    
+    os_m << "&column\n"
+         << indent_m << "name=" << name << ",\n"
+         << indent_m << "type=" << type << ",\n"
+         << indent_m << "units=" << unit << ",\n"
+         << indent_m << "description=\"" << column++ << " " << desc << "\"\n"
+         << "&end\n";
+}
+
+
+void SDDSWriter::addData(const std::string& mode,
+                         const short& no_row_counts)
+{
+    os_m << "&data\n"
+         << indent_m << "mode=" << mode << ",\n"
+         << indent_m << "no_row_counts=" << no_row_counts << "\n"
+         << "&end\n";
+}
+
+
+template<typename T>
+void SDDSWriter::writeValue(const T& value) {
+    os_m << value << std::setw(10) << "\t";
+}
diff --git a/src/Structure/SDDSWriter.h b/src/Structure/SDDSWriter.h
new file mode 100644
index 0000000000000000000000000000000000000000..f02ba64207137cd6bffd41999af1b589146706f8
--- /dev/null
+++ b/src/Structure/SDDSWriter.h
@@ -0,0 +1,50 @@
+#ifndef OPAL_SDDS_WRITER_H
+#define OPAL_SDDS_WRITER_H
+
+#include <fstream>
+#include <string>
+
+#include "Structure/DataSink.h"
+
+
+class SDDSWriter : public DataSink {
+
+public:
+    SDDSWriter(const std::string& fname);
+    
+    /** \brief
+     *  delete the last 'numberOfLines' lines of the file 'fileName'
+     */
+    void rewindLines(const std::string &fname, size_t numberOfLines) const;
+    
+    void replaceVersionString(const std::string &fname) const;
+    
+protected:
+    
+    void addDescription(const std::string& text,
+                        const std::string& content);
+    
+    void addParameter(const std::string& name,
+                      const std::string& type,
+                      const std::string& desc);
+    
+    void addColumn(const std::string& name,
+                   const std::string& type,
+                   const std::string& unit,
+                   const std::string& desc);
+
+    void addData(const std::string& mode,
+                 const short& no_row_counts);
+
+    virtual void writeHeader() = 0;
+    
+    virtual void writeData(PartBunchBase<double, 3> *beam) = 0;
+    
+    template<typename T>
+    void writeValue(const T& value);
+    
+protected:
+    std::ofstream os_m;
+};
+
+#endif
diff --git a/src/Structure/StatWriter.cpp b/src/Structure/StatWriter.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..eb271f59b371a30584c138a0e51a2fb1c723420f
--- /dev/null
+++ b/src/Structure/StatWriter.cpp
@@ -0,0 +1,273 @@
+#include "StatWriter.h"
+
+#include <sstream>
+
+void StatWriter::writeHeader() {
+    OPALTimer::Timer simtimer;
+    std::string dateStr(simtimer.date());
+    std::string timeStr(simtimer.time());
+    
+    os_m << "SDDS1" << std::endl;
+    
+    std::stringstream ss;
+    ss << "Statistics data '"
+       << OpalData::getInstance()->getInputFn()
+       << "' " << dateStr << " " << timeStr;
+    
+    this->addDescription(ss.str(), "stat parameters");
+    
+    this->addParameter("processors", "long", "Number of Cores used");
+    
+    this->addParameter("revision", "string", "git revision of opal");
+    
+    this->addParameter("flavor", "string", "OPAL flavor that wrote file");
+    
+    this->addColumn("t", "double", "ns", "Time");
+    
+    this->addColumn("s", "double", "m", "Path length");
+    
+    this->addColumn("numParticles", "long", "1", "Number of Macro Particles");
+    
+    this->addColumn("charge", "double", "1", "Bunch Charge");
+
+    this->addColumn("energy", "double", "MeV", "Mean Bunch Energy");
+    
+    this->addColumn("rms_x", "double", "m", "RMS Beamsize in x");
+    
+    this->addColumn("rms_y", "double", "m", "RMS Beamsize in y")
+
+    this->addColumn("rms_s", "double", "m", "RMS Beamsize in s"
+
+    this->addColumn("rms_px", "double", "1", "RMS Normalized Momenta in x");
+
+    this->addColumn("rms_py", "double", "1", "RMS Normalized Momenta in y");
+
+    this->addColumn("rms_ps", "double", "1", "RMS Normalized Momenta in s");
+
+    this->addColumn("emit_x", "double", "m", "Normalized Emittance x");
+
+    this->addColumn("emit_y", "double", "m", "Normalized Emittance y");
+
+    this->addColumn("emit_s", "double", "m", "Normalized Emittance s");
+
+    this->addColumn("mean_x", "double", "m", "Mean Beam Position in x");
+
+    this->addColumn("mean_y", "double", "m", "Mean Beam Position in y");
+
+    this->addColumn("mean_s", "double", "m", "Mean Beam Position in s");
+
+    this->addColumn("ref_x", "double", "m", "x coordinate of reference particle in lab cs");
+
+    this->addColumn("ref_y", "double", "m", "y coordinate of reference particle in lab cs");
+
+    this->addColumn("ref_z", "double", "m", "z coordinate of reference particle in lab cs");
+
+    this->addColumn("ref_px", "double", "1", "x momentum of reference particle in lab cs");
+
+    this->addColumn("ref_py", "double", "1", "y momentum of reference particle in lab cs");
+
+    this->addColumn("ref_pz", "double", "1", "z momentum of reference particle in lab cs");
+
+    this->addColumn("max_x", "double", "m", "Max Beamsize in x");
+
+    this->addColumn("max_y", "double", "m", "Max Beamsize in y");
+
+    this->addColumn("max_s", "double", "m", "Max Beamsize in s");
+
+    this->addColumn("xpx", "double", "1", "Correlation xpx");
+
+    this->addColumn("ypy", "double", "1", "Correlation ypy");
+
+    this->addColumn("zpz", "double", "1", "Correlation zpz");
+
+    this->addColumn("Dx", "double", "m", "Dispersion in x");
+
+    this->addColumn("DDx", "double", "1", "Derivative of dispersion in x");
+
+    this->addColumn("Dy", "double", "m", "Dispersion in y");
+
+    this->addColumn("DDy" "double", "1", "Derivative of dispersion in y");
+
+    this->addColumn("Bx_ref" "double", "T", "Bx-Field component of ref particle");
+
+    this->addColumn("By_ref" "double", "T", "By-Field component of ref particle");
+
+    this->addColumn("Bz_ref" "double", "T", "Bz-Field component of ref particle");
+
+    this->addColumn("Ex_ref" "double", "MV/m", "Ex-Field component of ref particle");
+
+    this->addColumn("Ey_ref" "double", "MV/m", "Ey-Field component of ref particle");
+
+    this->addColumn("Ez_ref" "double", "MV/m", "Ez-Field component of ref particle");
+
+    this->addColumn("dE" "double", "MeV", "energy spread of the beam");
+
+    this->addColumn("dt" "double", "ns", "time step size");
+
+    this->addColumn("partsOutside", "double",  "1", "outside n*sigma of the beam");
+
+
+    if (Ippl::getNodes() == 1) {
+        this->addColumn("R0_x", "double", "m", "R0 Particle position in x");
+
+        this->addColumn("R0_y", "double", "m", "R0 Particle position in y");
+
+        this->addColumn("R0_s", "double", "m", "R0 Particle position in z");
+
+        this->addColumn("P0_x", "double", "1", "R0 Particle momentum in x");
+
+        this->addColumn("P0_y", "double", "1", "R0 Particle momentum in y");
+
+        this->addColumn("P0_s", "double", "1", "R0 Particle momentum in z");
+    }
+
+    if (OpalData::getInstance()->isInOPALCyclMode()) {
+        char dir[] = { 'x', 'y', 'z' };
+
+        for (int i = 0; i < 3; ++i) {
+            std::stringstream tmp1;
+            tmp1 << "halo_" << dir[i];
+            
+            std::stringstream tmp2;
+            tmp2 << "Halo in " << dir[i];
+            this->addColumn(tmp1.str(), "double", "1", tmp2.str());
+        }
+        this->addColumn("azimuth", "double", "deg",
+                        "Azimuth in global coordinates");
+    }
+
+    for (size_t i = 0; i < losses.size(); ++ i) {
+        this->addColumn(losses[i].first, "long", "1",
+                        "Number of lost particles in element");
+    }
+
+    this->addData("ascii", "1");
+    
+    os_m << Ippl::getNodes()
+         << OPAL_PROJECT_NAME << " "
+         << OPAL_PROJECT_VERSION << " git rev. #" << Util::getGitRevision() << "\n"
+         << (OpalData::getInstance()->isInOPALTMode()? "opal-t":
+                (OpalData::getInstance()->isInOPALCyclMode()? "opal-cycl": "opal-env"))
+         << std::endl;
+}
+
+
+void StatWriter::writeData(PartBunchBase<double, 3> *beam) {
+    /// Start timer.
+    IpplTimings::startTimer(StatMarkerTimer_m);
+
+    /// Calculate beam statistics.
+    beam->calcBeamParameters();
+
+    size_t npOutside = 0;
+    if (Options::beamHaloBoundary > 0)
+        npOutside = beam->calcNumPartsOutside(Options::beamHaloBoundary*beam->get_rrms());
+
+    double  pathLength = 0.0;
+    if (OpalData::getInstance()->isInOPALCyclMode())
+        pathLength = beam->getLPath();
+    else
+        pathLength = beam->get_sPos();
+
+    /// Write data to files. If this is the first write to the beam statistics file, write SDDS
+    /// header information.
+
+    double Q = beam->getCharge();
+
+    if (Ippl::myNode() != 0) {
+        IpplTimings::stopTimer(StatMarkerTimer_m);
+        return;
+    }
+
+    open_m(os_statData, statFileName_m);
+        
+    if (mode_m == std::ios::out) {
+        mode_m = std::ios::app;
+        writeSDDSHeader(os_statData, losses);
+    }
+
+    this->writeValue(beam->getT() * 1e9);   // 1
+    this->writeValue(pathLength);           // 2
+    this->writeValue(beam->getTotalNum());  // 3
+    this->writeValue(Q);                    // 4
+    this->writeValue(Ekin);                 // 5
+    
+    this->writeValue(beam->get_rrms()(0));  // 6
+    this->writeValue(beam->get_rrms()(1));  // 7
+    this->writeValue(beam->get_rrms()(2));  // 8
+
+    this->writeValue(beam->get_prms()(0));  // 9
+    this->writeValue(beam->get_prms()(1));  // 10
+    this->writeValue(beam->get_prms()(2));  // 11
+
+    this->writeValue(beam->get_norm_emit()(0)); // 12
+    this->writeValue(beam->get_norm_emit()(1)); // 13
+    this->writeValue(beam->get_norm_emit()(2)); // 14
+
+    this->writeValue(beam->get_rmean()(0) );    // 15
+    this->writeValue(beam->get_rmean()(1) );    // 16
+    this->writeValue(beam->get_rmean()(2) );    // 17
+
+    this->writeValue(beam->RefPartR_m(0)); // 18
+    this->writeValue(beam->RefPartR_m(1)); // 19
+    this->writeValue(beam->RefPartR_m(2)); // 20
+
+    this->writeValue(beam->RefPartP_m(0)); // 21
+    this->writeValue(beam->RefPartP_m(1)); // 22
+    this->writeValue(beam->RefPartP_m(2)); // 23
+
+    this->writeValue(beam->get_maxExtent()(0)); // 24
+    this->writeValue(beam->get_maxExtent()(1)); // 25
+    this->writeValue(beam->get_maxExtent()(2)); // 26
+
+    // Write out Courant Snyder parameters.
+    this->writeValue(beam->get_rprms()(0));     // 27
+    this->writeValue(beam->get_rprms()(1));     // 28
+    this->writeValue(beam->get_rprms()(2));     // 29
+
+    // Write out dispersion.
+    this->writeValue(beam->get_Dx());      // 30
+    this->writeValue(beam->get_DDx());     // 31
+    this->writeValue(beam->get_Dy());      // 32
+    this->writeValue(beam->get_DDy());     // 33
+
+    // Write head/reference particle/tail field information.
+    this->writeValue(FDext[0](0));         // 34 B-ref x
+    this->writeValue(FDext[0](1));         // 35 B-ref y
+    this->writeValue(FDext[0](2));         // 36 B-ref z
+
+    this->writeValue(FDext[1](0));         // 37 E-ref x
+    this->writeValue(FDext[1](1));         // 38 E-ref y
+    this->writeValue(FDext[1](2));         // 39 E-ref z
+
+    this->writeValue(beam->getdE());        // 40 dE energy spread
+    this->writeValue(beam->getdT() * 1e9);  // 41 dt time step size
+    this->writeValue(npOutside);            // 42 number of particles outside n*sigma
+
+    if (Ippl::getNodes() == 1 && beam->getLocalNum() > 0) {
+        this->writeValue(beam->R[0](0));        // 43 R0_x
+        this->writeValue(beam->R[0](1));        // 44 R0_y
+        this->writeValue(beam->R[0](2));        // 45 R0_z
+        this->writeValue(beam->P[0](0));        // 46 P0_x
+        this->writeValue(beam->P[0](1));        // 47 P0_y
+        this->writeValue(beam->P[0](2));        // 48 P0_z
+    }
+
+    if (OpalData::getInstance()->isInOPALCyclMode()) {
+        Vector_t halo = beam->get_halo();
+        for (int i = 0; i < 3; ++i)
+            this->writeValue(halo(i));
+        
+        this->writeValue(azimuth);
+    }
+
+    for(size_t i = 0; i < losses.size(); ++ i) {
+        this->writeValue(losses[i].second);
+    }
+    
+    os_m << std::endl;
+    os_m.close();
+
+    /// %Stop timer.
+    IpplTimings::stopTimer(StatMarkerTimer_m);
+}
diff --git a/src/Structure/StatWriter.h b/src/Structure/StatWriter.h
new file mode 100644
index 0000000000000000000000000000000000000000..3eef8ea74c4dc3922535bf1e533305b89825fdb9
--- /dev/null
+++ b/src/Structure/StatWriter.h
@@ -0,0 +1,14 @@
+#ifndef OPAL_STAT_WRITER_H
+#define OPAL_STAT_WRITER_H
+
+#include "SDDSWriter.h"
+
+class StatWriter : public SDDSWriter {
+
+private:
+    void writeHeader();
+    
+    void writeData(PartBunchBase<double, 3> *beam);
+};
+
+#endif