diff --git a/transition_machine/include/ActionSet.hpp b/transition_machine/include/ActionSet.hpp
index 17471a33b5ec3f7c2d1a47ac06abbb80ab0c33ba..1d1c842ed0947fcb2698c9429baaf6758c973b04 100644
--- a/transition_machine/include/ActionSet.hpp
+++ b/transition_machine/include/ActionSet.hpp
@@ -32,6 +32,8 @@ class ActionSet
   ///
   /// If it is the case, the default action is the first element of the vector actions.\n When getAction is called with an unknown name, the default action is returned.\n If an ActionSet is dynamic, it cannot have a default action.
   bool hasDefaultAction;
+  /// @brief Index of the default action, if it has one.
+  int defaultActionIndex;
 
   public :
 
@@ -64,6 +66,10 @@ class ActionSet
   ///
   /// @return A pointer to the Action.
   Action * getAction(const std::string & name);
+  /// @brief Get a pointer to the default Action object.
+  ///
+  /// @return A pointer to the default Action.
+  Action * getDefaultAction();
   /// @brief Get the number of actions contained in this set.
   ///
   /// @return The number of actions in this set.
diff --git a/transition_machine/src/ActionSet.cpp b/transition_machine/src/ActionSet.cpp
index 2a0b527773779025e6557a0bd197daebb687e054..934562b5d8da26fb5235c30596208b366d8b9d48 100644
--- a/transition_machine/src/ActionSet.cpp
+++ b/transition_machine/src/ActionSet.cpp
@@ -14,17 +14,31 @@ ActionSet::ActionSet(const std::string & filename, bool isDynamic)
 
     char buffer[1024];
 
-    if(fscanf(fd, "Default : %[^\n]\n", buffer) == 1)
+    while (true)
     {
-      str2index[buffer] = actions.size();
-      actions.emplace_back(buffer);
-      hasDefaultAction = true;
-    }
-
-    while(fscanf(fd, "%[^\n]\n", buffer) == 1)
-    {
-      str2index[buffer] = actions.size();
-      actions.emplace_back(buffer);
+      if (fscanf(fd, "Default : %[^\n]\n", buffer) == 1)
+      {
+        if (hasDefaultAction)
+        {
+          fprintf(stderr, "ERROR (%s) : \'%s\' has more than 1 default action. Aborting.\n", ERRINFO, filename.c_str());
+          exit(1);
+        }
+
+        str2index[buffer] = actions.size();
+        actions.emplace_back(buffer);
+        hasDefaultAction = true;
+        defaultActionIndex = actions.size()-1;
+        continue;
+      }
+
+      if (fscanf(fd, "%[^\n]\n", buffer) == 1)
+      {
+        str2index[buffer] = actions.size();
+        actions.emplace_back(buffer);
+        continue;
+      }
+
+      break;
     }
 
     this->name = getFilenameFromPath(filename);
@@ -52,9 +66,6 @@ int ActionSet::getActionIndex(const std::string & name)
 
   if(!isDynamic)
   {
-    if(hasDefaultAction)
-      return 0;
-
     fprintf(stderr, "ERROR (%s) : unknown action \'%s\'. Aborting.\n", ERRINFO, name.c_str());
     printForDebug(stderr);
 
@@ -86,6 +97,17 @@ Action * ActionSet::getAction(const std::string & name)
   return &actions[getActionIndex(name)];
 }
 
+Action * ActionSet::getDefaultAction()
+{
+  if (!hasDefaultAction)
+  {
+    fprintf(stderr, "ERROR (%s) : requested default action in ActionSet \'%s\'. Aborting.\n", ERRINFO, name.c_str());
+    exit(1);
+  }
+
+  return &actions[defaultActionIndex];
+}
+
 unsigned int ActionSet::size()
 {
   return actions.size();
diff --git a/transition_machine/src/Classifier.cpp b/transition_machine/src/Classifier.cpp
index 337291ae768c0dd23d91b4d329418f78c44e6dd9..f68f1cc7e60f9c68cfd0acb217f8e2d2574297a6 100644
--- a/transition_machine/src/Classifier.cpp
+++ b/transition_machine/src/Classifier.cpp
@@ -279,15 +279,14 @@ std::vector<std::string> Classifier::getZeroCostActions(Config & config)
       result.emplace_back(a.name);
 
   if (result.empty() && as->hasDefaultAction)
-    result.emplace_back(as->getActionName(0));
+    result.emplace_back(as->getDefaultAction()->name);
 
   return result;
 }
 
 std::string Classifier::getDefaultAction() const
 {
-  if (as->hasDefaultAction)
-    return as->getActionName(0);
+  return as->getDefaultAction()->name;
 
   return std::string();
 }
diff --git a/transition_machine/src/Oracle.cpp b/transition_machine/src/Oracle.cpp
index a20e397329a71193da9c2a215739f3edf673d98c..8ba8eb23fb5f5431f73e602511d14f8629ed5b25 100644
--- a/transition_machine/src/Oracle.cpp
+++ b/transition_machine/src/Oracle.cpp
@@ -584,6 +584,8 @@ void Oracle::createDatabase()
   },
   [](Config & c, Oracle *, const std::string & action)
   {
+    bool hasId = c.hasTape("ID");
+
     auto & labels = c.getTape("LABEL");
     auto & govs = c.getTape("GOV");
     auto & eos = c.getTape(ProgramParameters::sequenceDelimiterTape);
@@ -592,8 +594,10 @@ void Oracle::createDatabase()
     int stackHead = c.stackEmpty() ? 0 : c.stackTop();
     int stackGov = 0;
     bool stackNoGov = false;
-    try {stackGov = stackHead + std::stoi(govs.getRef(stackHead-head));}
-      catch (std::exception &){stackNoGov = true;}
+    try 
+    {
+      stackGov = stackHead + std::stoi(govs.getRef(stackHead-head));
+    } catch (std::exception &){stackNoGov = true;}
     int headGov = 0;
     bool headNoGov = false;
     try {headGov = head + std::stoi(govs.getRef(0));}
@@ -671,7 +675,7 @@ void Oracle::createDatabase()
     {
       if (stackNoGov)
         return 0;
-      if (stackGov == 0)
+      if (stackGov == stackHead)
         cost++;
 
       for (int i = head; i <= sentenceEnd; i++)
@@ -683,14 +687,17 @@ void Oracle::createDatabase()
           cost++;
       }
 
-      return eos.getRef(stackHead-head) != ProgramParameters::sequenceDelimiter ? cost : cost+1;
+      if (eos.getRef(stackHead-head) != ProgramParameters::sequenceDelimiter)
+        return cost;
+
+      return cost+1;
     }
     else if (parts[0] == "LEFT")
     {
       if (stackNoGov)
         return 0;
 
-      if (stackGov == 0)
+      if (stackGov == stackHead)
         cost++;
 
       if (eos.getRef(stackHead-head) == ProgramParameters::sequenceDelimiter)
@@ -708,7 +715,13 @@ void Oracle::createDatabase()
       if (stackGov != head)
         cost++;
 
-      return parts.size() == 1 || labels.getRef(stackHead-head) == parts[1] ? cost : cost+1;
+      if (parts.size() == 1)
+        return cost;
+
+      if (labels.getRef(stackHead-head) == parts[1])
+        return cost;
+
+      return cost+1;
     }
     else if (parts[0] == "RIGHT")
     {
@@ -733,7 +746,12 @@ void Oracle::createDatabase()
         if (headGov == i)
           cost++;
 
-      return parts.size() == 1 || labels.getRef(0) == parts[1] ? cost : cost+1;
+      if (parts.size() == 1)
+        return cost;
+      if (labels.getRef(0) == parts[1])
+        return cost;
+
+      return cost+1;
     }
     else if (parts[0] == "EOS")
     {