Index: src/Parser/TremoloParser.cpp
===================================================================
--- src/Parser/TremoloParser.cpp	(revision 2affd161725660cecea8012a86f29f70ce24015a)
+++ src/Parser/TremoloParser.cpp	(revision 4795cd4131f40e0290a563607407aa1d61af6e2a)
@@ -57,4 +57,5 @@
 #include <algorithm>
 #include <boost/bind.hpp>
+#include <boost/function.hpp>
 #include <boost/lambda/lambda.hpp>
 #include <boost/lexical_cast.hpp>
@@ -362,4 +363,98 @@
 }
 
+template <class T>
+T NoOp(const atom * const)
+{
+  return T();
+}
+
+template <class T>
+void writeEntryFromAdditionalAtomData_ifpresent(
+    std::map<const atomId_t, TremoloAtomInfoContainer> &_additionalAtomData,
+    std::map<TremoloKey::atomDataKey, std::string> &_knownKeyNames,
+    std::ostream* _file,
+    const atom * const _currentAtom,
+    const TremoloKey::atomDataKey _currentField,
+    const typename boost::function<T (const atom * const)> _getter)
+{
+  if (_additionalAtomData.count(_currentAtom->getId())) {
+    LOG(3, "Writing for type " << _knownKeyNames[_currentField] << ": "
+        << _additionalAtomData[_currentAtom->getId()].get(_currentField));
+    *_file << _additionalAtomData[_currentAtom->getId()].get(_currentField);
+  } else if (_additionalAtomData.count(_currentAtom->GetTrueFather()->getId())) {
+    LOG(3, "Writing for type " << _knownKeyNames[_currentField] << " stuff from father: "
+        << _additionalAtomData[_currentAtom->GetTrueFather()->getId()].get(_currentField));
+    *_file << _additionalAtomData[_currentAtom->GetTrueFather()->getId()].get(_currentField);
+  } else {
+    LOG(3, "Writing for type " << _knownKeyNames[_currentField] << " its default value: "
+        << _getter(_currentAtom));
+    *_file << _getter(_currentAtom);
+  }
+  *_file << "\t";
+}
+
+template <class T>
+void writeAdditionalAtomDataEntry(
+    std::map<const atomId_t, TremoloAtomInfoContainer> &_additionalAtomData,
+    std::map<TremoloKey::atomDataKey, std::string> &_knownKeyNames,
+    TremoloAtomInfoContainer &_defaultAdditionalData,
+    std::ostream* _file,
+    const atom * const _currentAtom,
+    const TremoloKey::atomDataKey _currentField)
+{
+  if (_additionalAtomData.count(_currentAtom->getId())) {
+    LOG(3, "Writing for type " << _knownKeyNames[_currentField] << ": "
+        << _additionalAtomData[_currentAtom->getId()].get(_currentField));
+    *_file << _additionalAtomData[_currentAtom->getId()].get(_currentField);
+  } else if (_additionalAtomData.count(_currentAtom->GetTrueFather()->getId())) {
+    LOG(3, "Writing for type " << _knownKeyNames[_currentField] << " stuff from father: "
+        << _additionalAtomData[_currentAtom->GetTrueFather()->getId()].get(_currentField));
+    *_file << _additionalAtomData[_currentAtom->GetTrueFather()->getId()].get(_currentField);
+  } else {
+    LOG(3, "Writing for type " << _knownKeyNames[_currentField] << " its default value: "
+        << _defaultAdditionalData.get(_currentField));
+    *_file << _defaultAdditionalData.get(_currentField);
+  }
+  *_file << "\t";
+}
+
+template <class T>
+void writeEntryFromAdditionalAtomData_ifnotempty(
+    std::map<const atomId_t, TremoloAtomInfoContainer> &_additionalAtomData,
+    std::map<TremoloKey::atomDataKey, std::string> &_knownKeyNames,
+    TremoloAtomInfoContainer &_defaultAdditionalData,
+    std::ostream* _file,
+    const atom * const _currentAtom,
+    const TremoloKey::atomDataKey _currentField,
+    const typename boost::function<T (const atom * const)> _getter)
+{
+  if (_additionalAtomData.count(_currentAtom->getId())) {
+    if (_additionalAtomData[_currentAtom->getId()].get(_currentField) != "-") {
+      LOG(3, "Writing for type " << _knownKeyNames[_currentField] << ": "
+          << _additionalAtomData[_currentAtom->getId()].get(_currentField));
+      *_file << _additionalAtomData[_currentAtom->getId()].get(_currentField);
+    } else {
+      LOG(3, "Writing for type " << _knownKeyNames[_currentField] << " default value: "
+          << _getter(_currentAtom));
+      *_file << _getter(_currentAtom);
+    }
+  } else if (_additionalAtomData.count(_currentAtom->GetTrueFather()->getId())) {
+    if (_additionalAtomData[_currentAtom->GetTrueFather()->getId()].get(_currentField) != "-") {
+      LOG(3, "Writing for type " << _knownKeyNames[_currentField] << " stuff from father: "
+          << _additionalAtomData[_currentAtom->GetTrueFather()->getId()].get(_currentField));
+      *_file << _additionalAtomData[_currentAtom->GetTrueFather()->getId()].get(_currentField);
+    } else {
+      LOG(3, "Writing for type " << _knownKeyNames[_currentField] << " default value from father: "
+          << _getter(_currentAtom->GetTrueFather()));
+      *_file << _getter(_currentAtom->GetTrueFather());
+    }
+  } else {
+    LOG(3, "Writing for type " << _knownKeyNames[_currentField] << " its default value: "
+        << _getter(_currentAtom));
+    *_file << _getter(_currentAtom);
+  }
+  *_file << "\t";
+}
+
 /**
  * Writes one line of tremolo-formatted data to the provided stream.
@@ -401,24 +496,12 @@
         break;
       case TremoloKey::type :
-        if (additionalAtomData.count(currentAtom->getId())) {
-          if (additionalAtomData[currentAtom->getId()].get(currentField) != "-") {
-            LOG(3, "Writing for type " << knownKeyNames[currentField] << ": " << additionalAtomData[currentAtom->getId()].get(currentField));
-            *file << additionalAtomData[currentAtom->getId()].get(currentField) << "\t";
-          } else {
-            LOG(3, "Writing for type " << knownKeyNames[currentField] << " default value: " << currentAtom->getType()->getSymbol());
-            *file << currentAtom->getType()->getSymbol() << "\t";
-          }
-        } else if (additionalAtomData.count(currentAtom->GetTrueFather()->getId())) {
-          if (additionalAtomData[currentAtom->GetTrueFather()->getId()].get(currentField) != "-") {
-            LOG(3, "Writing for type " << knownKeyNames[currentField] << " stuff from father: " << additionalAtomData[currentAtom->GetTrueFather()->getId()].get(currentField));
-            *file << additionalAtomData[currentAtom->GetTrueFather()->getId()].get(currentField) << "\t";
-          } else {
-            LOG(3, "Writing for type " << knownKeyNames[currentField] << " default value from father: " << currentAtom->GetTrueFather()->getType()->getSymbol());
-            *file << currentAtom->GetTrueFather()->getType()->getSymbol() << "\t";
-          }
-        } else {
-          LOG(3, "Writing for type " << knownKeyNames[currentField] << " its default value: " << currentAtom->getType()->getSymbol());
-          *file << currentAtom->getType()->getSymbol() << "\t";
-        }
+        writeEntryFromAdditionalAtomData_ifnotempty<std::string>(
+            additionalAtomData,
+            knownKeyNames,
+            defaultAdditionalData,
+            file,
+            currentAtom,
+            currentField,
+            boost::bind(&element::getSymbol, boost::bind(&AtomInfo::getType, _1)));
         break;
       case TremoloKey::Id :
@@ -453,32 +536,24 @@
       case TremoloKey::charge :
         if (currentAtom->getCharge() == 0.) {
-          if (additionalAtomData.count(currentAtom->getId())) {
-            LOG(3, "Writing for type " << knownKeyNames[currentField] << ": " << additionalAtomData[currentAtom->getId()].get(currentField));
-            *file << additionalAtomData[currentAtom->getId()].get(currentField);
-          } else if (additionalAtomData.count(currentAtom->GetTrueFather()->getId())) {
-            LOG(3, "Writing for type " << knownKeyNames[currentField] << " stuff from father: " << additionalAtomData[currentAtom->GetTrueFather()->getId()].get(currentField));
-            *file << additionalAtomData[currentAtom->GetTrueFather()->getId()].get(currentField);
-          } else {
-            LOG(3, "Writing for type " << knownKeyNames[currentField] << " AtomInfo::charge : " << currentAtom->getCharge());
-            *file << currentAtom->getCharge();
-          }
+          writeEntryFromAdditionalAtomData_ifpresent<double>(
+              additionalAtomData,
+              knownKeyNames,
+              file,
+              currentAtom,
+              currentField,
+              boost::bind(&AtomInfo::getCharge, _1));
         } else {
           LOG(3, "Writing for type " << knownKeyNames[currentField] << " AtomInfo::charge : " << currentAtom->getCharge());
-          *file << currentAtom->getCharge();
+          *file << currentAtom->getCharge() << "\t";
         }
-        *file << "\t";
         break;
       default :
-        if (additionalAtomData.count(currentAtom->getId())) {
-          LOG(3, "Writing for type " << knownKeyNames[currentField] << ": " << additionalAtomData[currentAtom->getId()].get(currentField));
-          *file << additionalAtomData[currentAtom->getId()].get(currentField);
-        } else if (additionalAtomData.count(currentAtom->GetTrueFather()->getId())) {
-          LOG(3, "Writing for type " << knownKeyNames[currentField] << " stuff from father: " << additionalAtomData[currentAtom->GetTrueFather()->getId()].get(currentField));
-          *file << additionalAtomData[currentAtom->GetTrueFather()->getId()].get(currentField);
-        } else {
-          LOG(3, "Writing for type " << knownKeyNames[currentField] << " the default: " << defaultAdditionalData.get(currentField));
-          *file << defaultAdditionalData.get(currentField);
-        }
-        *file << "\t";
+        writeAdditionalAtomDataEntry<std::string>(
+            additionalAtomData,
+            knownKeyNames,
+            defaultAdditionalData,
+            file,
+            currentAtom,
+            currentField);
         break;
     }
