diff --git a/alib2algo/src/rte/convert/ToPostfixPushdownAutomaton.cpp b/alib2algo/src/rte/convert/ToPostfixPushdownAutomaton.cpp
index 1a827093ef68cff967bda9cbc7d66d75fba8c806..68d7b2630ec755194ce8e905f48bff3a4ac430e3 100644
--- a/alib2algo/src/rte/convert/ToPostfixPushdownAutomaton.cpp
+++ b/alib2algo/src/rte/convert/ToPostfixPushdownAutomaton.cpp
@@ -13,11 +13,11 @@ namespace rte {
 
 namespace convert {
 
-automaton::NPDA < > ToPostfixPushdownAutomaton::convert ( const rte::FormalRTE < > & rte ) {
+automaton::NPDA < ext::variant < common::ranked_symbol < DefaultSymbolType, DefaultRankType >, DefaultSymbolType >, DefaultEpsilonType, ext::variant < common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType >, DefaultSymbolType >, char > ToPostfixPushdownAutomaton::convert ( const rte::FormalRTE < > & rte ) {
 	return ToPostfixPushdownAutomatonGlushkovNaive::convert ( rte );
 }
 
-auto ToAutomatonFormalRegExp = registration::AbstractRegister < ToPostfixPushdownAutomaton, automaton::NPDA < >, const rte::FormalRTE < > & > ( ToPostfixPushdownAutomaton::convert );
+auto ToAutomatonFormalRegExp = registration::AbstractRegister < ToPostfixPushdownAutomaton, automaton::NPDA < ext::variant < common::ranked_symbol < DefaultSymbolType, DefaultRankType >, DefaultSymbolType >, DefaultEpsilonType, ext::variant < common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType >, DefaultSymbolType >, char >, const rte::FormalRTE < > & > ( ToPostfixPushdownAutomaton::convert );
 
 } /* namespace convert */
 
diff --git a/alib2algo/src/rte/convert/ToPostfixPushdownAutomaton.h b/alib2algo/src/rte/convert/ToPostfixPushdownAutomaton.h
index 6006cadcb546bb337b808d386932f71534475279..59af9171a2bcd4e59fca4e989f2cef47d1b9b9de 100644
--- a/alib2algo/src/rte/convert/ToPostfixPushdownAutomaton.h
+++ b/alib2algo/src/rte/convert/ToPostfixPushdownAutomaton.h
@@ -15,13 +15,23 @@ namespace rte {
 
 namespace convert {
 
+/**
+ * Converts a tree regular expression to a pushdown automaton.
+ *
+ * This class serves as a "default wrapper" over the conversion of RTE to PDA. It delegates to the conversion algorithm similar to glushkov construction.
+ *
+ * @sa rte::convert::ToPostfixPushdownAutomatonGlushkov
+ */
 class ToPostfixPushdownAutomaton {
 public:
 	/**
-	 * Performs conversion.
-	 * @return PDA equivalent to original regular rte expression reading linearized postfix tree
+	 * Implements conversion of the tree regular expressions to a pushdown automaton usign Glushkov's method of neighbours.
+	 *
+	 * \param regexp the regexp to convert
+	 *
+	 * \return PDA equivalent to original regular rte expression reading linearized postfix tree
 	 */
-	static automaton::NPDA < > convert ( const rte::FormalRTE < > & rte );
+	static automaton::NPDA < ext::variant < common::ranked_symbol < DefaultSymbolType, DefaultRankType >, DefaultSymbolType >, DefaultEpsilonType, ext::variant < common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType >, DefaultSymbolType >, char > convert ( const rte::FormalRTE < > & rte );
 
 };
 
diff --git a/alib2algo/src/rte/convert/ToPostfixPushdownAutomatonGlushkov.cpp b/alib2algo/src/rte/convert/ToPostfixPushdownAutomatonGlushkov.cpp
index 0e11e6a1deed28bc7df772b053ae8e9c91899614..4d5a0f3f8b11a4f8fcb47f8874eec7f5bc3c4b2c 100644
--- a/alib2algo/src/rte/convert/ToPostfixPushdownAutomatonGlushkov.cpp
+++ b/alib2algo/src/rte/convert/ToPostfixPushdownAutomatonGlushkov.cpp
@@ -21,69 +21,76 @@ namespace rte {
 
 namespace convert {
 
+inline common::ranked_symbol < DefaultSymbolType, DefaultRankType > phi ( const common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType > & symbol ) {
+	return common::ranked_symbol < DefaultSymbolType, DefaultRankType > ( symbol.getSymbol ( ).first, symbol.getRank ( ) );
+}
+
+/*ext::vector < ext::variant < common::ranked_symbol < DefaultSymbolType, DefaultRankType >, DefaultSymbolType > > phi ( const ext::vector < common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType > > & follow ) {
+	return ext::transform < ext::variant < common::ranked_symbol < DefaultSymbolType, DefaultRankType >, DefaultSymbolType > > ( follow, []( const common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType > & symbol ) { return phi ( symbol ); } );
+}*/
+
 template < class SymbolType, class RankType >
-bool ToPostfixPushdownAutomatonGlushkov::isSubstSymbolPresent ( const ext::set < common::ranked_symbol < SymbolType, RankType > > & container, const TAlphabet < SymbolType, RankType > & substAlphabet ) {
-	ext::vector < common::ranked_symbol < > > intersection;
+bool ToPostfixPushdownAutomatonGlushkov::isSubstSymbolPresent ( const ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > & container, const TAlphabet < SymbolType, RankType > & substAlphabet ) {
+	ext::vector < common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType > > intersection;
 	std::set_intersection ( container.begin ( ), container.end ( ), substAlphabet.begin ( ), substAlphabet.end ( ), std::back_inserter ( intersection ) );
 	return intersection.size ( ) > 0;
 }
 
 template < class SymbolType, class RankType >
-automaton::NPDA < SymbolType, DefaultEpsilonType, ext::variant < alphabet::BottomOfTheStackSymbol, ext::set < common::ranked_symbol < SymbolType, RankType > > >, DefaultStateType >
-ToPostfixPushdownAutomatonGlushkov::convert ( const rte::FormalRTE < > & rte ) {
+automaton::NPDA < ext::variant < common::ranked_symbol < SymbolType, RankType >, alphabet::EndSymbol >, DefaultEpsilonType, ext::variant < alphabet::BottomOfTheStackSymbol, ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > >, char > ToPostfixPushdownAutomatonGlushkov::convert ( const rte::FormalRTE < > & rte ) {
 
 	 // step 1; index RTE
-	rte::FormalRTE < > indexedRTE = rte::GlushkovIndexate::index ( rte );
+	rte::FormalRTE < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType > indexedRTE = rte::GlushkovIndexate::index ( rte );
 
 	 // step 2; compute:
 	 // - first set
-	const ext::set < common::ranked_symbol < > > firstSet = rte::GlushkovFirst::first ( indexedRTE );
+	const ext::set < common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType > > firstSet = rte::GlushkovFirst::first ( indexedRTE );
 
 	 // - follow set for every element of (non-indexed) RTE alphabet element
-	const ext::map < const rte::FormalRTEElement < SymbolType, RankType >*, ext::map < common::ranked_symbol < >, ext::set < common::ranked_symbol < > > > > substMapTree = GlushkovSubstitutionMap::substMap ( indexedRTE );
-	ext::map < common::ranked_symbol < >, ext::set < GlushkovFollow::TFollowTuple < SymbolType, RankType > > > followSet;
+	const ext::map < const rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType >*, ext::map < common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType >, ext::set < common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType > > > > substMapTree = GlushkovSubstitutionMap::substMap ( indexedRTE );
+	ext::map < common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType >, ext::set < GlushkovFollow::TFollowTuple < SymbolType, RankType > > > followSet;
 
-	for ( const common::ranked_symbol < > & symbol : indexedRTE.getAlphabet ( ) )
+	for ( const common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > & symbol : indexedRTE.getAlphabet ( ) )
 		followSet.insert ( std::make_pair ( symbol, rte::GlushkovFollow::follow ( indexedRTE, symbol, substMapTree ) ) );
 
 	/* check for exceptions -> there must be NO substitution symbol in first set */
-	if ( isSubstSymbolPresent ( firstSet, rte.getSubstitutionAlphabet ( ) ) )
+	if ( isSubstSymbolPresent ( firstSet, indexedRTE.getSubstitutionAlphabet ( ) ) )
 		throw exception::CommonException ( "GlushkovRTE: Substitution symbol appeared in the first set" );
 	/* check end */
 
 	/* check for exceptions -> there must be NO substitution symbol in follow sets */
-	for ( const std::pair < const common::ranked_symbol < SymbolType, RankType >, ext::set < GlushkovFollow::TFollowTuple < SymbolType, RankType > > > & kv : followSet )
+	for ( const std::pair < const common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType >, ext::set < GlushkovFollow::TFollowTuple < SymbolType, RankType > > > & kv : followSet )
 		for ( const GlushkovFollow::TFollowTuple < SymbolType, RankType > & followTuple : kv.second ) // TFollowTuple = vector < set < ranked_symbol > >
-			for ( const ext::set < common::ranked_symbol < SymbolType, RankType > > & followTupleElem : followTuple )
-				if ( isSubstSymbolPresent ( followTupleElem, rte.getSubstitutionAlphabet ( ) ) )
+			for ( const ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > & followTupleElem : followTuple )
+				if ( isSubstSymbolPresent ( followTupleElem, indexedRTE.getSubstitutionAlphabet ( ) ) )
 					throw exception::CommonException ( "GlushkovRTE: Substitution symbol appeared in a follow set" );
 	/* check end */
 
 	 // step 3; create PDA (w/o transitions yet) and initialize input alphabet = (non-indexed) RTE alphabet and END symbol
-	DefaultStateType q = DefaultStateType ( 'q' );
-	DefaultStateType f = DefaultStateType ( 'f' );
+	char q = 'q';
+	char f = 'f';
 
-	auto BotS = ext::variant < alphabet::BottomOfTheStackSymbol, ext::set < common::ranked_symbol < SymbolType, RankType > > >::template from < alphabet::BottomOfTheStackSymbol > ( );
-	automaton::NPDA < SymbolType, DefaultEpsilonType, ext::variant < alphabet::BottomOfTheStackSymbol, ext::set < common::ranked_symbol < SymbolType, RankType > > >, DefaultStateType > automaton ( q, BotS );
+	auto BotS = ext::variant < alphabet::BottomOfTheStackSymbol, ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > >::template from < alphabet::BottomOfTheStackSymbol > ( );
+	automaton::NPDA < ext::variant < common::ranked_symbol < SymbolType, RankType >, alphabet::EndSymbol >, DefaultEpsilonType, ext::variant < alphabet::BottomOfTheStackSymbol, ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > >, char > automaton ( q, BotS );
 
 	automaton.addState ( f );
 	automaton.addFinalState ( f );
 
-	for ( const common::ranked_symbol < > & symbol : rte.getAlphabet ( ) )
-		automaton.addInputSymbol ( symbol.getSymbol ( ) );
+	for ( const common::ranked_symbol < SymbolType, RankType > & symbol : rte.getAlphabet ( ) )
+		automaton.addInputSymbol ( symbol );
 
-	automaton.addInputSymbol ( alphabet::EndSymbol::instance < DefaultSymbolType > ( ) );
+	automaton.addInputSymbol ( alphabet::EndSymbol { } );
 
 	// step 4; create pushdown store alphabet;
 
 	// simple
-	for ( const common::ranked_symbol < > & symb : indexedRTE.getAlphabet ( ) )
-		automaton.addPushdownStoreSymbol ( ext::variant < alphabet::BottomOfTheStackSymbol, ext::set < common::ranked_symbol < SymbolType, RankType > > > ( { symb } ) );
+	for ( const common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > & symb : indexedRTE.getAlphabet ( ) )
+		automaton.addPushdownStoreSymbol ( ext::variant < alphabet::BottomOfTheStackSymbol, ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > > ( { symb } ) );
 
 	// complex
-	for ( const std::pair < const rte::FormalRTEElement < SymbolType, RankType >* const, ext::map < common::ranked_symbol < >, ext::set < common::ranked_symbol < > > > > & kv : substMapTree ) {
-		if ( dynamic_cast < const rte::FormalRTESymbolSubst < SymbolType, RankType > * const > ( kv.first ) ) { 
-			for ( const std::pair < common::ranked_symbol < >, ext::set < common::ranked_symbol < > > > & kv2 : kv.second ) {
+	for ( const std::pair < const rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType >* const, ext::map < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType >, ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > > > & kv : substMapTree ) {
+		if ( dynamic_cast < const rte::FormalRTESymbolSubst < ext::pair < SymbolType, unsigned >, RankType > * const > ( kv.first ) ) {
+			for ( const std::pair < common::ranked_symbol < ext::pair < SymbolType, unsigned > >, ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned > > > > & kv2 : kv.second ) {
 				automaton.addPushdownStoreSymbol ( kv2.second );
 			}
 		}
@@ -117,7 +124,7 @@ ToPostfixPushdownAutomatonGlushkov::convert ( const rte::FormalRTE < > & rte ) {
 		common::Streams::err << std::endl;
 
 		// ext::map < common::ranked_symbol < >, ext::set < GlushkovFollow::TFollowTuple < SymbolType, RankType > > > followSet;
-		for ( const std::pair < const common::ranked_symbol < >, ext::set < GlushkovFollow::TFollowTuple < SymbolType, RankType > > >& kv : followSet ) {
+		for ( const std::pair < const common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType >, ext::set < GlushkovFollow::TFollowTuple < SymbolType, RankType > > >& kv : followSet ) {
 			common::Streams::err << "Follow(RTE, " << kv.first << "):" << std::endl;
 
 			if ( kv.second.empty ( ) )
@@ -125,7 +132,7 @@ ToPostfixPushdownAutomatonGlushkov::convert ( const rte::FormalRTE < > & rte ) {
 
 			for ( const GlushkovFollow::TFollowTuple < SymbolType, RankType > & followTuple : kv.second ) { // TFollowTuple = vector < set < ranked_symbol > >
 				common::Streams::err << " \t - FollowTuple:" << std::endl;
-				for ( const ext::set < common::ranked_symbol < > > & child : followTuple )
+				for ( const ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > & child : followTuple )
 					common::Streams::err << "\t\t - " << child << std::endl;
 
 				common::Streams::err << std::endl;
@@ -147,51 +154,51 @@ ToPostfixPushdownAutomatonGlushkov::convert ( const rte::FormalRTE < > & rte ) {
 
 	/* TRANSITIONS */
 	// Pattern 3 and 2
-	for ( const common::ranked_symbol < > & symb : indexedRTE.getAlphabet ( ) ) {
+	for ( const common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType > & symb : indexedRTE.getAlphabet ( ) ) {
 		if ( symb.getRank ( ) == unsigned ( 0 ) ) {
-			ext::vector < ext::variant < alphabet::BottomOfTheStackSymbol, ext::set < common::ranked_symbol < SymbolType, RankType > > > > push;
-			push.push_back( ext::set < common::ranked_symbol < SymbolType, RankType > > { symb } );
+			ext::vector < ext::variant < alphabet::BottomOfTheStackSymbol, ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > > > push;
+			push.push_back ( ext::variant < alphabet::BottomOfTheStackSymbol, ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > > ( { symb } ) );
 
 			if ( common::GlobalData::verbose ) {
-				common::Streams::err << "Transition 3: " << rte::GlushkovIndexate::getSymbolFromGlushkovPair ( symb ).getSymbol ( ) << " | " << std::endl <<
+				common::Streams::err << "Transition 3: " << symb.getSymbol ( ).first << " | " << std::endl <<
 					"\t" << "[]" << std::endl <<
 					"\t ->" << std::endl <<
 					"\t" << push << std::endl << std::endl;
 			}
-			automaton.addTransition ( q, rte::GlushkovIndexate::getSymbolFromGlushkovPair ( symb ).getSymbol ( ), { }, q, push );
+			automaton.addTransition ( q, phi ( symb ), { }, q, push );
 		} else {
 			for ( const GlushkovFollow::TFollowTuple < SymbolType, RankType > & followTuple : followSet [ symb ] ) { //tuple = vector < set < symb > >
-				ext::vector < ext::variant < alphabet::BottomOfTheStackSymbol, ext::set < common::ranked_symbol < SymbolType, RankType > > > > pop, push;
+				ext::vector < ext::variant < alphabet::BottomOfTheStackSymbol, ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > > > pop, push;
 
 				for ( const auto & e : followTuple )
 				   pop.push_back ( e );
 				std::reverse ( pop.begin ( ), pop.end ( ) );
 
-				push.push_back( ext::set < common::ranked_symbol < SymbolType, RankType > > { symb } );
+				push.push_back( ext::variant < alphabet::BottomOfTheStackSymbol, ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > > ( { symb } ) );
 
 				if ( common::GlobalData::verbose ) {
-					common::Streams::err << "Transition 2: " << rte::GlushkovIndexate::getSymbolFromGlushkovPair ( symb ).getSymbol ( ) << " | " << std::endl <<
+					common::Streams::err << "Transition 2: " << symb.getSymbol ( ).first << " | " << std::endl <<
 						"\t" << pop << std::endl <<
 						"\t ->" << std::endl <<
 						"\t" << push << std::endl << std::endl;
 				}
-				automaton.addTransition ( q, rte::GlushkovIndexate::getSymbolFromGlushkovPair ( symb ).getSymbol ( ), pop, q, push );
+				automaton.addTransition ( q, phi ( symb ), pop, q, push );
 			}
 		}
 	}
 
 	// Pattern 1
-	for ( const common::ranked_symbol < > & symb : indexedRTE.getAlphabet ( ) ) {
-		for ( const std::pair < const rte::FormalRTEElement < SymbolType, RankType >* const, ext::map < common::ranked_symbol < >, ext::set < common::ranked_symbol < > > > > & kv : substMapTree ) {
-			if ( dynamic_cast < const rte::FormalRTESymbolSubst < SymbolType, RankType > * const > ( kv.first ) == nullptr ) // not a SubstSymbol node
+	for ( const common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType > & symb : indexedRTE.getAlphabet ( ) ) {
+		for ( const std::pair < const rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType >* const, ext::map < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType >, ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > > > & kv : substMapTree ) {
+			if ( dynamic_cast < const rte::FormalRTESymbolSubst < ext::pair < SymbolType, unsigned >, RankType > * const > ( kv.first ) == nullptr ) // not a SubstSymbol node
 				continue;
 
-			for ( const std::pair < common::ranked_symbol < >, ext::set < common::ranked_symbol < > > > & kv2 : kv.second ) {
-				if ( kv2.second.count ( symb ) == 0 ) 
+			for ( const std::pair < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType >, ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > > & kv2 : kv.second ) {
+				if ( kv2.second.count ( symb ) == 0 )
 					continue;
 
 				for ( const GlushkovFollow::TFollowTuple < SymbolType, RankType > & symbFollowTuple : followSet [ symb ] ) {
-					ext::vector < ext::variant < alphabet::BottomOfTheStackSymbol, ext::set < common::ranked_symbol < SymbolType, RankType > > > > pop, push;
+					ext::vector < ext::variant < alphabet::BottomOfTheStackSymbol, ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > > > pop, push;
 
 					if ( ( size_t ) symb.getRank ( ) > 0 ) {
 						for ( const auto & e : symbFollowTuple )
@@ -202,24 +209,24 @@ ToPostfixPushdownAutomatonGlushkov::convert ( const rte::FormalRTE < > & rte ) {
 					push.push_back( kv2.second );
 
 					if ( common::GlobalData::verbose ) {
-						common::Streams::err << "Transition 1" << ( pop.empty() ? "a" : "b" ) <<  ": " << rte::GlushkovIndexate::getSymbolFromGlushkovPair ( symb ).getSymbol ( ) << " | " << std::endl <<
+						common::Streams::err << "Transition 1" << ( pop.empty() ? "a" : "b" ) <<  ": " << symb.getSymbol ( ).first << " | " << std::endl <<
 							"\t" << pop << std::endl <<
 							"\t ->" << std::endl <<
 							"\t" << push << std::endl << std::endl;
 					}
 
-					automaton.addTransition ( q, rte::GlushkovIndexate::getSymbolFromGlushkovPair ( symb ).getSymbol ( ), pop, q, push );
+					automaton.addTransition ( q, phi ( symb ), pop, q, push );
 				}
 			}
 		}
 	}
 
 	// Final
-	for ( const common::ranked_symbol < > & symb : firstSet ) {
-		ext::vector < ext::variant < alphabet::BottomOfTheStackSymbol, ext::set < common::ranked_symbol < SymbolType, RankType > > > > pop;
-		pop.push_back ( ext::set < common::ranked_symbol < SymbolType, RankType > > { symb } );
+	for ( const common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > & symb : firstSet ) {
+		ext::vector < ext::variant < alphabet::BottomOfTheStackSymbol, ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > > > pop;
+		pop.push_back ( ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > { symb } );
 		pop.push_back ( BotS );
-		automaton.addTransition ( q, alphabet::EndSymbol::instance < DefaultSymbolType > ( ), pop, f, { } );
+		automaton.addTransition ( q, alphabet::EndSymbol ( ), pop, f, { } );
 	}
 	/* TRANSITIONS END */
 
@@ -227,7 +234,7 @@ ToPostfixPushdownAutomatonGlushkov::convert ( const rte::FormalRTE < > & rte ) {
 }
 
 auto ToPostfixPushdownAutomatonGlushkovFormalRTE = registration::AbstractRegister < ToPostfixPushdownAutomatonGlushkov,
-			automaton::NPDA < DefaultSymbolType, DefaultEpsilonType, ext::variant < alphabet::BottomOfTheStackSymbol, ext::set < common::ranked_symbol < object::Object, unsigned > > >, DefaultStateType >,
+			automaton::NPDA < ext::variant < common::ranked_symbol < DefaultSymbolType, DefaultRankType >, alphabet::EndSymbol >, DefaultEpsilonType, ext::variant < alphabet::BottomOfTheStackSymbol, ext::set < common::ranked_symbol < ext::pair < object::Object, unsigned >, unsigned > > >, char >,
 			const rte::FormalRTE < > & > ( ToPostfixPushdownAutomatonGlushkov::convert );
 
 } /* namespace convert */
diff --git a/alib2algo/src/rte/convert/ToPostfixPushdownAutomatonGlushkov.h b/alib2algo/src/rte/convert/ToPostfixPushdownAutomatonGlushkov.h
index 5edc33f74f65de2e7ce0dd045567f7adc76321bf..a0a9387336087aa5170b81eb97ae2c3cc2122a9a 100644
--- a/alib2algo/src/rte/convert/ToPostfixPushdownAutomatonGlushkov.h
+++ b/alib2algo/src/rte/convert/ToPostfixPushdownAutomatonGlushkov.h
@@ -16,6 +16,7 @@
 #include <alib/set>
 
 #include <alphabet/BottomOfTheStackSymbol.h>
+#include <alphabet/EndSymbol.h>
 
 namespace rte {
 
@@ -23,6 +24,7 @@ namespace convert {
 
 /**
  * Converts regular tree expression to real-time height-deterministic pda
+ *
  * Source: Master Thesis, Pecka Tomas, CTU FIT, 2016, chapter 4.2
  */
 class ToPostfixPushdownAutomatonGlushkov {
@@ -30,21 +32,26 @@ private:
 	// --------------------------------------------------------------------
 
 	template < class SymbolType, class RankType >
-	using TAlphabet = ext::set < common::ranked_symbol < SymbolType, RankType > >;
+	using TAlphabet = ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > >;
 
 	// --------------------------------------------------------------------
 
 	template < class SymbolType, class RankType >
-	static bool isSubstSymbolPresent ( const ext::set < common::ranked_symbol < SymbolType, RankType > > & container, const TAlphabet < SymbolType, RankType > & substAlphabet );
+	static bool isSubstSymbolPresent ( const ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > & container, const TAlphabet < SymbolType, RankType > & substAlphabet );
 
 public:
 	/**
-	 * Performs conversion.
-	 * @param re Original regular tree expression.
-	 * @return rhNPDA equivalent to original regular expression.
+	 * Implements conversion of the regular tree expressions to a real-time height-deterministic pushdown automaton usign algorithm similar to Glushkov's method of neighbours.
+	 *
+	 * \tparam SymbolType the type of symbols in the regular expression
+	 * \tparam RankType the type of symbol ranks in the regular expression
+	 *
+	 * \param rte the converted regexp to convert
+	 *
+	 * \return real-time height-determinitic pushdown automaton accepting the language described by the original regular tree expression
 	 */
 	template < class SymbolType, class RankType >
-	static automaton::NPDA < SymbolType, DefaultEpsilonType, ext::variant < alphabet::BottomOfTheStackSymbol, ext::set < common::ranked_symbol < SymbolType, RankType > > >, DefaultStateType > convert ( const rte::FormalRTE < > & rte );
+	static automaton::NPDA < ext::variant < common::ranked_symbol < SymbolType, RankType >, alphabet::EndSymbol >, DefaultEpsilonType, ext::variant < alphabet::BottomOfTheStackSymbol, ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > >, char > convert ( const rte::FormalRTE < > & rte );
 };
 
 } /* namespace convert */
diff --git a/alib2algo/src/rte/convert/ToPostfixPushdownAutomatonGlushkovNaive.cpp b/alib2algo/src/rte/convert/ToPostfixPushdownAutomatonGlushkovNaive.cpp
index fd25e1808b666b2bc21ffaba101db4dc9cf72b29..0b49beb96a2c89e68730a71b65d98e6b26bbf035 100644
--- a/alib2algo/src/rte/convert/ToPostfixPushdownAutomatonGlushkovNaive.cpp
+++ b/alib2algo/src/rte/convert/ToPostfixPushdownAutomatonGlushkovNaive.cpp
@@ -22,58 +22,62 @@ namespace rte {
 
 namespace convert {
 
-ext::vector < DefaultSymbolType > phi ( const ext::vector < common::ranked_symbol < > > & follow ) {
-	return ext::transform < DefaultSymbolType > ( follow, []( const common::ranked_symbol < > & symbol ) { return DefaultSymbolType ( symbol ); } );
+inline common::ranked_symbol < DefaultSymbolType, DefaultRankType > phi ( const common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType > & symbol ) {
+	return common::ranked_symbol < DefaultSymbolType, DefaultRankType > ( symbol.getSymbol ( ).first, symbol.getRank ( ) );
 }
 
-bool isSubstSymbolPresent ( const ext::set < common::ranked_symbol < > > & container, const ext::set < common::ranked_symbol < > > & substAlphabet ) {
-	ext::vector < common::ranked_symbol < > > intersection;
+/*ext::vector < ext::variant < common::ranked_symbol < DefaultSymbolType, DefaultRankType >, DefaultSymbolType > > phi ( const ext::vector < common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType > > & follow ) {
+	return ext::transform < ext::variant < common::ranked_symbol < DefaultSymbolType, DefaultRankType >, DefaultSymbolType > > ( follow, []( const common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType > & symbol ) { return phi ( symbol ); } );
+}*/
+
+bool isSubstSymbolPresent ( const ext::set < common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType > > & container, const ext::set < common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType > > & substAlphabet ) {
+	ext::vector < common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType > > intersection;
 	std::set_intersection ( container.begin ( ), container.end ( ), substAlphabet.begin ( ), substAlphabet.end ( ), std::back_inserter ( intersection ) );
 	return intersection.size ( ) > 0;
 }
 
-automaton::NPDA < > ToPostfixPushdownAutomatonGlushkovNaive::convert ( const rte::FormalRTE < > & rte ) {
+automaton::NPDA < ext::variant < common::ranked_symbol < DefaultSymbolType, DefaultRankType >, DefaultSymbolType >, DefaultEpsilonType, ext::variant < common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType >, DefaultSymbolType >, char > ToPostfixPushdownAutomatonGlushkovNaive::convert ( const rte::FormalRTE < > & rte ) {
 
 	 // step 1; index RTE
-	rte::FormalRTE < > indexedRTE = rte::GlushkovIndexate::index ( rte );
+	rte::FormalRTE < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType > indexedRTE = rte::GlushkovIndexate::index ( rte );
 
 	 // step 2; compute:
 	 // - first set
-	const ext::set < common::ranked_symbol < > > firstSet = rte::GlushkovFirst::first ( indexedRTE );
+	const ext::set < common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType > > firstSet = rte::GlushkovFirst::first ( indexedRTE );
 
 	 // - follow set for every element of (non-indexed) RTE alphabet element
-	ext::map < common::ranked_symbol < >, ext::set < ext::vector < common::ranked_symbol < > > > > followSet;
+	ext::map < common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType >, ext::set < ext::vector < common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType > > > > followSet;
 
-	for ( const common::ranked_symbol < > & symbol : indexedRTE.getAlphabet ( ) )
+	for ( const common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType > & symbol : indexedRTE.getAlphabet ( ) )
 		followSet.insert ( std::make_pair ( symbol, rte::GlushkovFollowNaive::follow ( indexedRTE, symbol ) ) );
 
 	 /* check for exceptions -> there must be NO substitution symbol in first or follow sets */
-	if ( isSubstSymbolPresent ( firstSet, rte.getSubstitutionAlphabet ( ) ) )
+	if ( isSubstSymbolPresent ( firstSet, indexedRTE.getSubstitutionAlphabet ( ) ) )
 		throw exception::CommonException ( "GlushkovRTE: Substitution symbol appeared in the first set" );
 
 	for ( const auto & kv : followSet )
 		for ( const auto & followTuple : kv.second )
-			if ( isSubstSymbolPresent ( ext::set < common::ranked_symbol < > > ( followTuple.begin ( ), followTuple.end ( ) ), rte.getSubstitutionAlphabet ( ) ) )
+			if ( isSubstSymbolPresent ( ext::set < common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType > > ( followTuple.begin ( ), followTuple.end ( ) ), indexedRTE.getSubstitutionAlphabet ( ) ) )
 				throw exception::CommonException ( "GlushkovRTE: Substitution symbol appeared in a follow set" );
 
 	/* check end */
 
 	 // step 3; create PDA (w/o transitions yet) and initialize input alphabet = (non-indexed) RTE alphabet and END symbol
-	DefaultStateType q = DefaultStateType ( 'q' );
-	DefaultStateType f = DefaultStateType ( 'f' );
-	automaton::NPDA < > automaton ( q, alphabet::BottomOfTheStackSymbol::instance < DefaultSymbolType > ( ) );
+	char q = 'q';
+	char f = 'f';
+	automaton::NPDA < ext::variant < common::ranked_symbol < DefaultSymbolType, DefaultRankType >, DefaultSymbolType >, DefaultEpsilonType, ext::variant < common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType >, DefaultSymbolType >, char > automaton ( q, alphabet::BottomOfTheStackSymbol::instance < DefaultSymbolType > ( ) );
 
 	automaton.addState ( f );
 	automaton.addFinalState ( f );
 
-	for ( const common::ranked_symbol < > & symbol : rte.getAlphabet ( ) )
-		automaton.addInputSymbol ( symbol.getSymbol ( ) );
+	for ( const common::ranked_symbol < DefaultSymbolType, DefaultRankType > & symbol : rte.getAlphabet ( ) )
+		automaton.addInputSymbol ( symbol );
 
 	automaton.addInputSymbol ( alphabet::EndSymbol::instance < DefaultSymbolType > ( ) );
 
 	 // step 4; create pushdown store alphabet; it consists of elements of indexed RTE alphabet and BotS symbol
-	for ( const common::ranked_symbol < > & symb : indexedRTE.getAlphabet ( ) )
-		automaton.addPushdownStoreSymbol ( DefaultSymbolType ( symb ) );
+	for ( const common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType > & symb : indexedRTE.getAlphabet ( ) )
+		automaton.addPushdownStoreSymbol ( symb );
 
 	 /* DEBUG */
 	if ( common::GlobalData::verbose ) {
@@ -109,21 +113,20 @@ automaton::NPDA < > ToPostfixPushdownAutomatonGlushkovNaive::convert ( const rte
 	}
 	/* DEBUG END */
 
-	for ( const common::ranked_symbol < > & symb : indexedRTE.getAlphabet ( ) ) {
-		if ( symb.getRank ( ) == unsigned ( 0 ) )
-			automaton.addTransition ( q, rte::GlushkovIndexate::getSymbolFromGlushkovPair ( symb ).getSymbol ( ), { }, q, { DefaultSymbolType ( symb ) } );
+	for ( const common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType > & symb : indexedRTE.getAlphabet ( ) ) {
+		if ( symb.getRank ( ) == 0 )
+			automaton.addTransition ( q, phi ( symb ), { }, q, { symb } );
 		else
-			for ( const ext::vector < common::ranked_symbol < > > & follow : followSet[symb] ) {
-				ext::vector < DefaultSymbolType > fstring = phi ( follow );
-				std::reverse ( fstring.begin ( ), fstring.end ( ) );
-				automaton.addTransition ( q, rte::GlushkovIndexate::getSymbolFromGlushkovPair ( symb ).getSymbol ( ), fstring, q, { DefaultSymbolType ( symb ) } );
+			for ( const ext::vector < common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType > > & follow : followSet[symb] ) {
+				ext::vector < ext::variant < common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType >, DefaultSymbolType > > fstring ( follow.rbegin ( ), follow.rend ( ) );
+				automaton.addTransition ( q, phi ( symb ), fstring, q, { symb } );
 			}
 
 	}
 
-	for ( const common::ranked_symbol < > & symb : firstSet ) {
-		ext::vector < DefaultSymbolType > pop;
-		pop.push_back ( DefaultSymbolType ( symb ) );
+	for ( const common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType > & symb : firstSet ) {
+		ext::vector < ext::variant < common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType >, DefaultSymbolType > > pop;
+		pop.push_back ( symb );
 		pop.push_back ( alphabet::BottomOfTheStackSymbol::instance < DefaultSymbolType > ( ) );
 		automaton.addTransition ( q, alphabet::EndSymbol::instance < DefaultSymbolType > ( ), pop, f, { } );
 	}
@@ -131,7 +134,7 @@ automaton::NPDA < > ToPostfixPushdownAutomatonGlushkovNaive::convert ( const rte
 	return automaton;
 }
 
-auto ToPostfixPushdownAutomatonGlushkovNaiveFormalRTE = registration::AbstractRegister < ToPostfixPushdownAutomatonGlushkovNaive, automaton::NPDA < >, const rte::FormalRTE < > & > ( ToPostfixPushdownAutomatonGlushkovNaive::convert );
+auto ToPostfixPushdownAutomatonGlushkovNaiveFormalRTE = registration::AbstractRegister < ToPostfixPushdownAutomatonGlushkovNaive, automaton::NPDA < ext::variant < common::ranked_symbol < DefaultSymbolType, DefaultRankType >, DefaultSymbolType >, DefaultEpsilonType, ext::variant < common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType >, DefaultSymbolType >, char >, const rte::FormalRTE < > & > ( ToPostfixPushdownAutomatonGlushkovNaive::convert );
 
 } /* namespace convert */
 
diff --git a/alib2algo/src/rte/convert/ToPostfixPushdownAutomatonGlushkovNaive.h b/alib2algo/src/rte/convert/ToPostfixPushdownAutomatonGlushkovNaive.h
index 129616eb09f49b5f35b838a7e53ed56fe6623628..340091f8b98ed288d15757150b9d56bed153f007 100644
--- a/alib2algo/src/rte/convert/ToPostfixPushdownAutomatonGlushkovNaive.h
+++ b/alib2algo/src/rte/convert/ToPostfixPushdownAutomatonGlushkovNaive.h
@@ -19,16 +19,19 @@ namespace convert {
 
 /**
  * Converts regular tree expression to real-time height-deterministic pda
+ *
  * Source: Master Thesis, Pecka Tomas, CTU FIT, 2016, chapter 4.2
  */
 class ToPostfixPushdownAutomatonGlushkovNaive {
 public:
 	/**
-	 * Performs conversion.
-	 * @param re Original regular tree expression.
-	 * @return rhNPDA equivalent to original regular expression.
+	 * Implements conversion of the regular tree expressions to a real-time height-deterministic pushdown automaton usign algorithm similar to Glushkov's method of neighbours.
+	 *
+	 * \param rte the converted regexp to convert
+	 *
+	 * \return real-time height-determinitic pushdown automaton accepting the language described by the original regular tree expression
 	 */
-	static automaton::NPDA < > convert ( const rte::FormalRTE < > & rte );
+	static automaton::NPDA < ext::variant < common::ranked_symbol < DefaultSymbolType, DefaultRankType >, DefaultSymbolType >, DefaultEpsilonType, ext::variant < common::ranked_symbol < ext::pair < DefaultSymbolType, unsigned >, DefaultRankType >, DefaultSymbolType >, char > convert ( const rte::FormalRTE < > & rte );
 };
 
 } /* namespace convert */
diff --git a/alib2algo/src/rte/glushkov/GlushkovFollow.h b/alib2algo/src/rte/glushkov/GlushkovFollow.h
index a99cf221cf82a8c5841453cc191d4898b8ec482b..6d14445875695a88da7ac20dc7029f685f6e3523 100644
--- a/alib2algo/src/rte/glushkov/GlushkovFollow.h
+++ b/alib2algo/src/rte/glushkov/GlushkovFollow.h
@@ -27,19 +27,19 @@ class GlushkovFollow {
 public:
 
 	template < class SymbolType, class RankType >
-	using TFollowTuple = ext::vector < ext::set < common::ranked_symbol < SymbolType, RankType > > >;
+	using TFollowTuple = ext::vector < ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > >;
 
 	template < class SymbolType, class RankType >
-	using TAlphabet = ext::set < common::ranked_symbol < SymbolType, RankType > >;
+	using TAlphabet = ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > >;
 
 private:
 	template < class SymbolType, class RankType >
-	using TSubstMap = ext::map < common::ranked_symbol < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > > >;
+	using TSubstMap = ext::map < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType >, ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > >;
 
 	// --------------------------------------------------------------------
 
 	template < class SymbolType, class RankType >
-	static ext::set < TFollowTuple < SymbolType, RankType > > replaceConstants ( const TAlphabet < SymbolType, RankType > & alphabetK, const ext::vector < ext::set < common::ranked_symbol < SymbolType, RankType > > > & follow, const TSubstMap < SymbolType, RankType > & subMap2 );
+	static ext::set < TFollowTuple < SymbolType, RankType > > replaceConstants ( const TAlphabet < SymbolType, RankType > & alphabetK, const ext::vector < ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > > & follow, const TSubstMap < SymbolType, RankType > & subMap2 );
 
 public:
 	/**
@@ -49,37 +49,37 @@ public:
 	 * @return all symbols that can follow specific symbol in word
 	 */
 	template < class SymbolType, class RankType >
-	static ext::set < TFollowTuple < SymbolType, RankType > > follow ( const rte::FormalRTE < SymbolType, RankType > & rte, const common::ranked_symbol < SymbolType, RankType > & symbol, const ext::map < const rte::FormalRTEElement < SymbolType, RankType > *, TSubstMap < SymbolType, RankType > > & substMapTree );
+	static ext::set < TFollowTuple < SymbolType, RankType > > follow ( const rte::FormalRTE < ext::pair < SymbolType, unsigned >, RankType > & rte, const common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > & symbol, const ext::map < const rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > *, TSubstMap < SymbolType, RankType > > & substMapTree );
 
 	template < class SymbolType, class RankType >
 	class Formal {
 	public:
-		static ext::set < TFollowTuple < SymbolType, RankType > > visit ( const rte::FormalRTEElement < SymbolType, RankType > & node, const common::ranked_symbol < SymbolType, RankType > & symbol, const TAlphabet < SymbolType, RankType > & alphabetK, const ext::map < const rte::FormalRTEElement < SymbolType, RankType >*, TSubstMap < SymbolType, RankType > > & substMapTree );
-		static ext::set < TFollowTuple < SymbolType, RankType > > visit ( const rte::FormalRTEAlternation < SymbolType, RankType > & node, const common::ranked_symbol < SymbolType, RankType > & symbol, const TAlphabet < SymbolType, RankType > & alphabetK, const ext::map < const rte::FormalRTEElement < SymbolType, RankType >*, TSubstMap < SymbolType, RankType > > & substMapTree );
-		static ext::set < TFollowTuple < SymbolType, RankType > > visit ( const rte::FormalRTESubstitution < SymbolType, RankType > & node, const common::ranked_symbol < SymbolType, RankType > & symbol, const TAlphabet < SymbolType, RankType > & alphabetK, const ext::map < const rte::FormalRTEElement < SymbolType, RankType >*, TSubstMap < SymbolType, RankType > > & substMapTree );
-		static ext::set < TFollowTuple < SymbolType, RankType > > visit ( const rte::FormalRTEIteration < SymbolType, RankType > & node, const common::ranked_symbol < SymbolType, RankType > & symbol, const TAlphabet < SymbolType, RankType > & alphabetK, const ext::map < const rte::FormalRTEElement < SymbolType, RankType >*, TSubstMap < SymbolType, RankType > > & substMapTree );
-		static ext::set < TFollowTuple < SymbolType, RankType > > visit ( const rte::FormalRTESymbolAlphabet < SymbolType, RankType > & node, const common::ranked_symbol < SymbolType, RankType > & symbol, const TAlphabet < SymbolType, RankType > & alphabetK, const ext::map < const rte::FormalRTEElement < SymbolType, RankType >*, TSubstMap < SymbolType, RankType > > & substMapTree );
-		static ext::set < TFollowTuple < SymbolType, RankType > > visit ( const rte::FormalRTESymbolSubst < SymbolType, RankType > & node, const common::ranked_symbol < SymbolType, RankType > & symbol, const TAlphabet < SymbolType, RankType > & alphabetK, const ext::map < const rte::FormalRTEElement < SymbolType, RankType >*, TSubstMap < SymbolType, RankType > > & substMapTree );
-		static ext::set < TFollowTuple < SymbolType, RankType > > visit ( const rte::FormalRTEEmpty < SymbolType, RankType > & node, const common::ranked_symbol < SymbolType, RankType > & symbol, const TAlphabet < SymbolType, RankType > & alphabetK, const ext::map < const rte::FormalRTEElement < SymbolType, RankType >*, TSubstMap < SymbolType, RankType > > & substMapTree );
+		static ext::set < TFollowTuple < SymbolType, RankType > > visit ( const rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > & node, const common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > & symbol, const TAlphabet < SymbolType, RankType > & alphabetK, const ext::map < const rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType >*, TSubstMap < SymbolType, RankType > > & substMapTree );
+		static ext::set < TFollowTuple < SymbolType, RankType > > visit ( const rte::FormalRTEAlternation < ext::pair < SymbolType, unsigned >, RankType > & node, const common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > & symbol, const TAlphabet < SymbolType, RankType > & alphabetK, const ext::map < const rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType >*, TSubstMap < SymbolType, RankType > > & substMapTree );
+		static ext::set < TFollowTuple < SymbolType, RankType > > visit ( const rte::FormalRTESubstitution < ext::pair < SymbolType, unsigned >, RankType > & node, const common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > & symbol, const TAlphabet < SymbolType, RankType > & alphabetK, const ext::map < const rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType >*, TSubstMap < SymbolType, RankType > > & substMapTree );
+		static ext::set < TFollowTuple < SymbolType, RankType > > visit ( const rte::FormalRTEIteration < ext::pair < SymbolType, unsigned >, RankType > & node, const common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > & symbol, const TAlphabet < SymbolType, RankType > & alphabetK, const ext::map < const rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType >*, TSubstMap < SymbolType, RankType > > & substMapTree );
+		static ext::set < TFollowTuple < SymbolType, RankType > > visit ( const rte::FormalRTESymbolAlphabet < ext::pair < SymbolType, unsigned >, RankType > & node, const common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > & symbol, const TAlphabet < SymbolType, RankType > & alphabetK, const ext::map < const rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType >*, TSubstMap < SymbolType, RankType > > & substMapTree );
+		static ext::set < TFollowTuple < SymbolType, RankType > > visit ( const rte::FormalRTESymbolSubst < ext::pair < SymbolType, unsigned >, RankType > & node, const common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > & symbol, const TAlphabet < SymbolType, RankType > & alphabetK, const ext::map < const rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType >*, TSubstMap < SymbolType, RankType > > & substMapTree );
+		static ext::set < TFollowTuple < SymbolType, RankType > > visit ( const rte::FormalRTEEmpty < ext::pair < SymbolType, unsigned >, RankType > & node, const common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > & symbol, const TAlphabet < SymbolType, RankType > & alphabetK, const ext::map < const rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType >*, TSubstMap < SymbolType, RankType > > & substMapTree );
 
 	};
 
 };
 
 template < class SymbolType, class RankType >
-ext::set < GlushkovFollow::TFollowTuple < SymbolType, RankType > > GlushkovFollow::follow ( const rte::FormalRTE < SymbolType, RankType > & rte, const common::ranked_symbol < SymbolType, RankType > & symbol, const ext::map < const rte::FormalRTEElement < SymbolType, RankType > *, TSubstMap < SymbolType, RankType > > & substMapTree ) {
+ext::set < GlushkovFollow::TFollowTuple < SymbolType, RankType > > GlushkovFollow::follow ( const rte::FormalRTE < ext::pair < SymbolType, unsigned >, RankType > & rte, const common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > & symbol, const ext::map < const rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > *, TSubstMap < SymbolType, RankType > > & substMapTree ) {
 	return rte.getRTE ( ).getStructure ( ).template accept < ext::set < TFollowTuple < SymbolType, RankType > >, GlushkovFollow::Formal < SymbolType, RankType > > ( symbol, rte.getSubstitutionAlphabet ( ), substMapTree );
 }
 
 // -----------------------------------------------------------------------------
 
 template < class SymbolType, class RankType >
-ext::set < GlushkovFollow::TFollowTuple < SymbolType, RankType > > GlushkovFollow::replaceConstants ( const TAlphabet < SymbolType, RankType > & alphabetK, const ext::vector < ext::set < common::ranked_symbol < SymbolType, RankType > > > & children, const TSubstMap < SymbolType, RankType > & subMap ) {
+ext::set < GlushkovFollow::TFollowTuple < SymbolType, RankType > > GlushkovFollow::replaceConstants ( const TAlphabet < SymbolType, RankType > & alphabetK, const ext::vector < ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > > & children, const TSubstMap < SymbolType, RankType > & subMap ) {
 	TFollowTuple < SymbolType, RankType > follow;
 
-	for ( const ext::set < common::ranked_symbol < SymbolType, RankType > > & s : children ) {
-		ext::set < common::ranked_symbol < SymbolType, RankType > > processed;
-		for ( const common::ranked_symbol < SymbolType, RankType > & e : s ) {
+	for ( const ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > & s : children ) {
+		ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > processed;
+		for ( const common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > & e : s ) {
 			if ( alphabetK.count ( e ) > 0 )
 				processed.insert ( subMap.at ( e ).begin ( ), subMap.at ( e ).end ( ) );
 			else
@@ -94,7 +94,7 @@ ext::set < GlushkovFollow::TFollowTuple < SymbolType, RankType > > GlushkovFollo
 // -----------------------------------------------------------------------------
 
 template < class SymbolType, class RankType >
-ext::set < GlushkovFollow::TFollowTuple < SymbolType, RankType > > GlushkovFollow::Formal < SymbolType, RankType > ::visit ( const rte::FormalRTEAlternation < SymbolType, RankType > & node, const common::ranked_symbol < SymbolType, RankType > & symbolF, const TAlphabet < SymbolType, RankType > & alphabetK, const ext::map < const rte::FormalRTEElement < SymbolType, RankType >*, TSubstMap < SymbolType, RankType > > & substMapTree ) {
+ext::set < GlushkovFollow::TFollowTuple < SymbolType, RankType > > GlushkovFollow::Formal < SymbolType, RankType > ::visit ( const rte::FormalRTEAlternation < ext::pair < SymbolType, unsigned >, RankType > & node, const common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > & symbolF, const TAlphabet < SymbolType, RankType > & alphabetK, const ext::map < const rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType >*, TSubstMap < SymbolType, RankType > > & substMapTree ) {
 	ext::set < TFollowTuple < SymbolType, RankType > > ret, tmp;
 
 	tmp = node.getLeftElement ( ).template accept < ext::set < TFollowTuple < SymbolType, RankType > >, GlushkovFollow::Formal < SymbolType, RankType > > ( symbolF, alphabetK, substMapTree );
@@ -107,34 +107,34 @@ ext::set < GlushkovFollow::TFollowTuple < SymbolType, RankType > > GlushkovFollo
 }
 
 template < class SymbolType, class RankType >
-ext::set < GlushkovFollow::TFollowTuple < SymbolType, RankType > > GlushkovFollow::Formal < SymbolType, RankType > ::visit ( const rte::FormalRTESubstitution < SymbolType, RankType > & node, const common::ranked_symbol < SymbolType, RankType > & symbolF, const TAlphabet < SymbolType, RankType > & alphabetK, const ext::map < const rte::FormalRTEElement < SymbolType, RankType >*, TSubstMap < SymbolType, RankType > > & substMapTree ) {
+ext::set < GlushkovFollow::TFollowTuple < SymbolType, RankType > > GlushkovFollow::Formal < SymbolType, RankType > ::visit ( const rte::FormalRTESubstitution < ext::pair < SymbolType, unsigned >, RankType > & node, const common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > & symbolF, const TAlphabet < SymbolType, RankType > & alphabetK, const ext::map < const rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType >*, TSubstMap < SymbolType, RankType > > & substMapTree ) {
 	/*
 	 * E sub F
 	 *   1. if symbolF in F subtree, then Follow(F, symbolF);
 	 *   2. if symbolF in E subtree, then Follow(E, symbolF);
 	 */
 
-	if ( node.getLeftElement ( ).template accept < bool, GlushkovPos::Formal < SymbolType, RankType > > ( symbolF ) )
+	if ( node.getLeftElement ( ).template accept < bool, GlushkovPos::Formal < ext::pair < SymbolType, unsigned >, RankType > > ( symbolF ) )
 		return node.getLeftElement ( ).template accept < ext::set < TFollowTuple < SymbolType, RankType > >, GlushkovFollow::Formal < SymbolType, RankType > > ( symbolF, alphabetK, substMapTree );
 	else
 		return node.getRightElement ( ).template accept < ext::set < TFollowTuple < SymbolType, RankType > >, GlushkovFollow::Formal < SymbolType, RankType > > ( symbolF, alphabetK, substMapTree );
 }
 
 template < class SymbolType, class RankType >
-ext::set < GlushkovFollow::TFollowTuple < SymbolType, RankType > > GlushkovFollow::Formal < SymbolType, RankType > ::visit ( const rte::FormalRTEIteration < SymbolType, RankType > & node, const common::ranked_symbol < SymbolType, RankType > & symbolF, const TAlphabet < SymbolType, RankType > & alphabetK, const ext::map < const rte::FormalRTEElement < SymbolType, RankType >*, TSubstMap < SymbolType, RankType > > & substMapTree ) {
+ext::set < GlushkovFollow::TFollowTuple < SymbolType, RankType > > GlushkovFollow::Formal < SymbolType, RankType > ::visit ( const rte::FormalRTEIteration < ext::pair < SymbolType, unsigned >, RankType > & node, const common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > & symbolF, const TAlphabet < SymbolType, RankType > & alphabetK, const ext::map < const rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType >*, TSubstMap < SymbolType, RankType > > & substMapTree ) {
 	return node.getElement ( ).template accept < ext::set < TFollowTuple < SymbolType, RankType > >, GlushkovFollow::Formal < SymbolType, RankType > > ( symbolF, alphabetK, substMapTree );
 }
 
 template < class SymbolType, class RankType >
-ext::set < GlushkovFollow::TFollowTuple < SymbolType, RankType > > GlushkovFollow::Formal < SymbolType, RankType > ::visit ( const rte::FormalRTESymbolAlphabet < SymbolType, RankType > & node, const common::ranked_symbol < SymbolType, RankType > & symbolF, const TAlphabet < SymbolType, RankType > & alphabetK, const ext::map < const rte::FormalRTEElement < SymbolType, RankType >*, TSubstMap < SymbolType, RankType > > & substMapTree ) {
+ext::set < GlushkovFollow::TFollowTuple < SymbolType, RankType > > GlushkovFollow::Formal < SymbolType, RankType > ::visit ( const rte::FormalRTESymbolAlphabet < ext::pair < SymbolType, unsigned >, RankType > & node, const common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > & symbolF, const TAlphabet < SymbolType, RankType > & alphabetK, const ext::map < const rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType >*, TSubstMap < SymbolType, RankType > > & substMapTree ) {
 
 	ext::set < TFollowTuple < SymbolType, RankType > > ret, tmp;
 
 	if ( symbolF == node.getSymbol ( ) ) {
-		ext::vector < ext::set < common::ranked_symbol < SymbolType, RankType > > > children;
+		ext::vector < ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > > children;
 
-		for ( const rte::FormalRTEElement < SymbolType, RankType > & c : node.getElements ( ) )
-			children.push_back ( c.template accept < TAlphabet < SymbolType, RankType >, GlushkovFirst::Formal < SymbolType, RankType > > ( ) );
+		for ( const rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > & c : node.getElements ( ) )
+			children.push_back ( c.template accept < TAlphabet < SymbolType, RankType >, GlushkovFirst::Formal < ext::pair < SymbolType, unsigned >, RankType > > ( ) );
 
 		return replaceConstants ( alphabetK, children, substMapTree.at( & node ));
 	}
@@ -148,12 +148,12 @@ ext::set < GlushkovFollow::TFollowTuple < SymbolType, RankType > > GlushkovFollo
 }
 
 template < class SymbolType, class RankType >
-ext::set < GlushkovFollow::TFollowTuple < SymbolType, RankType > > GlushkovFollow::Formal < SymbolType, RankType > ::visit ( const rte::FormalRTESymbolSubst < SymbolType, RankType > & /* node */, const common::ranked_symbol < SymbolType, RankType > & /* symbol */, const TAlphabet < SymbolType, RankType > & /* alphabetK */, const ext::map < const rte::FormalRTEElement < SymbolType, RankType >*, TSubstMap < SymbolType, RankType > > & /* substMapTree */ ) {
+ext::set < GlushkovFollow::TFollowTuple < SymbolType, RankType > > GlushkovFollow::Formal < SymbolType, RankType > ::visit ( const rte::FormalRTESymbolSubst < ext::pair < SymbolType, unsigned >, RankType > & /* node */, const common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > & /* symbol */, const TAlphabet < SymbolType, RankType > & /* alphabetK */, const ext::map < const rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType >*, TSubstMap < SymbolType, RankType > > & /* substMapTree */ ) {
 	return ext::set < TFollowTuple < SymbolType, RankType > > ( );
 }
 
 template < class SymbolType, class RankType >
-ext::set < GlushkovFollow::TFollowTuple < SymbolType, RankType > > GlushkovFollow::Formal < SymbolType, RankType > ::visit ( const rte::FormalRTEEmpty < SymbolType, RankType > & /* node */, const common::ranked_symbol < SymbolType, RankType > & /* symbol */, const TAlphabet < SymbolType, RankType > & /* alphabetK */, const ext::map < const rte::FormalRTEElement < SymbolType, RankType >*, TSubstMap < SymbolType, RankType > > & /* substMapTree */ ) {
+ext::set < GlushkovFollow::TFollowTuple < SymbolType, RankType > > GlushkovFollow::Formal < SymbolType, RankType > ::visit ( const rte::FormalRTEEmpty < ext::pair < SymbolType, unsigned >, RankType > & /* node */, const common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > & /* symbol */, const TAlphabet < SymbolType, RankType > & /* alphabetK */, const ext::map < const rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType >*, TSubstMap < SymbolType, RankType > > & /* substMapTree */ ) {
 	return ext::set < TFollowTuple < SymbolType, RankType > > ( );
 }
 
diff --git a/alib2algo/src/rte/glushkov/GlushkovFollowNaive.h b/alib2algo/src/rte/glushkov/GlushkovFollowNaive.h
index 8dcb7df6d3034ffcf6a395a8c2d3c901488abe79..1dd2d82e59982712f1143d77c79d23f190d34945 100644
--- a/alib2algo/src/rte/glushkov/GlushkovFollowNaive.h
+++ b/alib2algo/src/rte/glushkov/GlushkovFollowNaive.h
@@ -40,7 +40,7 @@ class GlushkovFollowNaive {
 	static void preprocessSubMap ( const TAlphabet < SymbolType, RankType > & alphabetK, TSubstMap < SymbolType, RankType > & subMap );
 
 	template < class SymbolType, class RankType >
-	static ext::vector < ext::vector < common::ranked_symbol < SymbolType, RankType > > > cartesian ( const ext::vector < ext::vector < common::ranked_symbol < SymbolType, RankType > > > & input );
+	static ext::vector < ext::vector < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > > cartesian ( const ext::vector < ext::vector < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > > & input );
 
 	template < class T >
 	static void cartesian_rec ( const ext::vector < ext::vector < T > > & input, ext::vector < ext::vector < T > > & ret, ext::vector < T > & current, size_t depth );
@@ -94,9 +94,9 @@ void GlushkovFollowNaive::cartesian_rec ( const ext::vector < ext::vector < T >
 }
 
 template < class SymbolType, class RankType >
-ext::vector < ext::vector < common::ranked_symbol < SymbolType, RankType > > > GlushkovFollowNaive::cartesian ( const ext::vector < ext::vector < common::ranked_symbol < SymbolType, RankType > > > & input ) {
-	ext::vector < ext::vector < common::ranked_symbol < SymbolType, RankType > > > ret;
-	ext::vector < common::ranked_symbol < SymbolType, RankType > > current ( input.size ( ), common::ranked_symbol < SymbolType, RankType > ( SymbolType ( 0 ), RankType ( 0 ) ) );
+ext::vector < ext::vector < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > > GlushkovFollowNaive::cartesian ( const ext::vector < ext::vector < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > > & input ) {
+	ext::vector < ext::vector < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > > ret;
+	ext::vector < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > current ( input.size ( ), common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > ( ext::make_pair ( SymbolType ( 0 ), 0u ), RankType ( 0 ) ) );
 
 	cartesian_rec ( input, ret, current, 0 );
 
diff --git a/alib2algo/src/rte/glushkov/GlushkovIndexate.cpp b/alib2algo/src/rte/glushkov/GlushkovIndexate.cpp
index ca487d27215bf3523e4aada5828d844c8f9a3b72..e4c919c7a6a5ba0322de729575b01b75545ac717 100644
--- a/alib2algo/src/rte/glushkov/GlushkovIndexate.cpp
+++ b/alib2algo/src/rte/glushkov/GlushkovIndexate.cpp
@@ -5,64 +5,13 @@
  *	  Author: Tomas Pecka
  */
 
-#include <alib/pair>
-
 #include "GlushkovIndexate.h"
 
-#include <rte/formal/FormalRTEElements.h>
 
 namespace rte {
 
 // ----------------------------------------------------------------------------
 
-common::ranked_symbol < > GlushkovIndexate::getSymbolFromGlushkovPair ( const common::ranked_symbol < > & symbol ) {
-	const ext::pair < DefaultSymbolType, DefaultSymbolType > & sps = ( ( const object::AnyObject < ext::pair < DefaultSymbolType, DefaultSymbolType > > & ) symbol.getSymbol ( ).getData ( ) ).getData ( );
-	return common::ranked_symbol < > ( sps.first, symbol.getRank ( ) );
-}
-
-FormalRTE < > GlushkovIndexate::index ( const rte::FormalRTE < > & rte ) {
-	int i = 1;
-
-	return FormalRTE < > ( FormalRTEStructure < DefaultSymbolType, unsigned > ( rte.getRTE ( ).getStructure ( ).accept < ext::ptr_value < rte::FormalRTEElement < DefaultSymbolType, unsigned > >, GlushkovIndexate::Formal > ( i ) ) );
-}
-
-// ----------------------------------------------------------------------------
-
-ext::ptr_value < FormalRTEElement < DefaultSymbolType, unsigned > > GlushkovIndexate::Formal::visit ( const rte::FormalRTESymbolAlphabet < DefaultSymbolType, unsigned > & node, int & i ) {
-	ext::pair < DefaultSymbolType, DefaultSymbolType > sps =  ext::make_pair ( DefaultSymbolType ( node.getSymbol ( ).getSymbol ( ) ), DefaultSymbolType ( i++ ) );
-	ext::ptr_vector < rte::FormalRTEElement < DefaultSymbolType, unsigned > > children;
-	for ( const rte::FormalRTEElement < DefaultSymbolType, unsigned > & e : node.getElements ( ) ) {
-		children.push_back ( ( FormalRTEElement < DefaultSymbolType, unsigned > && ) e.accept < ext::ptr_value < rte::FormalRTEElement < DefaultSymbolType, unsigned > >, GlushkovIndexate::Formal > ( i ) );
-	}
-
-	return ext::ptr_value < FormalRTESymbolAlphabet < DefaultSymbolType, unsigned > > ( FormalRTESymbolAlphabet < DefaultSymbolType, unsigned > ( common::ranked_symbol < > ( DefaultSymbolType ( object::AnyObject < ext::pair < DefaultSymbolType, DefaultSymbolType > > ( sps ) ), node.getSymbol ( ).getRank ( ) ), std::move ( children ) ) );
-}
-
-ext::ptr_value < FormalRTEElement < DefaultSymbolType, unsigned > > GlushkovIndexate::Formal::visit ( const rte::FormalRTESymbolSubst < DefaultSymbolType, unsigned > & node, int & ) {
-	return ext::ptr_value < FormalRTEElement < DefaultSymbolType, unsigned > > ( FormalRTESymbolSubst < DefaultSymbolType, unsigned > ( node ) );
-}
-
-ext::ptr_value < FormalRTEElement < DefaultSymbolType, unsigned > > GlushkovIndexate::Formal::visit ( const rte::FormalRTEAlternation < DefaultSymbolType, unsigned > & node, int & i ) {
-	ext::ptr_value < rte::FormalRTEElement < DefaultSymbolType, unsigned > > left = node.getLeftElement ( ).accept < ext::ptr_value < rte::FormalRTEElement < DefaultSymbolType, unsigned > >, GlushkovIndexate::Formal > ( i );
-	ext::ptr_value < rte::FormalRTEElement < DefaultSymbolType, unsigned > > right = node.getRightElement ( ).accept < ext::ptr_value < rte::FormalRTEElement < DefaultSymbolType, unsigned > >, GlushkovIndexate::Formal > ( i );
-	return ext::ptr_value < FormalRTEElement < DefaultSymbolType, unsigned > > ( FormalRTEAlternation < DefaultSymbolType, unsigned > ( std::move ( left ), std::move ( right ) ) );
-}
-
-ext::ptr_value < FormalRTEElement < DefaultSymbolType, unsigned > > GlushkovIndexate::Formal::visit ( const rte::FormalRTESubstitution < DefaultSymbolType, unsigned > & node, int & i ) {
-	ext::ptr_value < rte::FormalRTEElement < DefaultSymbolType, unsigned > > left = node.getLeftElement ( ).accept < ext::ptr_value < rte::FormalRTEElement < DefaultSymbolType, unsigned > >, GlushkovIndexate::Formal > ( i );
-	ext::ptr_value < rte::FormalRTEElement < DefaultSymbolType, unsigned > > right = node.getRightElement ( ).accept < ext::ptr_value < rte::FormalRTEElement < DefaultSymbolType, unsigned > >, GlushkovIndexate::Formal > ( i );
-	return ext::ptr_value < FormalRTEElement < DefaultSymbolType, unsigned > > ( FormalRTESubstitution < DefaultSymbolType, unsigned > ( std::move ( left ), std::move ( right ), node.getSubstitutionSymbol ( ) ) );
-}
-
-ext::ptr_value < FormalRTEElement < DefaultSymbolType, unsigned > > GlushkovIndexate::Formal::visit ( const rte::FormalRTEIteration < DefaultSymbolType, unsigned > & node, int & i ) {
-	ext::ptr_value < rte::FormalRTEElement < DefaultSymbolType, unsigned > > element = node.getElement ( ).accept < ext::ptr_value < rte::FormalRTEElement < DefaultSymbolType, unsigned > >, GlushkovIndexate::Formal > ( i );
-	return ext::ptr_value < FormalRTEElement < DefaultSymbolType, unsigned > > ( FormalRTEIteration < DefaultSymbolType, unsigned > ( std::move ( element ), node.getSubstitutionSymbol ( ) ) );
-}
-
-ext::ptr_value < FormalRTEElement < DefaultSymbolType, unsigned > > GlushkovIndexate::Formal::visit ( const rte::FormalRTEEmpty < DefaultSymbolType, unsigned > &, int & ) {
-	return ext::ptr_value < FormalRTEElement < DefaultSymbolType, unsigned > > ( FormalRTEEmpty < DefaultSymbolType, unsigned > ( ) );
-}
-
 // ----------------------------------------------------------------------------
 
 } /* namespace rte */
diff --git a/alib2algo/src/rte/glushkov/GlushkovIndexate.h b/alib2algo/src/rte/glushkov/GlushkovIndexate.h
index 5214e5b97a90cfd2dc59fdc4bdd3b2924cb04635..79ceeff486bef74bc16bb73d31b3cf27bde4e20c 100644
--- a/alib2algo/src/rte/glushkov/GlushkovIndexate.h
+++ b/alib2algo/src/rte/glushkov/GlushkovIndexate.h
@@ -9,36 +9,82 @@
 #define RTE_GLUSHKOV_INDEXATE_H_
 
 #include <common/ranked_symbol.hpp>
+#include <alib/pair>
 
 #include <rte/formal/FormalRTE.h>
+#include <rte/formal/FormalRTEElements.h>
 
 namespace rte {
 
 class GlushkovIndexate {
 public:
 	/**
-	 * @param re rte to index
+	 * @param rte rte to index
 	 * @return FormalRTE with indexed elements
 	 */
-	static FormalRTE < > index ( const rte::FormalRTE < > & re );
+	template < class SymbolType, class RankType >
+	static FormalRTE < ext::pair < SymbolType, unsigned >, RankType > index ( const rte::FormalRTE < SymbolType, RankType > & rte ) {
+		unsigned i = 1;
 
-	/**
-	 * @param symbol Glushkov Pair symbol, i.e., SymbolPair of RankedSymbol < > and integer index
-	 * @return RankedSymbol < > from the pair on input
-	 */
-	static common::ranked_symbol < > getSymbolFromGlushkovPair ( const common::ranked_symbol < > & symbol );
+		return FormalRTE < ext::pair < SymbolType, unsigned >, RankType > ( FormalRTEStructure < ext::pair < SymbolType, unsigned >, RankType > ( rte.getRTE ( ).getStructure ( ).template accept < ext::ptr_value < rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > >, GlushkovIndexate::Formal < SymbolType, RankType > > ( i ) ) );
+	}
 
+	template < class SymbolType, class RankType >
 	class Formal {
 	public:
-		static ext::ptr_value < FormalRTEElement < DefaultSymbolType, unsigned > > visit ( const rte::FormalRTEAlternation < DefaultSymbolType, unsigned > & node, int & i );
-		static ext::ptr_value < FormalRTEElement < DefaultSymbolType, unsigned > > visit ( const rte::FormalRTESubstitution < DefaultSymbolType, unsigned > & node, int & i );
-		static ext::ptr_value < FormalRTEElement < DefaultSymbolType, unsigned > > visit ( const rte::FormalRTEIteration < DefaultSymbolType, unsigned > & node, int & i );
-		static ext::ptr_value < FormalRTEElement < DefaultSymbolType, unsigned > > visit ( const rte::FormalRTESymbolAlphabet < DefaultSymbolType, unsigned > & node, int & i );
-		static ext::ptr_value < FormalRTEElement < DefaultSymbolType, unsigned > > visit ( const rte::FormalRTESymbolSubst < DefaultSymbolType, unsigned > & node, int & i );
-		static ext::ptr_value < FormalRTEElement < DefaultSymbolType, unsigned > > visit ( const rte::FormalRTEEmpty < DefaultSymbolType, unsigned > & node, int & i );
+		static ext::ptr_value < FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > > visit ( const rte::FormalRTEAlternation < SymbolType, RankType > & node, unsigned & i );
+		static ext::ptr_value < FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > > visit ( const rte::FormalRTESubstitution < SymbolType, RankType > & node, unsigned & i );
+		static ext::ptr_value < FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > > visit ( const rte::FormalRTEIteration < SymbolType, RankType > & node, unsigned & i );
+		static ext::ptr_value < FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > > visit ( const rte::FormalRTESymbolAlphabet < SymbolType, RankType > & node, unsigned & i );
+		static ext::ptr_value < FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > > visit ( const rte::FormalRTESymbolSubst < SymbolType, RankType > & node, unsigned & i );
+		static ext::ptr_value < FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > > visit ( const rte::FormalRTEEmpty < SymbolType, RankType > & node, unsigned & i );
 	};
+
 };
 
+template < class SymbolType, class RankType >
+ext::ptr_value < FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > > GlushkovIndexate::Formal < SymbolType, RankType >::visit ( const rte::FormalRTESymbolAlphabet < SymbolType, RankType > & node, unsigned & i ) {
+	ext::pair < SymbolType, unsigned > sps = ext::make_pair ( node.getSymbol ( ).getSymbol ( ), i ++ );
+	ext::ptr_vector < rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > > children;
+	for ( const rte::FormalRTEElement < SymbolType, RankType > & e : node.getElements ( ) ) {
+		children.push_back ( ( FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > && ) e.template accept < ext::ptr_value < rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > >, GlushkovIndexate::Formal < SymbolType, RankType > > ( i ) );
+	}
+
+	return ext::ptr_value < FormalRTESymbolAlphabet < ext::pair < SymbolType, unsigned >, RankType > > ( FormalRTESymbolAlphabet < ext::pair < SymbolType, unsigned >, RankType > ( common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > ( sps , node.getSymbol ( ).getRank ( ) ), std::move ( children ) ) );
+}
+
+template < class SymbolType, class RankType >
+ext::ptr_value < FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > > GlushkovIndexate::Formal < SymbolType, RankType >::visit ( const rte::FormalRTESymbolSubst < SymbolType, RankType > & node, unsigned & ) {
+	return ext::ptr_value < FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > > ( FormalRTESymbolSubst < ext::pair < SymbolType, unsigned >, RankType > ( common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > ( ext::make_pair ( node.getSymbol ( ).getSymbol ( ), 0u ), node.getSymbol ( ).getRank ( ) ) ) );
+}
+
+template < class SymbolType, class RankType >
+ext::ptr_value < FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > > GlushkovIndexate::Formal < SymbolType, RankType >::visit ( const rte::FormalRTEAlternation < SymbolType, RankType > & node, unsigned & i ) {
+	ext::ptr_value < rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > > left = node.getLeftElement ( ).template accept < ext::ptr_value < rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > >, GlushkovIndexate::Formal < SymbolType, RankType > > ( i );
+	ext::ptr_value < rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > > right = node.getRightElement ( ).template accept < ext::ptr_value < rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > >, GlushkovIndexate::Formal < SymbolType, RankType > > ( i );
+	return ext::ptr_value < FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > > ( FormalRTEAlternation < ext::pair < SymbolType, unsigned >, RankType > ( std::move ( left ), std::move ( right ) ) );
+}
+
+template < class SymbolType, class RankType >
+ext::ptr_value < FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > > GlushkovIndexate::Formal < SymbolType, RankType >::visit ( const rte::FormalRTESubstitution < SymbolType, RankType > & node, unsigned & i ) {
+	ext::ptr_value < rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > > left = node.getLeftElement ( ).template accept < ext::ptr_value < rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > >, GlushkovIndexate::Formal < SymbolType, RankType > > ( i );
+	ext::ptr_value < rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > > right = node.getRightElement ( ).template accept < ext::ptr_value < rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > >, GlushkovIndexate::Formal < SymbolType, RankType > > ( i );
+	FormalRTESymbolSubst < ext::pair < SymbolType, unsigned >, RankType > substSymbol ( common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > ( ext::make_pair ( node.getSubstitutionSymbol ( ).getSymbol ( ).getSymbol ( ), 0u ), node.getSubstitutionSymbol ( ).getSymbol ( ).getRank ( ) ) );
+	return ext::ptr_value < FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > > ( FormalRTESubstitution < ext::pair < SymbolType, unsigned >, RankType > ( std::move ( left ), std::move ( right ), std::move ( substSymbol ) ) );
+}
+
+template < class SymbolType, class RankType >
+ext::ptr_value < FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > > GlushkovIndexate::Formal < SymbolType, RankType >::visit ( const rte::FormalRTEIteration < SymbolType, RankType > & node, unsigned & i ) {
+	ext::ptr_value < rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > > element = node.getElement ( ).template accept < ext::ptr_value < rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > >, GlushkovIndexate::Formal < SymbolType, RankType > > ( i );
+	FormalRTESymbolSubst < ext::pair < SymbolType, unsigned >, RankType > substSymbol ( common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > ( ext::make_pair ( node.getSubstitutionSymbol ( ).getSymbol ( ).getSymbol ( ), 0u ), node.getSubstitutionSymbol ( ).getSymbol ( ).getRank ( ) ) );
+	return ext::ptr_value < FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > > ( FormalRTEIteration < ext::pair < SymbolType, unsigned >, RankType > ( std::move ( element ), std::move ( substSymbol ) ) );
+}
+
+template < class SymbolType, class RankType >
+ext::ptr_value < FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > > GlushkovIndexate::Formal < SymbolType, RankType >::visit ( const rte::FormalRTEEmpty < SymbolType, RankType > &, unsigned & ) {
+	return ext::ptr_value < FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > > ( FormalRTEEmpty < ext::pair < SymbolType, unsigned >, RankType > ( ) );
+}
+
 } /* namespace rte */
 
 #endif /* RTE_GLUSHKOV_INDEXATE_H_ */
diff --git a/alib2algo/src/rte/glushkov/GlushkovSubstitutionMap.h b/alib2algo/src/rte/glushkov/GlushkovSubstitutionMap.h
index c8ccc895a9e236b13a2835e92fa86489f5bc1f9a..76131dad71fbca70f954bee93ecffbb4f104d1d5 100644
--- a/alib2algo/src/rte/glushkov/GlushkovSubstitutionMap.h
+++ b/alib2algo/src/rte/glushkov/GlushkovSubstitutionMap.h
@@ -25,13 +25,13 @@ class GlushkovSubstitutionMap {
 
 private:
 	template < class SymbolType, class RankType >
-	using TSubstMap = ext::map < common::ranked_symbol < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > > >;
+	using TSubstMap = ext::map < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType >, ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > >;
 
 	template < class SymbolType, class RankType >
-	using TSubstMapTree = ext::map < const rte::FormalRTEElement < SymbolType, RankType >*, TSubstMap < SymbolType, RankType > >;
+	using TSubstMapTree = ext::map < const rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType >*, TSubstMap < SymbolType, RankType > >;
 
 	template < class SymbolType, class RankType >
-	using TAlphabet = ext::set < common::ranked_symbol < SymbolType, RankType > >;
+	using TAlphabet = ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > >;
 
 	// --------------------------------------------------------------------
 
@@ -39,7 +39,7 @@ private:
 	static void preprocessSubMap ( TSubstMap < SymbolType, RankType > & subMap, const TAlphabet < SymbolType, RankType > & alphabetK );
 
 	template < class SymbolType, class RankType >
-	static void subst_symbol_replaces ( ext::map < const rte::FormalRTEElement < SymbolType, RankType > *, TSubstMap < SymbolType, RankType > > & substMapTree, const TAlphabet < SymbolType, RankType > & alphabetK );
+	static void subst_symbol_replaces ( ext::map < const rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > *, TSubstMap < SymbolType, RankType > > & substMapTree, const TAlphabet < SymbolType, RankType > & alphabetK );
 
 public:
 	/**
@@ -47,18 +47,18 @@ public:
 	 * @return subst map for all RTE syntax tree elements
 	 */
 	template < class SymbolType, class RankType >
-	static ext::map < const rte::FormalRTEElement < SymbolType, RankType >*, TSubstMap < SymbolType, RankType > > substMap ( const rte::FormalRTE < SymbolType, RankType > & re );
+	static ext::map < const rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType >*, TSubstMap < SymbolType, RankType > > substMap ( const rte::FormalRTE < ext::pair < SymbolType, unsigned >, RankType > & re );
 
 	template < class SymbolType, class RankType >
 	class Formal {
 	public:
-		static void visit ( const rte::FormalRTEElement < SymbolType, RankType > & node, TSubstMap < SymbolType, RankType > & subM, TSubstMapTree < SymbolType, RankType > & subMapTree );
-		static void visit ( const rte::FormalRTEAlternation < SymbolType, RankType > & node, TSubstMap < SymbolType, RankType > & subM, TSubstMapTree < SymbolType, RankType > & subMapTree );
-		static void visit ( const rte::FormalRTESubstitution < SymbolType, RankType > & node, TSubstMap < SymbolType, RankType > & subM, TSubstMapTree < SymbolType, RankType > & subMapTree );
-		static void visit ( const rte::FormalRTEIteration < SymbolType, RankType > & node, TSubstMap < SymbolType, RankType > & subM, TSubstMapTree < SymbolType, RankType > & subMapTree );
-		static void visit ( const rte::FormalRTESymbolAlphabet < SymbolType, RankType > & node, TSubstMap < SymbolType, RankType > & subM, TSubstMapTree < SymbolType, RankType > & subMapTree );
-		static void visit ( const rte::FormalRTESymbolSubst < SymbolType, RankType > & node, TSubstMap < SymbolType, RankType > & subM, TSubstMapTree < SymbolType, RankType > & subMapTree );
-		static void visit ( const rte::FormalRTEEmpty < SymbolType, RankType > & node, TSubstMap < SymbolType, RankType > & subM, TSubstMapTree < SymbolType, RankType > & subMapTree );
+		static void visit ( const rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > & node, TSubstMap < SymbolType, RankType > & subM, TSubstMapTree < SymbolType, RankType > & subMapTree );
+		static void visit ( const rte::FormalRTEAlternation < ext::pair < SymbolType, unsigned >, RankType > & node, TSubstMap < SymbolType, RankType > & subM, TSubstMapTree < SymbolType, RankType > & subMapTree );
+		static void visit ( const rte::FormalRTESubstitution < ext::pair < SymbolType, unsigned >, RankType > & node, TSubstMap < SymbolType, RankType > & subM, TSubstMapTree < SymbolType, RankType > & subMapTree );
+		static void visit ( const rte::FormalRTEIteration < ext::pair < SymbolType, unsigned >, RankType > & node, TSubstMap < SymbolType, RankType > & subM, TSubstMapTree < SymbolType, RankType > & subMapTree );
+		static void visit ( const rte::FormalRTESymbolAlphabet < ext::pair < SymbolType, unsigned >, RankType > & node, TSubstMap < SymbolType, RankType > & subM, TSubstMapTree < SymbolType, RankType > & subMapTree );
+		static void visit ( const rte::FormalRTESymbolSubst < ext::pair < SymbolType, unsigned >, RankType > & node, TSubstMap < SymbolType, RankType > & subM, TSubstMapTree < SymbolType, RankType > & subMapTree );
+		static void visit ( const rte::FormalRTEEmpty < ext::pair < SymbolType, unsigned >, RankType > & node, TSubstMap < SymbolType, RankType > & subM, TSubstMapTree < SymbolType, RankType > & subMapTree );
 	};
 
 };
@@ -66,8 +66,8 @@ public:
 // -----------------------------------------------------------------------------
 
 template < class SymbolType, class RankType >
-void GlushkovSubstitutionMap::subst_symbol_replaces ( ext::map < const rte::FormalRTEElement < SymbolType, RankType > *, TSubstMap < SymbolType, RankType > > & substMapTree, const TAlphabet < SymbolType, RankType > & alphabetK ) {
-	for ( std::pair < const rte::FormalRTEElement < SymbolType, RankType > * const, TSubstMap < SymbolType, RankType > > & kv : substMapTree ) {
+void GlushkovSubstitutionMap::subst_symbol_replaces ( ext::map < const rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > *, TSubstMap < SymbolType, RankType > > & substMapTree, const TAlphabet < SymbolType, RankType > & alphabetK ) {
+	for ( std::pair < const rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType > * const, TSubstMap < SymbolType, RankType > > & kv : substMapTree ) {
 		preprocessSubMap ( kv.second, alphabetK );
 	}
 }
@@ -80,7 +80,7 @@ void GlushkovSubstitutionMap::subst_symbol_replaces ( ext::map < const rte::Form
 template < class SymbolType, class RankType >
 void GlushkovSubstitutionMap::preprocessSubMap ( TSubstMap < SymbolType, RankType > & subMap, const TAlphabet < SymbolType, RankType > & alphabetK ) {
 	for ( bool change = true; change; change = false )
-		for ( std::pair < const common::ranked_symbol < SymbolType, RankType >, TAlphabet < SymbolType, RankType > > & kv : subMap ) {
+		for ( std::pair < const common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType >, TAlphabet < SymbolType, RankType > > & kv : subMap ) {
 			TAlphabet < SymbolType, RankType > & substSet = kv.second;
 
 			for ( auto eIter = substSet.begin ( ); eIter != substSet.end ( ); ) {
@@ -100,12 +100,12 @@ void GlushkovSubstitutionMap::preprocessSubMap ( TSubstMap < SymbolType, RankTyp
 // -----------------------------------------------------------------------------
 
 template < class SymbolType, class RankType >
-ext::map < const rte::FormalRTEElement < SymbolType, RankType >*, GlushkovSubstitutionMap::TSubstMap < SymbolType, RankType > > GlushkovSubstitutionMap::substMap ( const rte::FormalRTE < SymbolType, RankType > & rte ) {
+ext::map < const rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType >*, GlushkovSubstitutionMap::TSubstMap < SymbolType, RankType > > GlushkovSubstitutionMap::substMap ( const rte::FormalRTE < ext::pair < SymbolType, unsigned >, RankType > & rte ) {
 	TSubstMap < SymbolType, RankType > subMap;
-	ext::map < const rte::FormalRTEElement < SymbolType, RankType >*, TSubstMap  < SymbolType, RankType > > subMapTree;
+	ext::map < const rte::FormalRTEElement < ext::pair < SymbolType, unsigned >, RankType >*, TSubstMap  < SymbolType, RankType > > subMapTree;
 
 	/* Init substitution map, ie \forall a \in K: sub[a] = \emptyset */
-	for ( const common::ranked_symbol < SymbolType, RankType > & ssymb : rte.getSubstitutionAlphabet ( ) )
+	for ( const common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > & ssymb : rte.getSubstitutionAlphabet ( ) )
 		subMap.insert ( std::make_pair ( ssymb, TAlphabet < SymbolType, RankType > { } ) );
 
 	/* recursively compute substMap */
@@ -117,14 +117,14 @@ ext::map < const rte::FormalRTEElement < SymbolType, RankType >*, GlushkovSubsti
 // -----------------------------------------------------------------------------
 
 template < class SymbolType, class RankType >
-void GlushkovSubstitutionMap::Formal < SymbolType, RankType >::visit ( const rte::FormalRTEAlternation < SymbolType, RankType > & node, TSubstMap < SymbolType, RankType > & subMap, TSubstMapTree < SymbolType, RankType > & subMapTree ) {
+void GlushkovSubstitutionMap::Formal < SymbolType, RankType >::visit ( const rte::FormalRTEAlternation < ext::pair < SymbolType, unsigned >, RankType > & node, TSubstMap < SymbolType, RankType > & subMap, TSubstMapTree < SymbolType, RankType > & subMapTree ) {
 	subMapTree.insert ( std::make_pair ( & node, subMap ) );
 	node.getLeftElement ( ).template accept < void, GlushkovSubstitutionMap::Formal < SymbolType, RankType > > ( subMap, subMapTree );
 	node.getRightElement ( ).template accept < void, GlushkovSubstitutionMap::Formal < SymbolType, RankType > > ( subMap, subMapTree );
 }
 
 template < class SymbolType, class RankType >
-void GlushkovSubstitutionMap::Formal < SymbolType, RankType >::visit ( const rte::FormalRTESubstitution < SymbolType, RankType > & node, TSubstMap < SymbolType, RankType > & subMap, TSubstMapTree < SymbolType, RankType > & subMapTree ) {
+void GlushkovSubstitutionMap::Formal < SymbolType, RankType >::visit ( const rte::FormalRTESubstitution < ext::pair < SymbolType, unsigned >, RankType > & node, TSubstMap < SymbolType, RankType > & subMap, TSubstMapTree < SymbolType, RankType > & subMapTree ) {
 	subMapTree.insert ( std::make_pair ( & node, subMap ) );
 
 	// re-init left map
@@ -132,7 +132,7 @@ void GlushkovSubstitutionMap::Formal < SymbolType, RankType >::visit ( const rte
 	auto itMap = subMapLeft.find ( node.getSubstitutionSymbol ( ).getSymbol ( ) );
 	itMap->second.clear ( );
 
-	for ( const auto & s : node.getRightElement ( ).template accept < ext::set < common::ranked_symbol < > >, GlushkovFirst::Formal < SymbolType, RankType > > ( ) )
+	for ( const auto & s : node.getRightElement ( ).template accept < ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > >, GlushkovFirst::Formal < ext::pair < SymbolType, unsigned >, RankType > > ( ) )
 		itMap->second.insert ( s );
 
 	node.getLeftElement ( ).template accept < void, GlushkovSubstitutionMap::Formal < SymbolType, RankType > > ( subMapLeft, subMapTree );
@@ -140,17 +140,17 @@ void GlushkovSubstitutionMap::Formal < SymbolType, RankType >::visit ( const rte
 }
 
 template < class SymbolType, class RankType >
-void GlushkovSubstitutionMap::Formal < SymbolType, RankType >::visit ( const rte::FormalRTEIteration < SymbolType, RankType > & node, TSubstMap < SymbolType, RankType > & subMap, TSubstMapTree < SymbolType, RankType > & subMapTree ) {
+void GlushkovSubstitutionMap::Formal < SymbolType, RankType >::visit ( const rte::FormalRTEIteration < ext::pair < SymbolType, unsigned >, RankType > & node, TSubstMap < SymbolType, RankType > & subMap, TSubstMapTree < SymbolType, RankType > & subMapTree ) {
 	subMapTree.insert ( std::make_pair ( & node, subMap ) );
 
-	for ( const auto & s : node.getElement ( ).template accept < TAlphabet < SymbolType, RankType >, GlushkovFirst::Formal < SymbolType, RankType > > ( ) )
+	for ( const auto & s : node.getElement ( ).template accept < TAlphabet < SymbolType, RankType >, GlushkovFirst::Formal < ext::pair < SymbolType, unsigned >, RankType > > ( ) )
 		subMap[node.getSubstitutionSymbol ( ).getSymbol ( )].insert ( s );
 
 	node.getElement ( ).template accept < void, GlushkovSubstitutionMap::Formal < SymbolType, RankType > > ( subMap, subMapTree );
 }
 
 template < class SymbolType, class RankType >
-void GlushkovSubstitutionMap::Formal < SymbolType, RankType >::visit ( const rte::FormalRTESymbolAlphabet < SymbolType, RankType > & node, TSubstMap < SymbolType, RankType > & subMap, TSubstMapTree < SymbolType, RankType > & subMapTree ) {
+void GlushkovSubstitutionMap::Formal < SymbolType, RankType >::visit ( const rte::FormalRTESymbolAlphabet < ext::pair < SymbolType, unsigned >, RankType > & node, TSubstMap < SymbolType, RankType > & subMap, TSubstMapTree < SymbolType, RankType > & subMapTree ) {
 	subMapTree.insert ( std::make_pair ( & node, subMap ) );
 
 	for ( const auto & c : node.getElements ( ) ) {
@@ -159,12 +159,12 @@ void GlushkovSubstitutionMap::Formal < SymbolType, RankType >::visit ( const rte
 }
 
 template < class SymbolType, class RankType >
-void GlushkovSubstitutionMap::Formal < SymbolType, RankType >::visit ( const rte::FormalRTESymbolSubst < SymbolType, RankType > & node, TSubstMap < SymbolType, RankType > & subMap, TSubstMapTree < SymbolType, RankType > & subMapTree ) {
+void GlushkovSubstitutionMap::Formal < SymbolType, RankType >::visit ( const rte::FormalRTESymbolSubst < ext::pair < SymbolType, unsigned >, RankType > & node, TSubstMap < SymbolType, RankType > & subMap, TSubstMapTree < SymbolType, RankType > & subMapTree ) {
 	subMapTree.insert ( std::make_pair ( & node, subMap ) );
 }
 
 template < class SymbolType, class RankType >
-void GlushkovSubstitutionMap::Formal < SymbolType, RankType >::visit ( const rte::FormalRTEEmpty < SymbolType, RankType > & node, TSubstMap < SymbolType, RankType > & subMap, TSubstMapTree < SymbolType, RankType > & subMapTree ) {
+void GlushkovSubstitutionMap::Formal < SymbolType, RankType >::visit ( const rte::FormalRTEEmpty < ext::pair < SymbolType, unsigned >, RankType > & node, TSubstMap < SymbolType, RankType > & subMap, TSubstMapTree < SymbolType, RankType > & subMapTree ) {
 	subMapTree.insert ( std::make_pair ( & node, subMap ) );
 }
 
diff --git a/alib2data/src/PrimitiveRegistrator.cpp b/alib2data/src/PrimitiveRegistrator.cpp
index 06ea49f93852af41720a617289a777917f295d54..6e33adc20e0ef08bc6782c590acb2bbcfbbd8d33 100644
--- a/alib2data/src/PrimitiveRegistrator.cpp
+++ b/alib2data/src/PrimitiveRegistrator.cpp
@@ -45,6 +45,8 @@ public:
 		core::xmlApi < object::Object >::template registerXmlWriter < ext::set < common::ranked_symbol < object::Object, unsigned > > > ( );
 		core::xmlApi < object::Object >::template registerXmlWriter < ext::pair < ext::set < ext::pair < object::Object, object::Object > >, ext::variant < string::Epsilon < object::Object >, object::Object > > > ( );
 		core::xmlApi < object::Object >::template registerXmlWriter < ext::pair < object::Object, ext::variant < string::Epsilon < object::Object >, object::Object > > > ( );
+		core::xmlApi < object::Object >::template registerXmlWriter < ext::set < common::ranked_symbol < ext::pair < object::Object, unsigned int >, unsigned int > > > ( );
+		core::xmlApi < object::Object >::template registerXmlWriter < common::ranked_symbol < ext::pair < object::Object, unsigned int>, unsigned int > > ( );
 	}
 
 	~PrimitiveRegistrator ( ) {
@@ -56,6 +58,8 @@ public:
 		core::xmlApi < object::Object >::template unregisterXmlWriter < ext::set < common::ranked_symbol < object::Object, unsigned > > > ( );
 		core::xmlApi < object::Object >::template unregisterXmlWriter < ext::pair < ext::set < ext::pair < object::Object, object::Object > >, ext::variant < string::Epsilon < object::Object >, object::Object > > > ( );
 		core::xmlApi < object::Object >::template unregisterXmlWriter < ext::pair < object::Object, ext::variant < string::Epsilon < object::Object >, object::Object > > > ( );
+		core::xmlApi < object::Object >::template unregisterXmlWriter < ext::set < common::ranked_symbol < ext::pair < object::Object, unsigned int >, unsigned int > > > ( );
+		core::xmlApi < object::Object >::template unregisterXmlWriter < common::ranked_symbol < ext::pair < object::Object, unsigned int>, unsigned int > > ( );
 	}
 };
 
diff --git a/examples2/rte/gen_rte1.py b/examples2/rte/gen_rte1.py
index fb17d1948d727edd2336a2228bfa470980ecff18..6bad1a75cfbf59ce6fa26a896001ab8a300085cc 100755
--- a/examples2/rte/gen_rte1.py
+++ b/examples2/rte/gen_rte1.py
@@ -19,22 +19,24 @@ def SCont(depth):
     if depth > MAXD or random.randint(0,1) == 0:
         return
 
-    p('b ')
-    p('a ')
-    p('d ')
+
+    p('d 1 ')
+    p('a 2 ')
     SCont(depth + 1)
+    if depth > MAXD or random.randint(0,1) == 0:
+        p('b 0 ')
+    else:
+        p('c 0 ')
 
 
 def S(depth):
+    SCont(depth + 1)
+
     if depth > MAXD or random.randint(0,1) == 0:
-        p('b ')
+        p('b 0 ')
     else:
-        p('c ')
-
-    SCont(depth + 1)
+        p('c 0 ')
 
 if __name__ == '__main__':
-    p("\"")
+    p('RANKED_TREE ')
     S(1)
-    p('#$')
-    p("\"")
diff --git a/examples2/rte/gen_rte2.py b/examples2/rte/gen_rte2.py
index 73e9bd886d8f21bfde728af12528692b0c429f95..ed239867b9a19ecb3c9c90b5a1ccaf1b4faedb16 100755
--- a/examples2/rte/gen_rte2.py
+++ b/examples2/rte/gen_rte2.py
@@ -17,11 +17,8 @@ def p(c):
 
 
 if __name__ == '__main__':
-    p("\"")
+    p('RANKED_TREE ')
 
-    p('b ')
-    p('b ')
-    p('a ')
-
-    p('#$')
-    p("\"")
+    p('a 2 ')
+    p('b 0 ')
+    p('b 0 ')
diff --git a/examples2/rte/gen_rte3.py b/examples2/rte/gen_rte3.py
index 1a02c48f4a3504fb669fbe283be93d021ce98177..66687753a477341e3873ba4fb3745ac673288f7c 100755
--- a/examples2/rte/gen_rte3.py
+++ b/examples2/rte/gen_rte3.py
@@ -18,15 +18,13 @@ def p(c):
 
 def S(depth):
     if depth > MAXD or random.randint(0,1) == 0:
-        p('b ')
+        p('b 0 ')
         return
 
+    p('a 2 ')
     S(depth + 1)
     S(depth + 1)
-    p('a ')
 
 if __name__ == '__main__':
-    p("\"")
+    p('RANKED_TREE ')
     S(1)
-    p('#$')
-    p("\"")
diff --git a/examples2/rte/gen_rte4.py b/examples2/rte/gen_rte4.py
index aa59556f518bd81d8659ac25afe4f43a745edf43..7b0140bb6a11bbc1cd874b77bf423e08711a18bb 100755
--- a/examples2/rte/gen_rte4.py
+++ b/examples2/rte/gen_rte4.py
@@ -18,19 +18,15 @@ def p(c):
 
 def S(depth):
     if depth > MAXD or random.randint(0,1) == 0:
-        p('b ')
-        p('b ')
-        p('a ')
+        p('a 2 ')
+        p('b 0 ')
+        p('b 0 ')
         return
 
+    p('a 2 ')
     S(depth + 1)
     S(depth + 1)
-    p('a ')
 
 if __name__ == '__main__':
-    p("\"")
+    p('RANKED_TREE ')
     S(1)
-    p('#$')
-    p("\"")
-
-
diff --git a/examples2/rte/gen_rte5.py b/examples2/rte/gen_rte5.py
index 0605fff3eb484ac5e1e92301e6d87635dd2eb4fb..9e4ed0aba6da3126c54acd91e733f0f349690297 100755
--- a/examples2/rte/gen_rte5.py
+++ b/examples2/rte/gen_rte5.py
@@ -17,9 +17,6 @@ def p(c):
 
 
 if __name__ == '__main__':
-    p("\"")
+    p('RANKED_TREE ')
 
-    p('a ')
-
-    p('#$')
-    p("\"")
+    p('a 0 ')
diff --git a/examples2/rte/gen_rte6.py b/examples2/rte/gen_rte6.py
index 59602d8c1dda4c4c598cee2034642a77bace1841..61027b1d50373e2eecfb07720ad90b195cab47db 100755
--- a/examples2/rte/gen_rte6.py
+++ b/examples2/rte/gen_rte6.py
@@ -19,7 +19,7 @@ def p(c):
 def SL(depth):
     rand = random.randint(0,1)
     if depth > MAXD or rand == 0:
-        p('b ')
+        p('b 0 ')
     elif rand == 1:
         S(depth + 1)
 
@@ -27,19 +27,16 @@ def SL(depth):
 def SR(depth):
     rand = random.randint(0,1)
     if depth > MAXD or rand == 0:
-        p('c ')
+        p('c 0 ')
     elif rand == 1:
         S(depth + 1)
 
 
 def S(depth):
+    p('a 2 ')
     SL(depth + 1)
     SR(depth + 1)
-    p('a ')
 
 if __name__ == '__main__':
-    p("\"")
+    p('RANKED_TREE ')
     S(1)
-    p('#$')
-    p("\"")
-
diff --git a/examples2/rte/gen_rte7.py b/examples2/rte/gen_rte7.py
index 1830cf6bf460630ab1221c27b819614dbc663593..4561cafb3a2d054efa524a99835ff1ba5b641020 100755
--- a/examples2/rte/gen_rte7.py
+++ b/examples2/rte/gen_rte7.py
@@ -20,19 +20,16 @@ def SCont(depth):
     if depth > MAXD or random.randint(0,2) == 0:
         return
 
-    p('d ')
+    p('d 1 ')
     SCont(depth + 1)
 
 
 def S(depth):
-    p('c ')
-    p('b ')
-    p('a ')
     SCont(depth + 1)
+    p('a 2 ')
+    p('c 0 ')
+    p('b 0 ')
 
 if __name__ == '__main__':
-    p("\"")
+    p('RANKED_TREE ')
     S(1)
-    p('#$')
-    p("\"")
-
diff --git a/examples2/rte/gen_rte8.py b/examples2/rte/gen_rte8.py
index 86571356a6f2e0b8ceac4c1f929f9d98d321b3d6..7dc7ae2a233c7aea79569b6907efcf5a4cd996bc 100755
--- a/examples2/rte/gen_rte8.py
+++ b/examples2/rte/gen_rte8.py
@@ -20,19 +20,16 @@ def S(depth):
     if depth > MAXD or random.randint(0,1) == 0:
         rand = random.randint(0,3)
 
-        if rand == 0: p('b ')
-        elif rand == 1: p('c ')
-        elif rand == 2: p('d ')
-        elif rand == 3: p('e ')
+        if rand == 0: p('b 0 ')
+        elif rand == 1: p('c 0 ')
+        elif rand == 2: p('d 0 ')
+        elif rand == 3: p('e 0 ')
         return
 
+    p('a 2 ')
     S(depth + 1)
     S(depth + 1)
-    p('a ')
 
 if __name__ == '__main__':
-    p("\"")
+    p('RANKED_TREE ')
     S(1)
-    p('#$')
-    p("\"")
-
diff --git a/examples2/rte/gen_rte9.py b/examples2/rte/gen_rte9.py
index 164d37d39e23640daa8a889ab7c1d1f5f7347344..d198c2eac0612675f96b097f63c70a926d98c5d5 100755
--- a/examples2/rte/gen_rte9.py
+++ b/examples2/rte/gen_rte9.py
@@ -18,14 +18,12 @@ def p(c):
 
 def S(depth):
     if depth > MAXD or random.randint(0,1) == 0:
-        p('b ')
+        p('b 0 ')
     else:
+        p('a 2 ')
         S(depth + 1)
         S(depth + 1)
-        p('a ')
 
 if __name__ == '__main__':
-    p("\"")
+    p('RANKED_TREE ')
     S(1)
-    p('#$')
-    p("\"")
diff --git a/tests.glushkovrte.sh b/tests.glushkovrte.sh
index 4f96da7eb7d5d4cbf0322f8e68bd42b0f691065b..933cabdb769a1d98a97412d7c32995abb27cf742 100755
--- a/tests.glushkovrte.sh
+++ b/tests.glushkovrte.sh
@@ -56,7 +56,9 @@ function log {
 # $3 = rte
 function runAcceptTest {
 	PATTERN=$(mktemp)
-	OUT=`timeout $TESTCASE_TIMEOUT bash -c "./arun2 -i <($1 | tee $PATTERN | ./aconvert2 --string_from_string) -a $2"`
+	FILE=$(mktemp)
+	echo '"#$"' > $FILE
+	OUT=`timeout $TESTCASE_TIMEOUT bash -c "./arun2 -i <($1 | tee $PATTERN | ./aconvert2 --tree_from_string | ./aql2 -q 'execute string::StringConcatenate ( PostfixRankedTree ) <#stdin < [string] :string::String $FILE >#stdout ') -a $2"`
 	RET=$?
 	if [ $RET == 0 ]; then # ok
 		echo $OUT | grep -q "<Bool>true</Bool>"
diff --git a/tests.glushkovrte_naive.sh b/tests.glushkovrte_naive.sh
index 0ac39209767a2e0d21668cae817c0eff446bf88a..7d7f358d865d9eb93ae95f0255e12e48e5d66866 100755
--- a/tests.glushkovrte_naive.sh
+++ b/tests.glushkovrte_naive.sh
@@ -54,7 +54,9 @@ function log {
 # $3 = rte
 function runAcceptTest {
 	PATTERN=$(mktemp)
-	OUT=`timeout $TESTCASE_TIMEOUT bash -c "./arun2 -i <($1 | tee $PATTERN | ./aconvert2 --string_from_string) -a $2"`
+	FILE=$(mktemp)
+	echo '"#$"' > $FILE
+	OUT=`timeout $TESTCASE_TIMEOUT bash -c "./arun2 -i <($1 | tee $PATTERN | ./aconvert2 --tree_from_string | ./aql2 -q 'execute string::StringConcatenate ( PostfixRankedTree ) <#stdin < [string] :string::String $FILE >#stdout ') -a $2"`
 	RET=$?
 	if [ $RET == 0 ]; then # ok
 		echo $OUT | grep -q "<Bool>true</Bool>"