diff --git a/maca_common/include/LimitedArray.hpp b/maca_common/include/LimitedArray.hpp
index c6dcda01018b73bace679b4f7049dd90ee798fb8..738cd16888ad0d20f8bc36140d165608082b961e 100644
--- a/maca_common/include/LimitedArray.hpp
+++ b/maca_common/include/LimitedArray.hpp
@@ -13,16 +13,18 @@ class LimitedArray
 {
   private :
 
-  std::vector<T> data;
+  std::vector< std::pair<T,bool> > data;
   int nbElements;
   int lastElementDataIndex;
   int lastElementRealIndex;
+  T mask;
 
   public :
 
-  LimitedArray(unsigned int limit) : data(limit)
+  LimitedArray(unsigned int limit, const T & mask) : data(limit)
   {
     clear();
+    this->mask = mask;
   }
 
   void clear()
@@ -44,17 +46,21 @@ class LimitedArray
 
     lastElementRealIndex++;
 
-    data[lastElementDataIndex] = elem;
+    data[lastElementDataIndex].first = elem;
   }
 
   const T & get(unsigned int index) const
   {
-    return data[index % data.size()];
+    if (data[index % data.size()].second)
+      return mask;
+
+    return data[index % data.size()].first;
   }
 
   void set(unsigned int index, const T & value)
   {
-    data[index % data.size()] = value;
+    data[index % data.size()].first = value;
+    data[index % data.size()].second = false;
   }
 
   int getLastIndex() const
@@ -70,7 +76,7 @@ class LimitedArray
   void printForDebug(FILE * out) const
   {
     for (int i = 0; i < std::min(nbElements,(int)data.size()); i++)
-      fprintf(out, "<%s>", data[i].c_str());
+      fprintf(out, "<%s>", data[i].first.c_str());
     fprintf(out, "\n");
   }
 
diff --git a/transition_machine/src/ActionBank.cpp b/transition_machine/src/ActionBank.cpp
index 4737d48da91aaaf467973b06f89334fc75d5cf9c..ed373d825deda3c980211a0f0478c50820a1b75f 100644
--- a/transition_machine/src/ActionBank.cpp
+++ b/transition_machine/src/ActionBank.cpp
@@ -401,7 +401,8 @@ std::vector<Action::BasicAction> ActionBank::str2sequence(const std::string & na
         }
         auto deps = split(ba.data, '+');
         for (auto s : deps)
-          simpleBufferWrite(c, "GOV", "", std::stoi(s));
+          if (!s.empty())
+            simpleBufferWrite(c, "GOV", "", std::stoi(s));
         ba.data.clear();
       };
     auto appliable = [](Config & c, Action::BasicAction &)
@@ -453,7 +454,9 @@ std::vector<Action::BasicAction> ActionBank::str2sequence(const std::string & na
         }
         auto deps = split(ba.data, '+');
         for (auto & dep : deps)
-          simpleBufferWrite(c, "LABEL", "", std::stoi(dep));
+          if (!dep.empty())
+            simpleBufferWrite(c, "LABEL", "", std::stoi(dep));
+        ba.data.clear();
       };
     auto appliable2 = [](Config & c, Action::BasicAction &)
       {
@@ -480,7 +483,9 @@ std::vector<Action::BasicAction> ActionBank::str2sequence(const std::string & na
       {
         auto elems = split(ba.data);
         for (auto elem : elems)
-          c.stackPush(std::stoi(elem));
+          if (!elem.empty())
+            c.stackPush(std::stoi(elem));
+        ba.data.clear();
       };
     auto appliable4 = [](Config & c, Action::BasicAction &)
       {
@@ -530,6 +535,11 @@ std::vector<Action::BasicAction> ActionBank::str2sequence(const std::string & na
 
             while (true)
             {
+              if (c.pastActions.empty())
+              {
+                fprintf(stderr, "ERROR (%s) : trying to undo action while pastActions is empty. Aborting.\n", ERRINFO);
+                exit(1);
+              }
               auto a = c.pastActions.pop();
               if (ProgramParameters::debug)
                 fprintf(stderr, "Undoing... <%s><%s>\n", a.first.c_str(), a.second.name.c_str());
diff --git a/transition_machine/src/Config.cpp b/transition_machine/src/Config.cpp
index bbd18c032eab5dd748e6775f05e0ca8ba8a0dbd3..f212b77be9800d68f76effdc5cff6d98d60f5bda 100644
--- a/transition_machine/src/Config.cpp
+++ b/transition_machine/src/Config.cpp
@@ -5,7 +5,7 @@
 #include "Action.hpp"
 #include "ProgramOutput.hpp"
 
-Config::Config(BD & bd, const std::string inputFilename) : bd(bd), hashHistory(30), pastActions(100)
+Config::Config(BD & bd, const std::string inputFilename) : bd(bd), hashHistory(90), pastActions(100)
 {
   this->outputFile = nullptr;
   this->stackHistory = -1;
@@ -36,7 +36,7 @@ Config::Config(const Config & other) : bd(other.bd), hashHistory(other.hashHisto
   this->file.reset(new File(*other.file.get()));
 }
 
-Config::Tape::Tape(const std::string & name, bool isKnown) : ref(ProgramParameters::readSize*4+1), hyp(ProgramParameters::readSize*4+1)
+Config::Tape::Tape(const std::string & name, bool isKnown) : ref(ProgramParameters::readSize*4+1, Dict::unknownValueStr), hyp(ProgramParameters::readSize*4+1, std::make_pair(Dict::unknownValueStr, 0.0))
 {
   this->head = 0;
   this->name = name;