From ecee679525bd2bc5b1d1dd81860f659b2cb90a78 Mon Sep 17 00:00:00 2001
From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz>
Date: Tue, 24 Apr 2018 16:15:21 +0200
Subject: [PATCH] adapt regexps and rtes to changes in tree_base

---
 .../regexp/convert/ToAutomatonThompson.cpp    |   8 +-
 alib2algo/src/regexp/glushkov/GlushkovFirst.h |  10 +-
 .../src/regexp/glushkov/GlushkovFollow.h      |  16 +-
 .../src/regexp/glushkov/GlushkovIndexate.h    |   8 +-
 alib2algo/src/regexp/glushkov/GlushkovLast.h  |  10 +-
 alib2algo/src/regexp/glushkov/GlushkovPos.h   |   8 +-
 alib2algo/src/regexp/properties/RegExpEmpty.h |   8 +-
 .../src/regexp/properties/RegExpEpsilon.h     |   8 +-
 .../src/regexp/simplify/RegExpOptimize.h      |  18 +-
 .../simplify/RegExpOptimizeFormalPart.hpp     | 198 +++++----
 .../simplify/RegExpOptimizeUnboundedPart.hpp  | 384 +++++++++---------
 .../src/regexp/transform/RegExpDerivation.h   |  16 +-
 .../src/regexp/transform/RegExpIntegral.h     |   8 +-
 alib2algo/src/rte/glushkov/GlushkovFollow.h   |   6 +-
 .../src/rte/glushkov/GlushkovFollowNaive.h    |   6 +-
 .../src/rte/glushkov/GlushkovIndexate.cpp     |   7 +-
 alib2algo/src/rte/glushkov/GlushkovPos.h      |   4 +-
 .../rte/glushkov/GlushkovSubstitutionMap.h    |   2 +-
 .../regexp/simplify/RegExpOptimizeTest.cpp    | 151 ++++++-
 .../regexp/formal/FormalRegExpAlternation.h   |  16 +-
 .../regexp/formal/FormalRegExpConcatenation.h |  18 +-
 .../src/regexp/formal/FormalRegExpEmpty.h     |   2 +-
 .../src/regexp/formal/FormalRegExpEpsilon.h   |   2 +-
 .../src/regexp/formal/FormalRegExpIteration.h |  10 +-
 .../src/regexp/formal/FormalRegExpSymbol.h    |   2 +-
 .../unbounded/UnboundedRegExpAlternation.h    |  38 +-
 .../unbounded/UnboundedRegExpConcatenation.h  |  38 +-
 .../regexp/unbounded/UnboundedRegExpEmpty.h   |   2 +-
 .../regexp/unbounded/UnboundedRegExpEpsilon.h |   2 +-
 .../unbounded/UnboundedRegExpIteration.h      |  10 +-
 .../regexp/unbounded/UnboundedRegExpSymbol.h  |   2 +-
 .../regexp/xml/common/RegExpToXmlComposer.h   |  10 +-
 .../src/rte/formal/FormalRTEAlternation.h     |  16 +-
 alib2data/src/rte/formal/FormalRTEIteration.h |  14 +-
 .../src/rte/formal/FormalRTESubstitution.h    |  16 +-
 .../src/rte/formal/FormalRTESymbolAlphabet.h  |  28 +-
 .../src/rte/xml/common/RTEFromXmlParser.h     |   4 +-
 .../src/rte/xml/common/RTEToXmlComposer.h     |   4 +-
 alib2data/test-src/rte/RTETest.cpp            |  16 +-
 alib2str/src/regexp/string/UnboundedRegExp.h  |   8 +-
 40 files changed, 612 insertions(+), 522 deletions(-)

diff --git a/alib2algo/src/regexp/convert/ToAutomatonThompson.cpp b/alib2algo/src/regexp/convert/ToAutomatonThompson.cpp
index db81b8f982..d9b50f26dc 100644
--- a/alib2algo/src/regexp/convert/ToAutomatonThompson.cpp
+++ b/alib2algo/src/regexp/convert/ToAutomatonThompson.cpp
@@ -142,8 +142,8 @@ void ToAutomatonThompson::Unbounded::visit(const regexp::UnboundedRegExpAlternat
 	automaton.addState(head);
 	automaton.addState(tail);
 
-	for(const auto& element : alternation.getElements()) {
-		element->accept < void, ToAutomatonThompson::Unbounded, automaton::EpsilonNFA < > &, int &, const DefaultStateType * &, const DefaultStateType * & >(automaton, nextState, headArg, tailArg);
+	for(const UnboundedRegExpElement < DefaultSymbolType > & element : alternation.getElements()) {
+		element.accept < void, ToAutomatonThompson::Unbounded, automaton::EpsilonNFA < > &, int &, const DefaultStateType * &, const DefaultStateType * & >(automaton, nextState, headArg, tailArg);
 		automaton.addTransition(head, string::Epsilon < >::EPSILON, *headArg);
 		automaton.addTransition(*tailArg, string::Epsilon < >::EPSILON, tail);
 	}
@@ -154,8 +154,8 @@ void ToAutomatonThompson::Unbounded::visit(const regexp::UnboundedRegExpAlternat
 
 void ToAutomatonThompson::Unbounded::visit(const regexp::UnboundedRegExpConcatenation < DefaultSymbolType > & concatenation, automaton::EpsilonNFA < > & automaton , int & nextState, const DefaultStateType * & headArg, const DefaultStateType * & tailArg) {
 	ext::vector<std::pair<const DefaultStateType*, const DefaultStateType*>> tails;
-	for(const auto& element : concatenation.getElements()) {
-		element->accept < void, ToAutomatonThompson::Unbounded, automaton::EpsilonNFA < > &, int &, const DefaultStateType * &, const DefaultStateType * & >(automaton, nextState, headArg, tailArg);
+	for(const UnboundedRegExpElement < DefaultSymbolType > & element : concatenation.getElements()) {
+		element.accept < void, ToAutomatonThompson::Unbounded, automaton::EpsilonNFA < > &, int &, const DefaultStateType * &, const DefaultStateType * & >(automaton, nextState, headArg, tailArg);
 		tails.push_back(std::make_pair(headArg, tailArg));
 	}
 
diff --git a/alib2algo/src/regexp/glushkov/GlushkovFirst.h b/alib2algo/src/regexp/glushkov/GlushkovFirst.h
index 609bf466c6..f3f472db22 100644
--- a/alib2algo/src/regexp/glushkov/GlushkovFirst.h
+++ b/alib2algo/src/regexp/glushkov/GlushkovFirst.h
@@ -60,8 +60,8 @@ template < class SymbolType >
 ext::set < regexp::UnboundedRegExpSymbol < SymbolType > > GlushkovFirst::Unbounded < SymbolType >::visit ( const regexp::UnboundedRegExpAlternation < SymbolType > & node ) {
 	ext::set < regexp::UnboundedRegExpSymbol < SymbolType > > ret, tmp;
 
-	for ( auto const & element : node.getElements ( ) ) {
-		tmp = element->template accept < ext::set < regexp::UnboundedRegExpSymbol < SymbolType > >, GlushkovFirst::Unbounded < SymbolType > > ( );
+	for ( const UnboundedRegExpElement < SymbolType > & element : node.getElements ( ) ) {
+		tmp = element.template accept < ext::set < regexp::UnboundedRegExpSymbol < SymbolType > >, GlushkovFirst::Unbounded < SymbolType > > ( );
 		ret.insert ( tmp.begin ( ), tmp.end ( ) );
 	}
 
@@ -72,11 +72,11 @@ template < class SymbolType >
 ext::set < regexp::UnboundedRegExpSymbol < SymbolType > > GlushkovFirst::Unbounded < SymbolType >::visit ( const regexp::UnboundedRegExpConcatenation < SymbolType > & node ) {
 	ext::set < regexp::UnboundedRegExpSymbol < SymbolType > > ret, tmp;
 
-	for ( auto const & element : node.getElements ( ) ) {
-		tmp = element->template accept < ext::set < regexp::UnboundedRegExpSymbol < SymbolType > >, GlushkovFirst::Unbounded < SymbolType > > ( );
+	for ( const UnboundedRegExpElement < SymbolType > & element : node.getElements ( ) ) {
+		tmp = element.template accept < ext::set < regexp::UnboundedRegExpSymbol < SymbolType > >, GlushkovFirst::Unbounded < SymbolType > > ( );
 		ret.insert ( tmp.begin ( ), tmp.end ( ) );
 
-		if ( ! regexp::properties::RegExpEpsilon::languageContainsEpsilon ( * element ) ) // If regexp of this subtree can match epsilon, then we need to add next subtree
+		if ( ! regexp::properties::RegExpEpsilon::languageContainsEpsilon ( element ) ) // If regexp of this subtree can match epsilon, then we need to add next subtree
 			break;
 	}
 
diff --git a/alib2algo/src/regexp/glushkov/GlushkovFollow.h b/alib2algo/src/regexp/glushkov/GlushkovFollow.h
index 1ffe796662..261c91e180 100644
--- a/alib2algo/src/regexp/glushkov/GlushkovFollow.h
+++ b/alib2algo/src/regexp/glushkov/GlushkovFollow.h
@@ -64,9 +64,9 @@ ext::set < UnboundedRegExpSymbol < SymbolType > > GlushkovFollow::follow ( const
 
 template < class SymbolType >
 ext::set < regexp::UnboundedRegExpSymbol < SymbolType > > GlushkovFollow::Unbounded < SymbolType >::visit ( const regexp::UnboundedRegExpAlternation < SymbolType > & node, const regexp::UnboundedRegExpSymbol < SymbolType > & symbolptr ) {
-	for ( auto const & element : node.getElements ( ) )
-		if ( element->template accept < bool, GlushkovPos::Unbounded < SymbolType > > ( symbolptr ) )
-			return element->template accept < ext::set < regexp::UnboundedRegExpSymbol < SymbolType > >, GlushkovFollow::Unbounded < SymbolType > > ( symbolptr );
+	for ( const UnboundedRegExpElement < SymbolType > & element : node.getElements ( ) )
+		if ( element.template accept < bool, GlushkovPos::Unbounded < SymbolType > > ( symbolptr ) )
+			return element.template accept < ext::set < regexp::UnboundedRegExpSymbol < SymbolType > >, GlushkovFollow::Unbounded < SymbolType > > ( symbolptr );
 
 	throw exception::CommonException ( "GlushkovFollow::Unbounded < SymbolType >::visit(Alt)" );
 }
@@ -76,20 +76,20 @@ ext::set < regexp::UnboundedRegExpSymbol < SymbolType > > GlushkovFollow::Unboun
 	ext::set < regexp::UnboundedRegExpSymbol < SymbolType > > ret, tmp, lastSet;
 
 	for ( auto e = node.getElements ( ).begin ( ); e != node.getElements ( ).end ( ); e++ ) {
-		if ( ! ( * e )->template accept < bool, GlushkovPos::Unbounded < SymbolType > > ( symbolptr ) )
+		if ( ! e->template accept < bool, GlushkovPos::Unbounded < SymbolType > > ( symbolptr ) )
 			continue;
 
-		tmp = ( * e )->template accept < ext::set < regexp::UnboundedRegExpSymbol < SymbolType > >, GlushkovFollow::Unbounded < SymbolType > > ( symbolptr );
+		tmp = e->template accept < ext::set < regexp::UnboundedRegExpSymbol < SymbolType > >, GlushkovFollow::Unbounded < SymbolType > > ( symbolptr );
 		ret.insert ( tmp.begin ( ), tmp.end ( ) );
 
-		lastSet = ( * e )->template accept < ext::set < regexp::UnboundedRegExpSymbol < SymbolType > >, GlushkovLast::Unbounded < SymbolType > > ( );
+		lastSet = e->template accept < ext::set < regexp::UnboundedRegExpSymbol < SymbolType > >, GlushkovLast::Unbounded < SymbolType > > ( );
 
 		if ( lastSet.find ( symbolptr ) != lastSet.end ( ) )
 			for ( auto f = next ( e ); f != node.getElements ( ).end ( ); f++ ) {
-				tmp = ( * f )->template accept < ext::set < regexp::UnboundedRegExpSymbol < SymbolType > >, GlushkovFirst::Unbounded < SymbolType > > ( );
+				tmp = f->template accept < ext::set < regexp::UnboundedRegExpSymbol < SymbolType > >, GlushkovFirst::Unbounded < SymbolType > > ( );
 				ret.insert ( tmp.begin ( ), tmp.end ( ) );
 
-				if ( ! regexp::properties::RegExpEpsilon::languageContainsEpsilon ( * * f ) )
+				if ( ! regexp::properties::RegExpEpsilon::languageContainsEpsilon ( * f ) )
 					break;
 			}
 
diff --git a/alib2algo/src/regexp/glushkov/GlushkovIndexate.h b/alib2algo/src/regexp/glushkov/GlushkovIndexate.h
index b72c2f3fc6..aaea3adb38 100644
--- a/alib2algo/src/regexp/glushkov/GlushkovIndexate.h
+++ b/alib2algo/src/regexp/glushkov/GlushkovIndexate.h
@@ -57,8 +57,8 @@ template < class SymbolType >
 ext::rvalue_ref < regexp::UnboundedRegExpElement < ext::pair < SymbolType, int > > > GlushkovIndexate::Unbounded < SymbolType >::visit(const regexp::UnboundedRegExpAlternation < SymbolType > & alternation, int & i) {
 	UnboundedRegExpAlternation < ext::pair < SymbolType, int > > * alt = new UnboundedRegExpAlternation < ext::pair < SymbolType, int > > ( );
 
-	for ( const auto & element : alternation.getElements ( ) )
-		alt->appendElement ( element->template accept < ext::rvalue_ref < regexp::UnboundedRegExpElement < ext::pair < SymbolType, int > > >, GlushkovIndexate::Unbounded < SymbolType > > ( i ) );
+	for ( const UnboundedRegExpElement < SymbolType > & element : alternation.getElements ( ) )
+		alt->appendElement ( element.template accept < ext::rvalue_ref < regexp::UnboundedRegExpElement < ext::pair < SymbolType, int > > >, GlushkovIndexate::Unbounded < SymbolType > > ( i ) );
 
 	return ext::rvalue_ref < UnboundedRegExpElement < ext::pair < SymbolType, int > > > ( alt );
 }
@@ -67,8 +67,8 @@ template < class SymbolType >
 ext::rvalue_ref < regexp::UnboundedRegExpElement < ext::pair < SymbolType, int > > > GlushkovIndexate::Unbounded < SymbolType >::visit(const regexp::UnboundedRegExpConcatenation < SymbolType > & concatenation, int & i) {
 	UnboundedRegExpConcatenation < ext::pair < SymbolType, int > > * con = new UnboundedRegExpConcatenation < ext::pair < SymbolType, int > > ( );
 
-	for ( const auto & element : concatenation.getElements ( ) )
-		con->appendElement ( element->template accept < ext::rvalue_ref < regexp::UnboundedRegExpElement < ext::pair < SymbolType, int > > >, GlushkovIndexate::Unbounded < SymbolType > > ( i ) );
+	for ( const UnboundedRegExpElement < SymbolType > & element : concatenation.getElements ( ) )
+		con->appendElement ( element.template accept < ext::rvalue_ref < regexp::UnboundedRegExpElement < ext::pair < SymbolType, int > > >, GlushkovIndexate::Unbounded < SymbolType > > ( i ) );
 
 	return ext::rvalue_ref < UnboundedRegExpElement < ext::pair < SymbolType, int > > > ( con );
 }
diff --git a/alib2algo/src/regexp/glushkov/GlushkovLast.h b/alib2algo/src/regexp/glushkov/GlushkovLast.h
index e93d2fb4ab..50cb57cf1d 100644
--- a/alib2algo/src/regexp/glushkov/GlushkovLast.h
+++ b/alib2algo/src/regexp/glushkov/GlushkovLast.h
@@ -60,8 +60,8 @@ template < class SymbolType >
 ext::set < regexp::UnboundedRegExpSymbol < SymbolType > > GlushkovLast::Unbounded < SymbolType >::visit ( const regexp::UnboundedRegExpAlternation < SymbolType > & node ) {
 	ext::set < regexp::UnboundedRegExpSymbol < SymbolType > > ret;
 
-	for ( const auto & element : node.getElements ( ) ) {
-		ext::set < regexp::UnboundedRegExpSymbol < SymbolType > > tmp = element->template accept < ext::set < regexp::UnboundedRegExpSymbol < SymbolType > >, GlushkovLast::Unbounded < SymbolType > > ( );
+	for ( const UnboundedRegExpElement < SymbolType > & element : node.getElements ( ) ) {
+		ext::set < regexp::UnboundedRegExpSymbol < SymbolType > > tmp = element.template accept < ext::set < regexp::UnboundedRegExpSymbol < SymbolType > >, GlushkovLast::Unbounded < SymbolType > > ( );
 		ret.insert ( tmp.begin ( ), tmp.end ( ) );
 	}
 
@@ -72,11 +72,11 @@ template < class SymbolType >
 ext::set < regexp::UnboundedRegExpSymbol < SymbolType > > GlushkovLast::Unbounded < SymbolType >::visit ( const regexp::UnboundedRegExpConcatenation < SymbolType > & node ) {
 	ext::set < regexp::UnboundedRegExpSymbol < SymbolType > > ret;
 
-	for ( const auto & element : ext::make_reverse ( node.getElements ( ) ) ) {
-		ext::set < regexp::UnboundedRegExpSymbol < SymbolType > > tmp = element->template accept < ext::set < regexp::UnboundedRegExpSymbol < SymbolType > >, GlushkovLast::Unbounded < SymbolType > > ( );
+	for ( const UnboundedRegExpElement < SymbolType > & element : ext::make_reverse ( node.getElements ( ) ) ) {
+		ext::set < regexp::UnboundedRegExpSymbol < SymbolType > > tmp = element.template accept < ext::set < regexp::UnboundedRegExpSymbol < SymbolType > >, GlushkovLast::Unbounded < SymbolType > > ( );
 		ret.insert ( tmp.begin ( ), tmp.end ( ) );
 
-		if ( ! regexp::properties::RegExpEpsilon::languageContainsEpsilon ( * element ) )
+		if ( ! regexp::properties::RegExpEpsilon::languageContainsEpsilon ( element ) )
 			break;
 	}
 
diff --git a/alib2algo/src/regexp/glushkov/GlushkovPos.h b/alib2algo/src/regexp/glushkov/GlushkovPos.h
index c6cb444f43..fbcf18c1dc 100644
--- a/alib2algo/src/regexp/glushkov/GlushkovPos.h
+++ b/alib2algo/src/regexp/glushkov/GlushkovPos.h
@@ -53,8 +53,8 @@ bool GlushkovPos::pos ( const UnboundedRegExpSymbol < SymbolType > & symbol, con
 
 template < class SymbolType >
 bool GlushkovPos::Unbounded < SymbolType >::visit ( const regexp::UnboundedRegExpAlternation < SymbolType > & node, const regexp::UnboundedRegExpSymbol < SymbolType > & symbol ) {
-	for ( const auto & element : node.getElements ( ) )
-		if ( element->template accept < bool, GlushkovPos::Unbounded < SymbolType > > ( symbol ) )
+	for ( const UnboundedRegExpElement < SymbolType > & element : node.getElements ( ) )
+		if ( element.template accept < bool, GlushkovPos::Unbounded < SymbolType > > ( symbol ) )
 			return true;
 
 	return false;
@@ -62,8 +62,8 @@ bool GlushkovPos::Unbounded < SymbolType >::visit ( const regexp::UnboundedRegEx
 
 template < class SymbolType >
 bool GlushkovPos::Unbounded < SymbolType >::visit ( const regexp::UnboundedRegExpConcatenation < SymbolType > & node, const regexp::UnboundedRegExpSymbol < SymbolType > & symbol ) {
-	for ( const auto & element : node.getElements ( ) )
-		if ( element->template accept < bool, GlushkovPos::Unbounded < SymbolType > > ( symbol ) )
+	for ( const UnboundedRegExpElement < SymbolType > & element : node.getElements ( ) )
+		if ( element.template accept < bool, GlushkovPos::Unbounded < SymbolType > > ( symbol ) )
 			return true;
 
 	return false;
diff --git a/alib2algo/src/regexp/properties/RegExpEmpty.h b/alib2algo/src/regexp/properties/RegExpEmpty.h
index 3f6b745a71..393e5a40f9 100644
--- a/alib2algo/src/regexp/properties/RegExpEmpty.h
+++ b/alib2algo/src/regexp/properties/RegExpEmpty.h
@@ -99,8 +99,8 @@ bool RegExpEmpty::languageIsEmpty(const regexp::UnboundedRegExp < SymbolType > &
 
 template < class SymbolType >
 bool RegExpEmpty::Unbounded< SymbolType >::visit(const regexp::UnboundedRegExpAlternation < SymbolType > & alternation) {
-	for(const auto& element : alternation.getElements()) {
-		if(! element->template accept < bool, RegExpEmpty::Unbounded < SymbolType > > ( ) ) {
+	for(const UnboundedRegExpElement < SymbolType > & element : alternation.getElements()) {
+		if(! element.template accept < bool, RegExpEmpty::Unbounded < SymbolType > > ( ) ) {
 			return false;
 		}
 	}
@@ -109,8 +109,8 @@ bool RegExpEmpty::Unbounded< SymbolType >::visit(const regexp::UnboundedRegExpAl
 
 template < class SymbolType >
 bool RegExpEmpty::Unbounded< SymbolType >::visit(const regexp::UnboundedRegExpConcatenation < SymbolType > & concatenation) {
-	for(const auto& element : concatenation.getElements()) {
-		if( element->template accept < bool, RegExpEmpty::Unbounded < SymbolType > > ( ) ) {
+	for(const UnboundedRegExpElement < SymbolType > & element : concatenation.getElements()) {
+		if( element.template accept < bool, RegExpEmpty::Unbounded < SymbolType > > ( ) ) {
 			return true;
 		}
 	}
diff --git a/alib2algo/src/regexp/properties/RegExpEpsilon.h b/alib2algo/src/regexp/properties/RegExpEpsilon.h
index 4c381f4782..ca66c89127 100644
--- a/alib2algo/src/regexp/properties/RegExpEpsilon.h
+++ b/alib2algo/src/regexp/properties/RegExpEpsilon.h
@@ -98,8 +98,8 @@ bool RegExpEpsilon::languageContainsEpsilon(const regexp::UnboundedRegExp < Symb
 
 template < class SymbolType >
 bool RegExpEpsilon::Unbounded < SymbolType >::visit(const regexp::UnboundedRegExpAlternation < SymbolType > & alternation) {
-	for ( const auto & element : alternation.getElements ( ) )
-		if ( element->template accept < bool, RegExpEpsilon::Unbounded < SymbolType > > ( ) )
+	for ( const UnboundedRegExpElement < SymbolType > & element : alternation.getElements ( ) )
+		if ( element.template accept < bool, RegExpEpsilon::Unbounded < SymbolType > > ( ) )
 			return true;
 
 	return false;
@@ -107,8 +107,8 @@ bool RegExpEpsilon::Unbounded < SymbolType >::visit(const regexp::UnboundedRegEx
 
 template < class SymbolType >
 bool RegExpEpsilon::Unbounded < SymbolType >::visit(const regexp::UnboundedRegExpConcatenation < SymbolType > & concatenation) {
-	for ( const auto & element : concatenation.getElements ( ) )
-		if ( ! element->template accept < bool, RegExpEpsilon::Unbounded < SymbolType > > ( ) )
+	for ( const UnboundedRegExpElement < SymbolType > & element : concatenation.getElements ( ) )
+		if ( ! element.template accept < bool, RegExpEpsilon::Unbounded < SymbolType > > ( ) )
 			return false;
 
 	return true;
diff --git a/alib2algo/src/regexp/simplify/RegExpOptimize.h b/alib2algo/src/regexp/simplify/RegExpOptimize.h
index 8134f65a58..9e47f0add9 100644
--- a/alib2algo/src/regexp/simplify/RegExpOptimize.h
+++ b/alib2algo/src/regexp/simplify/RegExpOptimize.h
@@ -83,19 +83,19 @@ private:
 	static regexp::FormalRegExpElement < SymbolType > * optimizeInner( const regexp::FormalRegExpElement < SymbolType > & node );
 
 	template < class SymbolType >
-	static regexp::UnboundedRegExpElement < SymbolType > * optimizeInner( const regexp::UnboundedRegExpElement < SymbolType > & node );
+	static ext::rvalue_ref < regexp::UnboundedRegExpElement < SymbolType > > optimizeInner( const regexp::UnboundedRegExpElement < SymbolType > & node );
 	template < class SymbolType >
-	static regexp::UnboundedRegExpElement < SymbolType > * optimizeInner( const regexp::UnboundedRegExpAlternation < SymbolType > & node );
+	static ext::rvalue_ref < regexp::UnboundedRegExpElement < SymbolType > > optimizeInner( const regexp::UnboundedRegExpAlternation < SymbolType > & node );
 	template < class SymbolType >
-	static regexp::UnboundedRegExpElement < SymbolType > * optimizeInner( const regexp::UnboundedRegExpConcatenation < SymbolType > & node );
+	static ext::rvalue_ref < regexp::UnboundedRegExpElement < SymbolType > > optimizeInner( const regexp::UnboundedRegExpConcatenation < SymbolType > & node );
 	template < class SymbolType >
-	static regexp::UnboundedRegExpElement < SymbolType > * optimizeInner( const regexp::UnboundedRegExpIteration < SymbolType > & node );
+	static ext::rvalue_ref < regexp::UnboundedRegExpElement < SymbolType > > optimizeInner( const regexp::UnboundedRegExpIteration < SymbolType > & node );
 	template < class SymbolType >
-	static regexp::UnboundedRegExpElement < SymbolType > * optimizeInner( const regexp::UnboundedRegExpSymbol < SymbolType > & node );
+	static ext::rvalue_ref < regexp::UnboundedRegExpElement < SymbolType > > optimizeInner( const regexp::UnboundedRegExpSymbol < SymbolType > & node );
 	template < class SymbolType >
-	static regexp::UnboundedRegExpElement < SymbolType > * optimizeInner( const regexp::UnboundedRegExpEpsilon < SymbolType > & node );
+	static ext::rvalue_ref < regexp::UnboundedRegExpElement < SymbolType > > optimizeInner( const regexp::UnboundedRegExpEpsilon < SymbolType > & node );
 	template < class SymbolType >
-	static regexp::UnboundedRegExpElement < SymbolType > * optimizeInner( const regexp::UnboundedRegExpEmpty < SymbolType > & node );
+	static ext::rvalue_ref < regexp::UnboundedRegExpElement < SymbolType > > optimizeInner( const regexp::UnboundedRegExpEmpty < SymbolType > & node );
 
 	template < class SymbolType >
 	static bool A1( regexp::UnboundedRegExpAlternation < SymbolType > & node );
@@ -207,9 +207,7 @@ UnboundedRegExp < SymbolType > RegExpOptimize::optimize( const UnboundedRegExp <
 
 template < class SymbolType >
 UnboundedRegExpStructure < SymbolType > RegExpOptimize::optimize( const UnboundedRegExpStructure < SymbolType > & regexp ) {
-	UnboundedRegExpElement < SymbolType > * optimized = optimizeInner( regexp.getStructure( ) );
-
-	return regexp::UnboundedRegExpStructure < SymbolType > ( ext::manage_move ( optimized ) );
+	return regexp::UnboundedRegExpStructure < SymbolType > ( optimizeInner( regexp.getStructure( ) ) );
 }
 
 } /* namespace simplify */
diff --git a/alib2algo/src/regexp/simplify/RegExpOptimizeFormalPart.hpp b/alib2algo/src/regexp/simplify/RegExpOptimizeFormalPart.hpp
index fc59075c02..d565c6c1d7 100644
--- a/alib2algo/src/regexp/simplify/RegExpOptimizeFormalPart.hpp
+++ b/alib2algo/src/regexp/simplify/RegExpOptimizeFormalPart.hpp
@@ -54,7 +54,7 @@ void RegExpOptimize::optimize( FormalRegExpElement < SymbolType > & element ) {
 }
 
 template < class SymbolType >
-FormalRegExpElement < SymbolType >* RegExpOptimize::optimizeInner( const FormalRegExpElement < SymbolType > & node ) {
+FormalRegExpElement < SymbolType > * RegExpOptimize::optimizeInner( const FormalRegExpElement < SymbolType > & node ) {
 	FormalRegExpElement < SymbolType >* elem = node.clone();
 
 	// optimize while you can
@@ -127,16 +127,12 @@ bool RegExpOptimize::A1( FormalRegExpElement < SymbolType > * & n ) {
 	FormalRegExpAlternation < SymbolType > * node = dynamic_cast<FormalRegExpAlternation < SymbolType > *>( n );
 	if( ! node ) return false;
 
-	if( dynamic_cast<FormalRegExpAlternation < SymbolType > *>( node->getLeft().get() ) ) {
-		ext::smart_ptr < FormalRegExpAlternation < SymbolType > > leftAlt ( static_cast<FormalRegExpAlternation < SymbolType > *>( node->getLeft().release() ) );
+	if( dynamic_cast < FormalRegExpAlternation < SymbolType > * > ( & node->getLeft ( ) ) ) {
+		FormalRegExpAlternation < SymbolType > leftAlt ( std::move ( static_cast < FormalRegExpAlternation < SymbolType > & > ( node->getLeft ( ) ) ) );
 
-		ext::smart_ptr < FormalRegExpElement < SymbolType > > x = std::move ( leftAlt->getLeft() );
-		ext::smart_ptr < FormalRegExpElement < SymbolType > > y = std::move ( leftAlt->getRight() );
-		ext::smart_ptr < FormalRegExpElement < SymbolType > > z = std::move ( node->getRight() );
-
-		leftAlt->setLeft ( std::move ( y ) );
-		leftAlt->setRight ( std::move ( z ) );
-		node->setLeft ( std::move ( x ) );
+		node->setLeft ( std::move ( leftAlt.getLeft ( ) ) );
+		leftAlt.setLeft ( std::move ( leftAlt.getRight ( ) ) );
+		leftAlt.setRight ( std::move ( node->getRight ( ) ) );
 		node->setRight ( std::move ( leftAlt ) );
 
 		return true;
@@ -151,23 +147,20 @@ bool RegExpOptimize::A1( FormalRegExpElement < SymbolType > * & n ) {
   * @return bool true if optimization applied else false
   */
 template < class SymbolType >
-bool RegExpOptimize::A2( FormalRegExpElement < SymbolType > * & n ) {
+bool RegExpOptimize::A2 ( FormalRegExpElement < SymbolType > * & n ) {
 	FormalRegExpAlternation < SymbolType > * node = dynamic_cast<FormalRegExpAlternation < SymbolType > *>( n );
 	if( ! node ) return false;
 
-	if( dynamic_cast<FormalRegExpAlternation < SymbolType > *>( node->getRight().get() ) ) {
-		FormalRegExpAlternation < SymbolType > * rightAlt = static_cast < FormalRegExpAlternation < SymbolType > * > ( node->getRight ( ).get ( ) );
+	if ( dynamic_cast < FormalRegExpAlternation < SymbolType > * > ( & node->getRight ( ) ) ) {
+		FormalRegExpAlternation < SymbolType > & rightAlt = static_cast < FormalRegExpAlternation < SymbolType > & > ( node->getRight ( ) );
 
-		ext::smart_ptr < FormalRegExpElement < SymbolType > > x = std::move ( node->getLeft ( ) );
-		ext::smart_ptr < FormalRegExpElement < SymbolType > > y = std::move ( rightAlt->getLeft ( ) );
+		if ( node->getLeft ( ) > rightAlt.getLeft ( ) ) {
+			ext::rvalue_ref < FormalRegExpElement < SymbolType > > tmp ( std::move ( node->getLeft ( ) ).clone ( ) );
 
-		if(*x > *y) {
-			node->setLeft ( std::move ( y ) );
-			rightAlt->setLeft ( std::move ( x ) );
+			node->setLeft ( std::move ( rightAlt.getLeft ( ) ) );
+			rightAlt.setLeft ( tmp );
 			return true;
 		} else {
-			node->setLeft ( std::move ( x ) );
-			rightAlt->setLeft ( std::move ( y ) );
 			return false;
 		}
 	}
@@ -181,20 +174,20 @@ bool RegExpOptimize::A2( FormalRegExpElement < SymbolType > * & n ) {
   * @return bool true if optimization applied else false
   */
 template < class SymbolType >
-bool RegExpOptimize::A3( FormalRegExpElement < SymbolType > * & n ) {
-	FormalRegExpAlternation < SymbolType > * node = dynamic_cast<FormalRegExpAlternation < SymbolType > *>( n );
+bool RegExpOptimize::A3 ( FormalRegExpElement < SymbolType > * & n ) {
+	FormalRegExpAlternation < SymbolType > * node = dynamic_cast < FormalRegExpAlternation < SymbolType > * > ( n );
 	if( ! node ) return false;
 
 	// input can be \0 + \0, so at least one element must be preserved
 
-	if( dynamic_cast<FormalRegExpEmpty < SymbolType > *>( node->getRight().get() ) ) {
-		n = node->getLeft().release();
+	if ( dynamic_cast < FormalRegExpEmpty < SymbolType > * > ( & node->getRight ( ) ) ) {
+		n = std::move ( node->getLeft ( ) ).clone ( );
 		delete node;
 		return true;
 	}
 
-	if( dynamic_cast<FormalRegExpEmpty < SymbolType > *>( node->getLeft().get() ) ) {
-		n = node->getRight().release();
+	if ( dynamic_cast < FormalRegExpEmpty < SymbolType > * > ( & node->getLeft ( ) ) ) {
+		n = std::move ( node->getRight ( ) ).clone ( );
 		delete node;
 		return true;
 	}
@@ -217,11 +210,11 @@ bool RegExpOptimize::A4( FormalRegExpElement < SymbolType > * & n ) {
 	 * As we always sort in optimization, we can use the first version, but A4 must be __always__ called __after__ A2
 	 */
 
-	FormalRegExpAlternation < SymbolType > * node = dynamic_cast<FormalRegExpAlternation < SymbolType > *>( n );
-	if( ! node ) return false;
+	FormalRegExpAlternation < SymbolType > * node = dynamic_cast < FormalRegExpAlternation < SymbolType > * > ( n );
+	if ( ! node ) return false;
 
-	if( node->getLeftElement() == node->getRightElement() ) {
-		n = node->getRight().release();
+	if ( node->getLeftElement() == node->getRightElement() ) {
+		n = std::move ( node->getRight ( ) ).clone ( );
 		delete node;
 		return true;
 	}
@@ -239,16 +232,12 @@ bool RegExpOptimize::A5( FormalRegExpElement < SymbolType > * & n ) {
 	FormalRegExpConcatenation < SymbolType > * node = dynamic_cast<FormalRegExpConcatenation < SymbolType > *>( n );
 	if( ! node ) return false;
 
-	if( dynamic_cast<FormalRegExpConcatenation < SymbolType > *>( node->getLeft().get() ) ) {
-		ext::smart_ptr < FormalRegExpConcatenation < SymbolType > > leftCon ( static_cast<FormalRegExpConcatenation < SymbolType > *>( node->getLeft().release() ) );
-
-		ext::smart_ptr < FormalRegExpElement < SymbolType > > x = std::move ( leftCon->getLeft() );
-		ext::smart_ptr < FormalRegExpElement < SymbolType > > y = std::move ( leftCon->getRight() );
-		ext::smart_ptr < FormalRegExpElement < SymbolType > > z = std::move ( node->getRight() );
+	if( dynamic_cast < FormalRegExpConcatenation < SymbolType > * > ( & node->getLeft ( ) ) ) {
+		FormalRegExpConcatenation < SymbolType > leftCon ( std::move ( static_cast < FormalRegExpConcatenation < SymbolType > & > ( node->getLeft ( ) ) ) );
 
-		leftCon->setLeft ( std::move ( y ) );
-		leftCon->setRight ( std::move ( z ) );
-		node->setLeft ( std::move ( x ) );
+		node->setLeft ( std::move ( leftCon.getLeft ( ) ) );
+		leftCon.setLeft ( std::move ( leftCon.getRight ( ) ) );
+		leftCon.setRight ( std::move ( node->getRight ( ) ) );
 		node->setRight ( std::move ( leftCon ) );
 
 		return true;
@@ -269,14 +258,14 @@ bool RegExpOptimize::A6( FormalRegExpElement < SymbolType > * & n ) {
 
 	// input can be \e + \e, so at least one element must be preserved
 
-	if( dynamic_cast<FormalRegExpEpsilon < SymbolType > *>( node->getRight().get() ) ) {
-		n = node->getLeft().release();
+	if ( dynamic_cast < FormalRegExpEpsilon < SymbolType > * > ( & node->getRight ( ) ) ) {
+		n = std::move ( node->getLeft ( ) ).clone ( );
 		delete node;
 		return true;
 	}
 
-	if( dynamic_cast<FormalRegExpEpsilon < SymbolType > *>( node->getLeft().get() ) ) {
-		n = node->getRight().release();
+	if ( dynamic_cast < FormalRegExpEpsilon < SymbolType > * > ( & node->getLeft ( ) ) ) {
+		n = std::move ( node->getRight ( ) ).clone ( );
 		delete node;
 		return true;
 	}
@@ -294,7 +283,7 @@ bool RegExpOptimize::A7( FormalRegExpElement < SymbolType > * & n ) {
 	FormalRegExpConcatenation < SymbolType > * node = dynamic_cast<FormalRegExpConcatenation < SymbolType > *>( n );
 	if( ! node ) return false;
 
-	if( dynamic_cast<FormalRegExpEmpty < SymbolType > *>( node->getRight().get() ) || dynamic_cast<FormalRegExpEmpty < SymbolType > *>( node->getLeft().get() ) ) {
+	if ( dynamic_cast < FormalRegExpEmpty < SymbolType > * > ( & node->getRight ( ) ) || dynamic_cast < FormalRegExpEmpty < SymbolType > * > ( & node->getLeft ( ) ) ) {
 		delete node;
 		n = new FormalRegExpEmpty < SymbolType > { };
 		return true;
@@ -336,49 +325,49 @@ bool RegExpOptimize::A10( FormalRegExpElement < SymbolType > * & n ) {
 	 * - but if we do not have the eps, but we do have iteration, then \e \in h(iter), therefore \e in h(node).
 	 */
 
-	FormalRegExpAlternation < SymbolType > * node = dynamic_cast<FormalRegExpAlternation < SymbolType > *>( n );
-	if( ! node ) return false;
+	FormalRegExpAlternation < SymbolType > * node = dynamic_cast<FormalRegExpAlternation < SymbolType > * > ( n );
+	if ( ! node ) return false;
 
-	if( dynamic_cast<FormalRegExpEpsilon < SymbolType > *>( node->getLeft().get() ) ) {
-		FormalRegExpConcatenation < SymbolType > * rightCon = dynamic_cast<FormalRegExpConcatenation < SymbolType > *>( node->getRight().get() );
-		if( ! rightCon ) return false;
+	if ( dynamic_cast < FormalRegExpEpsilon < SymbolType > * > ( & node->getLeft ( ) ) ) {
+		FormalRegExpConcatenation < SymbolType > * rightCon = dynamic_cast < FormalRegExpConcatenation < SymbolType > * > ( & node->getRight ( ) );
+		if ( ! rightCon ) return false;
 
-		FormalRegExpIteration < SymbolType > * rightLeftIte = dynamic_cast<FormalRegExpIteration < SymbolType > *>( rightCon->getLeft().get() );
-		if( rightLeftIte ) {
-			if(rightLeftIte->getElement() == rightCon->getRightElement()) {
-				n = rightCon->getLeft().release();
+		FormalRegExpIteration < SymbolType > * rightLeftIte = dynamic_cast < FormalRegExpIteration < SymbolType > * > ( & rightCon->getLeft ( ) );
+		if ( rightLeftIte ) {
+			if ( rightLeftIte->getElement ( ) == rightCon->getRightElement ( ) ) {
+				n = std::move ( rightCon->getLeft ( ) ).clone ( );
 				delete node;
 				return true;
 			}
 		}
 
-		FormalRegExpIteration < SymbolType > * rightRightIte = dynamic_cast<FormalRegExpIteration < SymbolType > *>( rightCon->getRight().get() );
-		if( rightRightIte ) {
-			if(rightRightIte->getElement() == rightCon->getLeftElement()) {
-				n = rightCon->getRight().release();
+		FormalRegExpIteration < SymbolType > * rightRightIte = dynamic_cast < FormalRegExpIteration < SymbolType > * > ( & rightCon->getRight ( ) );
+		if ( rightRightIte ) {
+			if ( rightRightIte->getElement ( ) == rightCon->getLeftElement ( ) ) {
+				n = std::move ( rightCon->getRight ( ) ).clone ( );
 				delete node;
 				return true;
 			}
 		}
 	}
 
-	if( dynamic_cast<FormalRegExpEpsilon < SymbolType > *>( node->getRight().get() ) ) {
-		FormalRegExpConcatenation < SymbolType > * leftCon = dynamic_cast<FormalRegExpConcatenation < SymbolType > *>( node->getLeft().get() );
-		if( ! leftCon ) return false;
+	if ( dynamic_cast < FormalRegExpEpsilon < SymbolType > * > ( & node->getRight ( ) ) ) {
+		FormalRegExpConcatenation < SymbolType > * leftCon = dynamic_cast < FormalRegExpConcatenation < SymbolType > * > ( & node->getLeft ( ) );
+		if ( ! leftCon ) return false;
 
-		FormalRegExpIteration < SymbolType > * leftLeftIte = dynamic_cast<FormalRegExpIteration < SymbolType > *>( leftCon->getLeft().get() );
-		if( leftLeftIte ) {
-			if(leftLeftIte->getElement() == leftCon->getRightElement()) {
-				n = leftCon->getLeft().release();
+		FormalRegExpIteration < SymbolType > * leftLeftIte = dynamic_cast < FormalRegExpIteration < SymbolType > * > ( & leftCon->getLeft ( ) );
+		if ( leftLeftIte ) {
+			if ( leftLeftIte->getElement ( ) == leftCon->getRightElement ( ) ) {
+				n = std::move ( leftCon->getLeft ( ) ).clone ( );
 				delete node;
 				return true;
 			}
 		}
 
-		FormalRegExpIteration < SymbolType > * leftRightIte = dynamic_cast<FormalRegExpIteration < SymbolType > *>( leftCon->getRight().get() );
-		if( leftRightIte ) {
-			if(leftRightIte->getElement() == leftCon->getLeftElement()) {
-				n = leftCon->getRight().release();
+		FormalRegExpIteration < SymbolType > * leftRightIte = dynamic_cast < FormalRegExpIteration < SymbolType > * > ( & leftCon->getRight ( ) );
+		if ( leftRightIte ) {
+			if ( leftRightIte->getElement ( ) == leftCon->getLeftElement ( ) ) {
+				n = std::move ( leftCon->getRight ( ) ).clone ( );
 				delete node;
 				return true;
 			}
@@ -398,13 +387,13 @@ bool RegExpOptimize::A11( FormalRegExpElement < SymbolType > * & n ) {
 	FormalRegExpIteration < SymbolType > * node = dynamic_cast<FormalRegExpIteration < SymbolType > *>( n );
 	if( ! node ) return false;
 
-	FormalRegExpAlternation < SymbolType > * childAlt = dynamic_cast<FormalRegExpAlternation < SymbolType > *>( node->getChild().get() );
-	if( childAlt ) {
-		if( dynamic_cast < FormalRegExpEpsilon < SymbolType > * > ( childAlt->getLeft ( ).get ( ) ) ) {
+	FormalRegExpAlternation < SymbolType > * childAlt = dynamic_cast < FormalRegExpAlternation < SymbolType > * > ( & node->getChild ( ) );
+	if ( childAlt ) {
+		if ( dynamic_cast < FormalRegExpEpsilon < SymbolType > * > ( & childAlt->getLeft ( ) ) ) {
 			node->setChild ( std::move ( childAlt->getRight ( ) ) );
 			return true;
 		}
-		if( dynamic_cast < FormalRegExpEpsilon < SymbolType > * > ( childAlt->getRight ( ).get ( ) ) ) {
+		if ( dynamic_cast < FormalRegExpEpsilon < SymbolType > * > ( & childAlt->getRight ( ) ) ) {
 			node->setChild ( std::move ( childAlt->getLeft ( ) ) );
 			return true;
 		}
@@ -424,12 +413,12 @@ bool RegExpOptimize::V1( FormalRegExpElement < SymbolType > * & n ) {
 	FormalRegExpIteration < SymbolType > * node = dynamic_cast<FormalRegExpIteration < SymbolType > *>( n );
 	if( ! node ) return false;
 
-	if( dynamic_cast<FormalRegExpEmpty< SymbolType > *>( node->getChild ( ).get() ) ) {
+	if ( dynamic_cast < FormalRegExpEmpty < SymbolType > * > ( & node->getChild ( ) ) ) {
 		delete node;
 		n = new FormalRegExpEpsilon < SymbolType > ( );
 		return true;
 	}
-	if( dynamic_cast<FormalRegExpEpsilon < SymbolType > *>( node->getChild ( ).get() ) ) {
+	if ( dynamic_cast<FormalRegExpEpsilon < SymbolType > * > ( & node->getChild ( ) ) ) {
 		delete node;
 		n = new FormalRegExpEpsilon < SymbolType > ( );
 		return true;
@@ -447,19 +436,19 @@ bool RegExpOptimize::V2( FormalRegExpElement < SymbolType > * & n ) {
 	FormalRegExpAlternation < SymbolType > * node = dynamic_cast<FormalRegExpAlternation < SymbolType > *>( n );
 	if( ! node ) return false;
 
-	FormalRegExpIteration < SymbolType > * leftIte = dynamic_cast<FormalRegExpIteration < SymbolType > *>( node->getLeft().get() );
-	if( leftIte ) {
-		if(leftIte->getElement() == node->getRightElement()) {
-			n = node->getLeft().release();
+	FormalRegExpIteration < SymbolType > * leftIte = dynamic_cast < FormalRegExpIteration < SymbolType > * > ( & node->getLeft ( ) );
+	if ( leftIte ) {
+		if ( leftIte->getElement ( ) == node->getRightElement ( ) ) {
+			n = std::move ( node->getLeft ( ) ).clone ( );
 			delete node;
 			return true;
 		}
 	}
 
-	FormalRegExpIteration < SymbolType > * rightIte = dynamic_cast<FormalRegExpIteration < SymbolType > *>( node->getRight().get() );
-	if( rightIte ) {
-		if(rightIte->getElement() == node->getLeftElement()) {
-			n = node->getRight().release();
+	FormalRegExpIteration < SymbolType > * rightIte = dynamic_cast < FormalRegExpIteration < SymbolType > * > ( & node->getRight ( ) );
+	if ( rightIte ) {
+		if ( rightIte->getElement ( ) == node->getLeftElement ( ) ) {
+			n = std::move ( node->getRight ( ) ).clone ( );
 			delete node;
 			return true;
 		}
@@ -478,7 +467,7 @@ bool RegExpOptimize::V3( FormalRegExpElement < SymbolType > * & n ) {
 	FormalRegExpIteration < SymbolType > * node = dynamic_cast<FormalRegExpIteration < SymbolType > *>( n );
 	if( ! node ) return false;
 
-	FormalRegExpIteration < SymbolType >* childIter = dynamic_cast<FormalRegExpIteration < SymbolType >*>( node->getChild().get() );
+	FormalRegExpIteration < SymbolType > * childIter = dynamic_cast < FormalRegExpIteration < SymbolType > * > ( & node->getChild ( ) );
 	if( childIter ) {
 		node->setChild ( std::move ( childIter->getChild ( ) ) );
 		return true;
@@ -494,21 +483,21 @@ bool RegExpOptimize::V3( FormalRegExpElement < SymbolType > * & n ) {
   */
 template < class SymbolType >
 bool RegExpOptimize::V4( FormalRegExpElement < SymbolType > * & n ) {
-	FormalRegExpIteration < SymbolType > * node = dynamic_cast<FormalRegExpIteration < SymbolType > *>( n );
+	FormalRegExpIteration < SymbolType > * node = dynamic_cast < FormalRegExpIteration < SymbolType > *>( n );
 	if( ! node ) return false;
 
-	FormalRegExpConcatenation < SymbolType > * child = dynamic_cast<FormalRegExpConcatenation < SymbolType > *>( node->getChild().get() );
+	FormalRegExpConcatenation < SymbolType > * child = dynamic_cast < FormalRegExpConcatenation < SymbolType > * > ( & node->getChild ( ) );
 	if( ! child ) return false;
 
-	FormalRegExpIteration < SymbolType > * leftIte = dynamic_cast<FormalRegExpIteration < SymbolType > *>( child->getLeft().get() );
+	FormalRegExpIteration < SymbolType > * leftIte = dynamic_cast < FormalRegExpIteration < SymbolType > * > ( & child->getLeft ( ) );
 	if( ! leftIte ) return false;
 
-	FormalRegExpIteration < SymbolType > * rightIte = dynamic_cast<FormalRegExpIteration < SymbolType > *>( child->getRight().get() );
+	FormalRegExpIteration < SymbolType > * rightIte = dynamic_cast < FormalRegExpIteration < SymbolType > * > ( & child->getRight ( ) );
 	if( ! rightIte ) return false;
 
-	n = new FormalRegExpIteration < SymbolType >( FormalRegExpAlternation < SymbolType >(std::move( leftIte->getElement ( ) ), std::move( rightIte->getElement ( ) ) ) );
+	node->setChild ( FormalRegExpAlternation < SymbolType >( std::move ( leftIte->getElement ( ) ), std::move ( rightIte->getElement ( ) ) ) );
 
-	delete node;
+	delete child;
 	return true;
 }
 
@@ -559,18 +548,23 @@ bool RegExpOptimize::V9( FormalRegExpElement < SymbolType > * & /* n */) {
   */
 template < class SymbolType >
 bool RegExpOptimize::V10( FormalRegExpElement < SymbolType > * & n ) {
-	FormalRegExpAlternation < SymbolType > * node = dynamic_cast<FormalRegExpAlternation < SymbolType > *>( n );
+	FormalRegExpIteration < SymbolType > * node = dynamic_cast < FormalRegExpIteration < SymbolType > *>( n );
 	if( ! node ) return false;
 
-	FormalRegExpIteration < SymbolType > * leftIte = dynamic_cast<FormalRegExpIteration < SymbolType > *>( node->getLeft().get() );
+	FormalRegExpAlternation < SymbolType > * alt = dynamic_cast < FormalRegExpAlternation < SymbolType > * > ( & node->getChild ( ) );
+	if( ! alt ) return false;
+
+	FormalRegExpIteration < SymbolType > * leftIte = dynamic_cast < FormalRegExpIteration < SymbolType > * > ( & alt->getLeft ( ) );
 	if( ! leftIte ) return false;
 
-	FormalRegExpIteration < SymbolType > * rightIte = dynamic_cast<FormalRegExpIteration < SymbolType > *>( node->getRight().get() );
+	FormalRegExpIteration < SymbolType > * rightIte = dynamic_cast < FormalRegExpIteration < SymbolType > * > ( & alt->getRight ( ) );
 	if( ! rightIte ) return false;
 
-	n = new FormalRegExpConcatenation < SymbolType >(std::move( leftIte->getElement() ), std::move( rightIte->getElement() ) );
+	alt->setLeft ( std::move ( leftIte->getChild ( ) ) );
+	alt->setRight ( std::move ( rightIte->getChild ( ) ) );
 
-	delete node;
+	delete leftIte;
+	delete rightIte;
 	return true;
 }
 
@@ -584,19 +578,19 @@ bool RegExpOptimize::X1( FormalRegExpElement < SymbolType > * & n ) {
 	FormalRegExpAlternation < SymbolType > * node = dynamic_cast<FormalRegExpAlternation < SymbolType > *>( n );
 	if( ! node ) return false;
 
-	FormalRegExpIteration < SymbolType > * leftIte = dynamic_cast<FormalRegExpIteration < SymbolType > *>( node->getLeft().get() );
-	if( leftIte ) {
-		if(dynamic_cast<FormalRegExpEpsilon < SymbolType > *>(node->getRight().get())) {
-			n = node->getLeft().release();
+	FormalRegExpIteration < SymbolType > * leftIte = dynamic_cast < FormalRegExpIteration < SymbolType > * > ( & node->getLeft ( ) );
+	if ( leftIte ) {
+		if ( dynamic_cast < FormalRegExpEpsilon < SymbolType > * > ( & node->getRight ( ) ) ) {
+			n = std::move ( node->getLeft ( ) ).clone ( );
 			delete node;
 			return true;
 		}
 	}
 
-	FormalRegExpIteration < SymbolType > * rightIte = dynamic_cast<FormalRegExpIteration < SymbolType > *>( node->getRight().get() );
-	if( rightIte ) {
-		if(dynamic_cast<FormalRegExpEpsilon < SymbolType > *>(node->getLeft().get())) {
-			n = node->getRight().release();
+	FormalRegExpIteration < SymbolType > * rightIte = dynamic_cast < FormalRegExpIteration < SymbolType > * > ( & node->getRight ( ) );
+	if ( rightIte ) {
+		if ( dynamic_cast < FormalRegExpEpsilon < SymbolType > * > ( & node->getLeft ( ) ) ) {
+			n = std::move ( node->getRight ( ) ).clone ( );
 			delete node;
 			return true;
 		}
diff --git a/alib2algo/src/regexp/simplify/RegExpOptimizeUnboundedPart.hpp b/alib2algo/src/regexp/simplify/RegExpOptimizeUnboundedPart.hpp
index ba743ec80f..7c70103e14 100644
--- a/alib2algo/src/regexp/simplify/RegExpOptimizeUnboundedPart.hpp
+++ b/alib2algo/src/regexp/simplify/RegExpOptimizeUnboundedPart.hpp
@@ -5,6 +5,8 @@
  *	  Author: Tomas Pecka
  */
 
+#include <iostream>
+
 namespace regexp {
 
 namespace simplify {
@@ -12,36 +14,28 @@ namespace simplify {
 template < class SymbolType >
 void RegExpOptimize::optimize( UnboundedRegExpAlternation < SymbolType > & alt ) {
 	for( unsigned i = 0; i < alt.getChildren ( ).size ( ); i++ )
-		alt.setChild( ext::smart_ptr < UnboundedRegExpElement < SymbolType > > ( optimizeInner( * alt.getChildren ( ) [ i ] ) ), i );
+		alt.setChild ( optimizeInner ( alt.getChildren ( ) [ i ] ), i );
 
-	while( A1( alt ) || A2( alt ) || A3( alt ) || A4( alt ) || A10( alt ) || V2( alt ) || V5( alt ) || V6( alt ) || X1( alt ) );
+	while ( A1( alt ) || A2( alt ) || A3( alt ) || A4( alt ) || A10( alt ) || V2( alt ) || V5( alt ) || V6( alt ) || X1( alt ) );
 }
 
 template < class SymbolType >
 void RegExpOptimize::optimize( UnboundedRegExpConcatenation < SymbolType > & concat ) {
 	for( unsigned i = 0; i < concat.getChildren ( ).size ( ); i++ )
-		concat.setChild( ext::smart_ptr < UnboundedRegExpElement < SymbolType > > ( optimizeInner( * concat.getChildren ( ) [ i ] ) ), i );
+		concat.setChild ( optimizeInner ( concat.getChildren ( ) [ i ] ), i );
 
-	while( A5( concat ) || A6( concat ) || A7( concat ) || A8( concat ) || A9( concat ) || V8( concat ) );//|| V9( concat ) );
+	while ( A5( concat ) || A6( concat ) || A7( concat ) || A8( concat ) || A9( concat ) || V8( concat ) || V9( concat ) );
 }
 
 template < class SymbolType >
 void RegExpOptimize::optimize( UnboundedRegExpIteration < SymbolType > & iter ) {
-	iter.setChild ( ext::smart_ptr < UnboundedRegExpElement < SymbolType > > ( optimizeInner ( * iter.getChild ( ) ) ) );
-	do {
-		// V1 is implemented right here
-		if( dynamic_cast<UnboundedRegExpEmpty < SymbolType >*>( iter.getChild ( ).get() ) ) {
-			return;
-		}
-		// T1 is implemented right here \e* = \e
-		if( dynamic_cast<UnboundedRegExpEpsilon < SymbolType >*>( iter.getChild ( ).get() ) ) {
-			return;
-		}
-	} while( A11( iter ) || V1( iter ) || V3( iter ) || V4( iter ) || V10( iter ) );
+	iter.setChild ( optimizeInner ( iter.getChild ( ) ) );
+
+	while ( A11( iter ) || V1( iter ) || V3( iter ) || V4( iter ) || V10( iter ) );
 }
 
 template < class SymbolType >
-UnboundedRegExpElement < SymbolType >* RegExpOptimize::optimizeInner( const UnboundedRegExpElement < SymbolType > & node ) {
+ext::rvalue_ref < regexp::UnboundedRegExpElement < SymbolType > > RegExpOptimize::optimizeInner( const UnboundedRegExpElement < SymbolType > & node ) {
 	const UnboundedRegExpAlternation < SymbolType > * alternation = dynamic_cast<const UnboundedRegExpAlternation < SymbolType >*>( & node );
 	if( alternation )
 		return optimizeInner( * alternation );
@@ -70,86 +64,72 @@ UnboundedRegExpElement < SymbolType >* RegExpOptimize::optimizeInner( const Unbo
 }
 
 template < class SymbolType >
-UnboundedRegExpElement < SymbolType > * RegExpOptimize::optimizeInner( const UnboundedRegExpAlternation < SymbolType > & node ) {
-	UnboundedRegExpAlternation < SymbolType >* alt = new UnboundedRegExpAlternation < SymbolType >( );
+ext::rvalue_ref < regexp::UnboundedRegExpElement < SymbolType > > RegExpOptimize::optimizeInner( const UnboundedRegExpAlternation < SymbolType > & node ) {
+	UnboundedRegExpAlternation < SymbolType > alt;
 
-	for( const auto & child : node.getElements ( ) )
-		alt->pushBackChild( ext::smart_ptr < UnboundedRegExpElement < SymbolType > > ( optimizeInner( * child ) ) );
+	for( const UnboundedRegExpElement < SymbolType > & child : node.getElements ( ) )
+		alt.pushBackChild ( optimizeInner( child ) );
 
 	// optimize while you can
-	while( A1( * alt ) || A2( * alt ) || A3( * alt ) || A4( * alt ) || A10( * alt ) || V2( * alt ) || V5( * alt ) || V6( * alt ) || X1( * alt ) );
+	while( A1 ( alt ) || A2 ( alt ) || A3 ( alt ) || A4 ( alt ) || A10 ( alt ) || V2 ( alt ) || V5 ( alt ) || V6 ( alt ) || X1 ( alt ) );
 
-	if( alt->getElements ( ).size( ) == 1 ) {
-		UnboundedRegExpElement < SymbolType >* ret = alt->getChildren ( ).front ( ).release ( );
-		delete alt;
-		return ret;
-	}
+	if( alt.getElements ( ).size( ) == 1 )
+		return ext::rvalue_ref < regexp::UnboundedRegExpElement < SymbolType > > ( std::move ( alt.getChildren ( ).front ( ) ).clone() );
 
-	if( alt->getElements ( ).size( ) == 0 ) {
-		delete alt;
-		return new UnboundedRegExpEmpty < SymbolType >( );
-	}
+	if( alt.getElements ( ).size( ) == 0 )
+		return ext::rvalue_ref < regexp::UnboundedRegExpElement < SymbolType > > ( new UnboundedRegExpEmpty < SymbolType > ( ) );
 
-	return alt;
+	return ext::rvalue_ref < regexp::UnboundedRegExpElement < SymbolType > > ( alt.clone ( ) );
 }
 
 template < class SymbolType >
-UnboundedRegExpElement < SymbolType > * RegExpOptimize::optimizeInner( const UnboundedRegExpConcatenation < SymbolType > & node ) {
-	UnboundedRegExpConcatenation < SymbolType >* concat = new UnboundedRegExpConcatenation < SymbolType >( );
+ext::rvalue_ref < regexp::UnboundedRegExpElement < SymbolType > > RegExpOptimize::optimizeInner( const UnboundedRegExpConcatenation < SymbolType > & node ) {
+	UnboundedRegExpConcatenation < SymbolType > concat;
 
-	for( const auto & child : node.getElements ( ) )
-		concat->pushBackChild ( ext::smart_ptr < UnboundedRegExpElement < SymbolType > > ( optimizeInner( * child ) ) );
+	for( const UnboundedRegExpElement < SymbolType > & child : node.getElements ( ) )
+		concat.pushBackChild ( optimizeInner( child ) );
 
-	while( A5( * concat ) || A6( * concat ) || A7( * concat ) || A8( * concat ) || A9( * concat ) || V8( * concat ) );//|| V9( * concat ) );
+	while( A5 ( concat ) || A6 ( concat ) || A7 ( concat ) || A8 ( concat ) || A9 ( concat ) || V8 ( concat ) || V9 ( concat ) );
 
-	if( concat->getElements ( ).size( ) == 1 ) {
-		UnboundedRegExpElement < SymbolType >* ret = concat->getChildren ( ).front( ).release();
-		delete concat;
-		return ret;
-	}
+	if( concat.getElements ( ).size( ) == 1 )
+		return ext::rvalue_ref < regexp::UnboundedRegExpElement < SymbolType > > ( std::move ( concat.getChildren ( ).front ( ) ).clone() );
 
-	if( concat->getElements ( ).size( ) == 0 ) {
-		delete concat;
-		return new UnboundedRegExpEpsilon < SymbolType >( );
-	}
+	if( concat.getElements ( ).size( ) == 0 )
+		return ext::rvalue_ref < regexp::UnboundedRegExpElement < SymbolType > > ( new UnboundedRegExpEpsilon < SymbolType > ( ) );
 
-	return concat;
+	return ext::rvalue_ref < regexp::UnboundedRegExpElement < SymbolType > > ( concat.clone ( ) );
 }
 
 template < class SymbolType >
-UnboundedRegExpElement < SymbolType > * RegExpOptimize::optimizeInner( const UnboundedRegExpIteration < SymbolType > & node ) {
-	UnboundedRegExpIteration < SymbolType >* iter = new UnboundedRegExpIteration < SymbolType >( UnboundedRegExpEmpty < SymbolType > {} );
-	iter->setChild ( ext::smart_ptr < UnboundedRegExpElement < SymbolType > > ( optimizeInner ( * node.getChild ( ) ) ) );
-
-	do {
-		// V1 is implemented right here
-		if( dynamic_cast<UnboundedRegExpEmpty < SymbolType >*>( iter->getChild ( ).get() ) ) {
-			delete iter;
-			return new UnboundedRegExpEpsilon < SymbolType >( );
-		}
-		// T1 is implemented right here \e* = \e
-		if( dynamic_cast<UnboundedRegExpEpsilon < SymbolType >*>( iter->getChild ( ).get() ) ) {
-			delete iter;
-			return new UnboundedRegExpEpsilon < SymbolType >( );
-		}
-	} while( A11( * iter ) || V1( * iter ) || V3( * iter ) || V4( * iter ) || V10( * iter ) );
+ext::rvalue_ref < regexp::UnboundedRegExpElement < SymbolType > > RegExpOptimize::optimizeInner( const UnboundedRegExpIteration < SymbolType > & node ) {
+	UnboundedRegExpIteration < SymbolType > iter ( optimizeInner ( node.getChild ( ) ) );
 
-	return iter;
+	while ( A11 ( iter ) || V1 ( iter ) || V3 ( iter ) || V4 ( iter ) || V10 ( iter ) );
+
+	// V1 is implemented right here
+	if( dynamic_cast < UnboundedRegExpEmpty < SymbolType > * > ( & iter.getChild ( ) ) )
+		return ext::rvalue_ref < regexp::UnboundedRegExpElement < SymbolType > > ( new UnboundedRegExpEpsilon < SymbolType > ( ) );
+
+	// T1 is implemented right here \e* = \e
+	if ( dynamic_cast < UnboundedRegExpEpsilon < SymbolType > * > ( & iter.getChild ( ) ) )
+		return ext::rvalue_ref < regexp::UnboundedRegExpElement < SymbolType > > ( new UnboundedRegExpEpsilon < SymbolType > ( ) );
+
+	return ext::rvalue_ref < regexp::UnboundedRegExpElement < SymbolType > > ( iter.clone ( ) );
 }
 
 template < class SymbolType >
-UnboundedRegExpElement < SymbolType > * RegExpOptimize::optimizeInner( const UnboundedRegExpSymbol < SymbolType > & node ) {
-	return node.clone( );
+ext::rvalue_ref < regexp::UnboundedRegExpElement < SymbolType > > RegExpOptimize::optimizeInner( const UnboundedRegExpSymbol < SymbolType > & node ) {
+	return ext::rvalue_ref < regexp::UnboundedRegExpElement < SymbolType > > ( node.clone ( ) );
 }
 
 template < class SymbolType >
-UnboundedRegExpElement < SymbolType > * RegExpOptimize::optimizeInner( const UnboundedRegExpEmpty < SymbolType > & node ) {
-	return node.clone( );
+ext::rvalue_ref < regexp::UnboundedRegExpElement < SymbolType > > RegExpOptimize::optimizeInner( const UnboundedRegExpEmpty < SymbolType > & node ) {
+	return ext::rvalue_ref < regexp::UnboundedRegExpElement < SymbolType > > ( node.clone ( ) );
 }
 
 template < class SymbolType >
-UnboundedRegExpElement < SymbolType > * RegExpOptimize::optimizeInner( const UnboundedRegExpEpsilon < SymbolType > & node ) {
-	return node.clone( );
+ext::rvalue_ref < regexp::UnboundedRegExpElement < SymbolType > > RegExpOptimize::optimizeInner( const UnboundedRegExpEpsilon < SymbolType > & node ) {
+	return ext::rvalue_ref < regexp::UnboundedRegExpElement < SymbolType > > ( node.clone ( ) );
 }
 
 /**
@@ -162,11 +142,11 @@ bool RegExpOptimize::A1( UnboundedRegExpAlternation < SymbolType > & node ) {
 	bool optimized = false;
 
 	for( auto it = node.getChildren ( ).begin( ); it != node.getChildren ( ).end( ); ) {
-		if( dynamic_cast < UnboundedRegExpAlternation < SymbolType > * > ( it->get ( ) ) ) {
-			ext::smart_ptr < UnboundedRegExpAlternation < SymbolType > > childAlt ( static_cast < UnboundedRegExpAlternation < SymbolType > * >( it->release() ) );
+		if( dynamic_cast < UnboundedRegExpAlternation < SymbolType > * > ( & * it ) ) {
+			UnboundedRegExpAlternation < SymbolType > childAlt ( static_cast < UnboundedRegExpAlternation < SymbolType > && > ( std::move ( * it ) ) );
 			it = node.getChildren ( ).erase( it );
 
-			it = node.insert( it, std::make_move_iterator(childAlt->getChildren ( ).begin ( ) ), std::make_move_iterator(childAlt->getChildren ( ).end ( ) ) );
+			it = node.insert ( it, std::make_move_iterator ( childAlt.getChildren ( ).begin ( ) ), std::make_move_iterator ( childAlt.getChildren ( ).end ( ) ) );
 
  			optimized = true;
 		} else
@@ -183,12 +163,13 @@ bool RegExpOptimize::A1( UnboundedRegExpAlternation < SymbolType > & node ) {
   */
 template < class SymbolType >
 bool RegExpOptimize::A2( UnboundedRegExpAlternation < SymbolType > & node ) {
-	auto cmp = [ ]( const ext::smart_ptr < UnboundedRegExpElement < SymbolType > > & a, const ext::smart_ptr < UnboundedRegExpElement < SymbolType > > & b ) -> bool { return *a < *b; };
 
-	if( std::is_sorted( node.getChildren ( ).begin( ), node.getChildren ( ).end( ), cmp ) )
+	auto cmp = [ ]( const UnboundedRegExpElement < SymbolType > * a, const UnboundedRegExpElement < SymbolType > * b ) -> bool { return * a < * b; };
+
+	if ( std::is_sorted ( node.getChildren ( ).begin( ).base ( ), node.getChildren ( ).end( ).base ( ), cmp ) )
 		return false;
 
-	std::sort( node.getChildren ( ).begin(), node.getChildren ( ).end(), cmp );
+	std::sort ( node.getChildren ( ).begin ( ).base ( ), node.getChildren ( ).end ( ).base ( ), cmp );
 	return true;
 }
 
@@ -203,9 +184,9 @@ bool RegExpOptimize::A3( UnboundedRegExpAlternation < SymbolType > & node ) {
 
 	// alternation with no children is efectively \0
 
-	for( auto it = node.getChildren ( ).begin( ); it != node.getChildren ( ).end( ); ) {
-		if( dynamic_cast < UnboundedRegExpEmpty < SymbolType > * >( it->get ( ) ) ) {
-			it = node.getChildren ( ).erase( it );
+	for( auto it = node.getChildren ( ).begin ( ); it != node.getChildren ( ).end ( ); ) {
+		if( dynamic_cast < UnboundedRegExpEmpty < SymbolType > * >( & * it ) ) {
+			it = node.getChildren ( ).erase ( it );
 
 			optimized = true;
 		} else
@@ -222,6 +203,7 @@ bool RegExpOptimize::A3( UnboundedRegExpAlternation < SymbolType > & node ) {
   */
 template < class SymbolType >
 bool RegExpOptimize::A4( UnboundedRegExpAlternation < SymbolType > & node ) {
+
 	/*
 	 * two ways of implementing this opitimization:
 	 * - sort and call std::unique ( O(n lg n) + O(n) ), but it also sorts...
@@ -229,10 +211,10 @@ bool RegExpOptimize::A4( UnboundedRegExpAlternation < SymbolType > & node ) {
 	 *
 	 * As we always sort in optimization, we can use the first version, but A4 must be __always__ called __after__ A2
 	 */
-	auto cmp = [ ]( const ext::smart_ptr < UnboundedRegExpElement < SymbolType > > & a, const ext::smart_ptr < UnboundedRegExpElement < SymbolType > > & b ) -> bool { return *a == *b; };
+	auto cmp = [ ]( const UnboundedRegExpElement < SymbolType > * a, const UnboundedRegExpElement < SymbolType > * b ) -> bool { return * a == * b; };
 
 	size_t size = node.getChildren ( ).size ( );
-	node.getChildren ( ).erase ( std::unique ( node.getChildren ( ).begin ( ), node.getChildren ( ).end ( ), cmp), node.getChildren ( ).end( ) );
+	node.getChildren ( ).erase ( dereferencer ( ext::unique ( node.getChildren ( ).begin ( ).base ( ), node.getChildren ( ).end ( ).base ( ), cmp ) ), node.getChildren ( ).end( ) );
 
 	return size != node.getChildren ( ).size ( );
 }
@@ -247,15 +229,16 @@ bool RegExpOptimize::A5( UnboundedRegExpConcatenation < SymbolType > & node ) {
 	bool optimized = false;
 
 	for( auto it = node.getChildren ( ).begin( ); it != node.getChildren ( ).end( ); ) {
-		if( dynamic_cast<UnboundedRegExpConcatenation < SymbolType > *>( it->get() ) ) {
-			ext::smart_ptr < UnboundedRegExpConcatenation < SymbolType > > childConcat ( static_cast<UnboundedRegExpConcatenation < SymbolType > *>( it->release() ) );
-			it = node.getChildren ( ).erase( it );
+		if( dynamic_cast < UnboundedRegExpConcatenation < SymbolType > * > ( & * it ) ) {
+
+			UnboundedRegExpConcatenation < SymbolType > childConcat = static_cast < UnboundedRegExpConcatenation < SymbolType > && > ( std::move ( * it ) );
+			it = node.getChildren ( ).erase ( it );
 
-			it = node.insert( it, std::make_move_iterator(childConcat->getChildren ( ).begin( )), std::make_move_iterator(childConcat->getChildren ( ).end( ) ));
+			it = node.insert ( it, std::make_move_iterator ( childConcat.getChildren ( ).begin( ) ), std::make_move_iterator ( childConcat.getChildren ( ).end( ) ) );
 
 			optimized = true;
 		} else
-			it ++;
+			++ it;
 	}
 
 	return optimized;
@@ -273,12 +256,12 @@ bool RegExpOptimize::A6( UnboundedRegExpConcatenation < SymbolType > & node ) {
 	// concatenation with no children is efectively \e
 
 	for( auto it = node.getChildren ( ).begin( ); it != node.getChildren ( ).end( ); ) {
-		if( dynamic_cast < UnboundedRegExpEpsilon < SymbolType > * >( it->get ( ) ) ) {
-			it = node.getChildren ( ).erase( it );
+		if ( dynamic_cast < UnboundedRegExpEpsilon < SymbolType > * > ( & * it ) ) {
+			it = node.getChildren ( ).erase ( it );
 
 			optimized = true;
 		} else
-			it ++;
+			++ it;
 	}
 
 	return optimized;
@@ -291,11 +274,12 @@ bool RegExpOptimize::A6( UnboundedRegExpConcatenation < SymbolType > & node ) {
   */
 template < class SymbolType >
 bool RegExpOptimize::A7( UnboundedRegExpConcatenation < SymbolType > & node ) {
+
 	if(node.getChildren ( ).size() == 1) return false;
 
-	if( std::any_of( node.getChildren ( ).begin( ), node.getChildren ( ).end( ), []( const ext::smart_ptr < UnboundedRegExpElement < SymbolType > > & a ) -> bool{ return dynamic_cast < UnboundedRegExpEmpty < SymbolType > * >( a.get() ); } ) ) {
+	if( std::any_of ( node.getChildren ( ).begin( ), node.getChildren ( ).end( ), [ ] ( const UnboundedRegExpElement < SymbolType > & a ) -> bool { return dynamic_cast < const UnboundedRegExpEmpty < SymbolType > * > ( & a ); } ) ) {
 		node.getChildren ( ).clear( );
-		node.pushBackChild( ext::smart_ptr < UnboundedRegExpElement < SymbolType > > ( new UnboundedRegExpEmpty < SymbolType >( ) ) );
+		node.pushBackChild ( UnboundedRegExpEmpty < SymbolType > ( ) );
 
 		return true;
 	}
@@ -408,7 +392,7 @@ bool RegExpOptimize::A9( UnboundedRegExpConcatenation < SymbolType > & /* node *
   * @return bool true if optimization applied else false
   */
 template < class SymbolType >
-bool RegExpOptimize::A10( UnboundedRegExpAlternation < SymbolType > & node ) {
+bool RegExpOptimize::A10( UnboundedRegExpAlternation < SymbolType > & /* node */ ) {
 	bool optimized = false;
 
 	/*
@@ -418,37 +402,35 @@ bool RegExpOptimize::A10( UnboundedRegExpAlternation < SymbolType > & node ) {
 	 */
 
 	// check if we have some epsilon or iteration left, else nothing to do
-	auto eps = find_if( node.getElements().begin( ), node.getElements().end( ), [ ]( const ext::smart_ptr < UnboundedRegExpElement < SymbolType > > & a ) -> bool {
-		return dynamic_cast<UnboundedRegExpEpsilon < SymbolType > const *>( a.get() ) || dynamic_cast<UnboundedRegExpIteration < SymbolType > const*>( a.get() );
+	/*auto eps = find_if( node.getElements().begin( ), node.getElements().end( ), [ ]( const UnboundedRegExpElement < SymbolType > & a ) -> bool {
+		return dynamic_cast < const UnboundedRegExpEpsilon < SymbolType > * > ( & a ) || dynamic_cast < const UnboundedRegExpIteration < SymbolType > * > ( & a  );
 	});
 
 	if( eps == node.getElements().end( ) )
 		return false;
 
 	for( unsigned i = 0; i < node.getChildren ( ).size ( ); i++ ) {
-		UnboundedRegExpConcatenation < SymbolType > * childConcat = dynamic_cast<UnboundedRegExpConcatenation < SymbolType > *>( node.getChildren ( ) [ i ].get ( ) );
+		UnboundedRegExpConcatenation < SymbolType > * childConcat = dynamic_cast < UnboundedRegExpConcatenation < SymbolType > * > ( & node.getChildren ( ) [ i ]  );
 		if( ! childConcat )
 			continue;
 
 		// if iteration is first element of concatenation
-		UnboundedRegExpIteration < SymbolType > * iter = dynamic_cast<UnboundedRegExpIteration < SymbolType > *>( childConcat->getElements().front( ).get() );
+		UnboundedRegExpIteration < SymbolType > * iter = dynamic_cast < UnboundedRegExpIteration < SymbolType > * > ( & childConcat->getElements ( ).front( ) );
 		if( ! iter )
 			continue;
 
 		// concatenation without the iteration node
 		UnboundedRegExpConcatenation < SymbolType > tmpConcat ( * childConcat );
-		tmpConcat.getChildren ( ).erase( tmpConcat.getChildren ( ).begin( ) );
-		UnboundedRegExpElement < SymbolType > * tmpConcatOpt = optimizeInner ( tmpConcat );
+		tmpConcat.getChildren ( ).erase ( tmpConcat.getChildren ( ).begin( ) );
+		ext::rvalue_ref < UnboundedRegExpElement < SymbolType > > tmpConcatOpt = optimizeInner ( tmpConcat );
 
 		// check if the iteration element is the same as the rest of the concatenation
-		if( iter->getElement() == * tmpConcatOpt ) {
+		if( iter->getElement() == tmpConcatOpt ) {
 			optimized = true;
 
 			node.setChild ( std::move ( childConcat->getElements().front() ), i );
 		}
-
-		delete tmpConcatOpt;
-	}
+	} */
 
 	return optimized;
 }
@@ -460,20 +442,21 @@ bool RegExpOptimize::A10( UnboundedRegExpAlternation < SymbolType > & node ) {
   */
 template < class SymbolType >
 bool RegExpOptimize::A11( UnboundedRegExpIteration < SymbolType > & node ) {
-	UnboundedRegExpAlternation < SymbolType > * childAlt = dynamic_cast<UnboundedRegExpAlternation < SymbolType > *>( node.getChild ( ).get() );
+
+	UnboundedRegExpAlternation < SymbolType > * childAlt = dynamic_cast<UnboundedRegExpAlternation < SymbolType > * >( & node.getChild ( ) );
 
 	if( childAlt ) {
 		// check if eps inside iteration's alternation
-		auto eps = find_if( childAlt->getChildren ( ).begin( ), childAlt->getChildren ( ).end( ), [ ]( const ext::smart_ptr < UnboundedRegExpElement < SymbolType > > & a ) -> bool {
-			return dynamic_cast<UnboundedRegExpEpsilon < SymbolType > *>( a.get() );
+		auto eps = find_if ( childAlt->getChildren ( ).begin( ), childAlt->getChildren ( ).end( ), [ ] ( const UnboundedRegExpElement < SymbolType > & a ) -> bool {
+			return dynamic_cast < const UnboundedRegExpEpsilon < SymbolType > * > ( & a );
 		});
 
 		// if no eps
-		if( eps == childAlt->getChildren ( ).end( ) )
+		if ( eps == childAlt->getChildren ( ).end( ) )
 			return false;
 
 		// remove eps from alternation
-		childAlt->getChildren ( ).erase( eps );
+		childAlt->getChildren ( ).erase ( eps );
 		return true;
 	}
 
@@ -498,7 +481,7 @@ bool RegExpOptimize::V1( UnboundedRegExpIteration < SymbolType > &) {
   * @return bool true if optimization applied else false
   */
 template < class SymbolType >
-bool RegExpOptimize::V2( UnboundedRegExpAlternation < SymbolType > & node ) {
+bool RegExpOptimize::V2( UnboundedRegExpAlternation < SymbolType > & /* node */ ) {
 	bool optimized = false;
 
 	/*
@@ -506,24 +489,24 @@ bool RegExpOptimize::V2( UnboundedRegExpAlternation < SymbolType > & node ) {
 	 * We need also to cover the cases like ( a + b + d )* + ( e )* + a + b + c + e = ( a + b + d )* + ( e )* + c
 	 */
 
-	ext::vector < UnboundedRegExpElement < SymbolType > * > iterElements;
-	// cache  iter elements because of operator invalidation after erase
-	for( const ext::smart_ptr < UnboundedRegExpElement < SymbolType > > & n : node.getElements ( ) ) {
-		UnboundedRegExpIteration < SymbolType > * iter = dynamic_cast < UnboundedRegExpIteration < SymbolType > * > ( n.get ( ) );
+	/*ext::vector < const UnboundedRegExpElement < SymbolType > * > iterElements;
+	// cache iter elements because of operator invalidation after erase
+	for( const UnboundedRegExpElement < SymbolType > & n : node.getElements ( ) ) {
+		const UnboundedRegExpIteration < SymbolType > * iter = dynamic_cast < const UnboundedRegExpIteration < SymbolType > * > ( & n );
 		if( iter ) {
-			UnboundedRegExpAlternation < SymbolType > * inner = dynamic_cast < UnboundedRegExpAlternation < SymbolType > * > ( iter->getChild ( ).get ( ) );
+			const UnboundedRegExpAlternation < SymbolType > * inner = dynamic_cast < const UnboundedRegExpAlternation < SymbolType > * > ( & iter->getChild ( ) );
 			if ( inner )
-				for ( const ext::smart_ptr < UnboundedRegExpElement < SymbolType > > & innerElement : inner->getElements ( ) )
-					iterElements.push_back ( innerElement.get() );
+				for ( const UnboundedRegExpElement < SymbolType > & innerElement : inner->getElements ( ) )
+					iterElements.push_back ( & innerElement );
 			else
-				iterElements.push_back ( iter->getChild ( ).get ( ) );
+				iterElements.push_back ( & iter->getChild ( ) );
 
 		}
 	}
 
-	for( UnboundedRegExpElement < SymbolType > * n : iterElements ) {
-		auto it = find_if( node.getChildren().begin( ), node.getChildren().end( ), [ n ] ( const ext::smart_ptr < UnboundedRegExpElement < SymbolType > > & a ) -> bool {
-			return *a == *n;
+	for( const UnboundedRegExpElement < SymbolType > * n : iterElements ) {
+		auto it = find_if ( node.getChildren ( ).begin ( ), node.getChildren ( ).end ( ), [ n ] ( const UnboundedRegExpElement < SymbolType > & a ) -> bool {
+			return a == *n;
 		});
 
 		if( it == node.getChildren().end() ) {
@@ -531,8 +514,8 @@ bool RegExpOptimize::V2( UnboundedRegExpAlternation < SymbolType > & node ) {
 		}
 
 		optimized = true;
-		node.getChildren().erase( it );
-	}
+		node.getChildren ( ).erase( it );
+	}*/
 
 	return optimized;
 }
@@ -543,9 +526,10 @@ bool RegExpOptimize::V2( UnboundedRegExpAlternation < SymbolType > & node ) {
   * @return bool true if optimization applied else false
   */
 template < class SymbolType >
-bool RegExpOptimize::V3( UnboundedRegExpIteration < SymbolType > & node ) {
-	UnboundedRegExpIteration < SymbolType >* childIter = dynamic_cast<UnboundedRegExpIteration < SymbolType >*>( node.getChild ( ).get() );
-	if( childIter ) {
+bool RegExpOptimize::V3 ( UnboundedRegExpIteration < SymbolType > & node ) {
+
+	UnboundedRegExpIteration < SymbolType > * childIter = dynamic_cast < UnboundedRegExpIteration < SymbolType > * > ( & node.getChild ( ) );
+	if ( childIter ) {
 		node.setChild ( std::move ( childIter->getChild ( ) ) );
 
 		return true;
@@ -561,17 +545,18 @@ bool RegExpOptimize::V3( UnboundedRegExpIteration < SymbolType > & node ) {
   */
 template < class SymbolType >
 bool RegExpOptimize::V4( UnboundedRegExpIteration < SymbolType > & node ) {
+
 	// interpretation: if iteration's element is concat and every concat's element is iteration
-	UnboundedRegExpConcatenation < SymbolType >* cont = dynamic_cast<UnboundedRegExpConcatenation < SymbolType >*>( node.getChild ( ).get() );
-	if( ! cont || ! all_of( cont->getChildren ( ).begin( ), cont->getChildren ( ).end( ), [] ( const ext::smart_ptr < UnboundedRegExpElement < SymbolType > > & a ) -> bool{ return dynamic_cast<UnboundedRegExpIteration < SymbolType > * >( a.get() ); } ) )
+	UnboundedRegExpConcatenation < SymbolType > * cont = dynamic_cast < UnboundedRegExpConcatenation < SymbolType > * > ( & node.getChild ( ) );
+	if ( ! cont || ! all_of ( cont->getChildren ( ).begin( ), cont->getChildren ( ).end ( ), [ ] ( const UnboundedRegExpElement < SymbolType > & a ) -> bool { return dynamic_cast < const UnboundedRegExpIteration < SymbolType > * > ( & a ); } ) )
 		return false;
 
 	UnboundedRegExpAlternation < SymbolType > newAlt;
 
-	for( const auto & n : cont->getChildren ( ) )
-		newAlt.pushBackChild ( std::move ( static_cast < UnboundedRegExpIteration < SymbolType > * > ( n.get ( ) )->getChild ( ) ) );
+	for ( UnboundedRegExpElement < SymbolType > & n : cont->getChildren ( ) )
+		newAlt.pushBackChild ( std::move ( static_cast < UnboundedRegExpIteration < SymbolType > & > ( n ).getChild ( ) ) );
 
-	node.setChild ( ext::smart_ptr < UnboundedRegExpElement < SymbolType > > ( optimizeInner ( newAlt ) ) );
+	node.setChild ( optimizeInner ( newAlt ) );
 
 	return true;
 }
@@ -582,7 +567,7 @@ bool RegExpOptimize::V4( UnboundedRegExpIteration < SymbolType > & node ) {
   * @return bool true if optimization applied else false
   */
 template < class SymbolType >
-bool RegExpOptimize::V5( UnboundedRegExpAlternation < SymbolType > & node ) {
+bool RegExpOptimize::V5( UnboundedRegExpAlternation < SymbolType > & /* node */ ) {
 	bool optimized = false;
 
 	// reinterpretation: ax*y = ay+ax*xy
@@ -592,15 +577,15 @@ bool RegExpOptimize::V5( UnboundedRegExpAlternation < SymbolType > & node ) {
 	//	y = rest (suffix)
 	// prefix.x*x.suffix + prefix.suffix = prefix.x*.suffix
 
-	for( auto itA = node.getChildren().begin( ); itA != node.getChildren().end( ); ) {
-		UnboundedRegExpConcatenation < SymbolType > * concat = dynamic_cast<UnboundedRegExpConcatenation < SymbolType >*>( itA->get() );
+	/* for( auto itA = node.getChildren().begin( ); itA != node.getChildren().end( ); ) {
+		UnboundedRegExpConcatenation < SymbolType > * concat = dynamic_cast < UnboundedRegExpConcatenation < SymbolType > * > ( & * itA );
 		if( ! concat ) {
 			++ itA;
 			continue;
 		}
 
 		for( auto itC = concat->getChildren().begin( ); itC != std::prev( concat->getChildren().end( ) ); ) {
-			UnboundedRegExpIteration < SymbolType > * iter = dynamic_cast<UnboundedRegExpIteration < SymbolType >*>( itC->get() );
+			UnboundedRegExpIteration < SymbolType > * iter = dynamic_cast < UnboundedRegExpIteration < SymbolType > * > ( & * itC );
 			if( ! iter ) {
 				++ itC;
 				continue;
@@ -610,58 +595,57 @@ bool RegExpOptimize::V5( UnboundedRegExpAlternation < SymbolType > & node ) {
 			auto itStartY = std::next( itC ); //itStartY points to y in expression x*xy
 
 			// if iter's element is concat
-			if( dynamic_cast<UnboundedRegExpConcatenation < SymbolType >*>( iter->getChild().get() ) ) {
-				UnboundedRegExpConcatenation < SymbolType > * iterConcat = dynamic_cast<UnboundedRegExpConcatenation < SymbolType >*>( iter->getChild().get() );
+			if( dynamic_cast < UnboundedRegExpConcatenation < SymbolType > * > ( & iter->getChild ( ) ) ) {
+				UnboundedRegExpConcatenation < SymbolType > * iterConcat = dynamic_cast < UnboundedRegExpConcatenation < SymbolType > * > ( & iter->getChild ( ) );
 
-				if( iterConcat->getChildren().size( ) != ( unsigned ) distance( std::next( itC ), concat->getChildren().end( ) )
-					|| ! equal( iterConcat->getChildren().begin( ), iterConcat->getChildren().end( ), std::next( itC ),
-					[ ]( const ext::smart_ptr < UnboundedRegExpElement < SymbolType > > & a, const ext::smart_ptr < UnboundedRegExpElement < SymbolType > > & b ) -> bool{ return *a == *b; } ) ) {
+				if( iterConcat->getChildren().size( ) != ( unsigned ) distance ( std::next ( itC ), concat->getChildren ( ).end ( ) )
+					|| ! equal ( iterConcat->getChildren ( ).begin ( ), iterConcat->getChildren ( ).end ( ), std::next ( itC ),
+					[ ] ( const UnboundedRegExpElement < SymbolType > & a, const UnboundedRegExpElement < SymbolType > & b ) -> bool { return a == b; } ) ) {
 					++ itC;
 					continue;
 				}
-				advance( itStartY, (int)iterConcat->getChildren().size( ) );
+				std::advance( itStartY, iterConcat->getChildren().size( ) );
 			} else {
-				if( * iter->getChild() != ** std::next( itC ) ) {
+				if( iter->getChild() != * std::next( itC ) ) {
 					++ itC;
 					continue;
 				}
 
-				advance( itStartY, 1 );
+				std::advance( itStartY, 1 );
 			}
 
 			// store everything before iteration as "a"
 			UnboundedRegExpConcatenation < SymbolType > tmpAY;
 			if( concat->getChildren().begin( ) == itC ) {
-				tmpAY.pushBackChild( ext::smart_ptr < UnboundedRegExpElement < SymbolType > > ( new UnboundedRegExpEpsilon < SymbolType >( ) ) );
+				tmpAY.pushBackChild ( UnboundedRegExpEpsilon < SymbolType > ( ) );
 			} else {
 				UnboundedRegExpConcatenation < SymbolType > tmpA;
 				tmpA.insert( tmpA.getChildren().end( ), concat->getChildren().begin( ), itC );
-				tmpAY.pushBackChild( ext::smart_ptr < UnboundedRegExpElement < SymbolType > > ( optimizeInner( tmpA ) ) );
+				tmpAY.pushBackChild ( optimizeInner( tmpA ) );
 			}
 
 			// store everything behind iteration's followup element as "y"
 			if( itStartY == concat->getChildren().end( ) ) {
-				tmpAY.pushBackChild( ext::smart_ptr < UnboundedRegExpElement < SymbolType > > ( new UnboundedRegExpEpsilon < SymbolType >( ) ) );
+				tmpAY.pushBackChild ( UnboundedRegExpEpsilon < SymbolType > ( ) );
 			} else {
 				UnboundedRegExpConcatenation < SymbolType > tmpY;
 				tmpY.insert( tmpY.getChildren().end( ), itStartY, concat->getChildren().end( ) );
-				tmpAY.pushBackChild( ext::smart_ptr < UnboundedRegExpElement < SymbolType > > ( optimizeInner( tmpY ) ) );
+				tmpAY.pushBackChild ( optimizeInner ( tmpY ) );
 			}
 
 			// concatenate "a" and "y" and see if they exist somewhere in parent alternation ( node.getChildren() )
-			UnboundedRegExpElement < SymbolType > * regexpAY = optimizeInner( tmpAY );
+			ext::rvalue_ref < UnboundedRegExpElement < SymbolType > > regexpAY = optimizeInner( tmpAY );
 
-			auto iterAY = find_if( node.getChildren().begin( ), node.getChildren().end( ), [ regexpAY ] ( const ext::smart_ptr < UnboundedRegExpElement < SymbolType > > & a ) -> bool{ return *a == *regexpAY; } );
-			delete regexpAY;
+			auto iterAY = find_if ( node.getChildren().begin( ), node.getChildren().end( ), [ & ] ( const UnboundedRegExpElement < SymbolType > & a ) -> bool { return a == regexpAY.get ( ); } );
 			if( iterAY == node.getChildren().end( ) ) {
 				++ itC;
 
 				continue;
 			}
 
-			tmpAY.insert( tmpAY.getChildren ( ).begin ( ) + 1, * itC );
+			tmpAY.insert ( tmpAY.getChildren ( ).begin ( ) + 1, * itC );
 
-			node.setChild( ext::smart_ptr < UnboundedRegExpElement < SymbolType > > ( optimizeInner( tmpAY ) ), itA );
+			node.setChild ( optimizeInner( tmpAY ), itA );
 
 			itA = node.getChildren().erase( iterAY );
 
@@ -670,7 +654,7 @@ bool RegExpOptimize::V5( UnboundedRegExpAlternation < SymbolType > & node ) {
 		}
 
 		++ itA;
-	}
+	}*/
 
 	return optimized;
 }
@@ -681,7 +665,7 @@ bool RegExpOptimize::V5( UnboundedRegExpAlternation < SymbolType > & node ) {
   * @return bool true if optimization applied else false
   */
 template < class SymbolType >
-bool RegExpOptimize::V6( UnboundedRegExpAlternation < SymbolType > & node ) {
+bool RegExpOptimize::V6( UnboundedRegExpAlternation < SymbolType > & /* node */ ) {
 	bool optimized = false;
 
 	// reinterpretation: ax*y = ay+axx*y
@@ -691,15 +675,15 @@ bool RegExpOptimize::V6( UnboundedRegExpAlternation < SymbolType > & node ) {
 	//	y = rest (suffix)
 	// prefix.xx*.suffix + prefix.suffix = prefix.x*.suffix
 
-	for( auto itA = node.getChildren ( ).begin( ); itA != node.getChildren ( ).end( ); ) {
-		UnboundedRegExpConcatenation < SymbolType > * concat = dynamic_cast<UnboundedRegExpConcatenation < SymbolType >*>( itA->get() );
+	/* for( auto itA = node.getChildren ( ).begin( ); itA != node.getChildren ( ).end( ); ) {
+		UnboundedRegExpConcatenation < SymbolType > * concat = dynamic_cast < UnboundedRegExpConcatenation < SymbolType > * > ( & * itA );
 		if( ! concat ) {
 			++ itA;
 			continue;
 		}
 
 		for( auto itC = std::next( concat->getChildren ( ).begin( ) ); itC != concat->getChildren ( ).end( ); ) {
-			UnboundedRegExpIteration < SymbolType > * iter = dynamic_cast<UnboundedRegExpIteration < SymbolType >*>( itC->get() );
+			UnboundedRegExpIteration < SymbolType > * iter = dynamic_cast < UnboundedRegExpIteration < SymbolType > * > ( & * itC );
 			if( ! iter ) {
 				++ itC;
 				continue;
@@ -709,52 +693,51 @@ bool RegExpOptimize::V6( UnboundedRegExpAlternation < SymbolType > & node ) {
 			auto itStartX = itC; //itStartX points to first x in expression xx*, everything before is therefore prefix - regexp "a"
 
 			// if iter's element is concat
-			UnboundedRegExpConcatenation < SymbolType > * iterConcat = dynamic_cast<UnboundedRegExpConcatenation < SymbolType >*>( iter->getChild ( ).get() );
+			UnboundedRegExpConcatenation < SymbolType > * iterConcat = dynamic_cast < UnboundedRegExpConcatenation < SymbolType > * > ( & iter->getChild ( ) );
 			if( iterConcat ) {
 
 				if( distance( concat->getChildren ( ).begin( ), itC ) < (int) iterConcat->getChildren ( ).size( ) ) {
 					++ itC;
 					continue;
 				}
-				advance( itStartX, - (int) iterConcat->getChildren().size( ) );
+				ext::retract ( itStartX, iterConcat->getChildren().size( ) );
 
 				if( iterConcat->getChildren ( ).size( ) != ( unsigned ) distance( itStartX, concat->getChildren ( ).end( ) )
-						|| ! equal( iterConcat->getChildren().begin( ), iterConcat->getChildren().end( ), itStartX,
-						[]( const ext::smart_ptr < UnboundedRegExpElement < SymbolType > > & a, const ext::smart_ptr < UnboundedRegExpElement < SymbolType > > & b ) -> bool{ return *a == *b; } ) ) {
+						|| ! equal ( iterConcat->getChildren ( ).begin ( ), iterConcat->getChildren ( ).end ( ), itStartX,
+						[ ] ( const UnboundedRegExpElement < SymbolType > & a, const UnboundedRegExpElement < SymbolType > & b ) -> bool { return a == b; } ) ) {
 					++ itC;
 					continue;
 				}
 			} else {
-				if( * iter->getChild ( ) != ** std::prev( itC ) ) {
+				if( iter->getChild ( ) != * std::prev( itC ) ) {
 					++ itC;
 					continue;
 				}
 
-				advance( itStartX, -1 );
+				std::advance( itStartX, -1 );
 			}
 
 			// concatenate "a" and "y" and see if they exist somewhere in parent alternation ( node->getChildren() )
 			UnboundedRegExpConcatenation < SymbolType > tmpAY;
-			if( concat->getChildren().begin( ) == itStartX ) {
-				tmpAY.pushBackChild( ext::smart_ptr < UnboundedRegExpElement < SymbolType > > ( new UnboundedRegExpEpsilon < SymbolType >( ) ) );
+			if( concat->getChildren ( ).begin ( ) == itStartX ) {
+				tmpAY.pushBackChild ( UnboundedRegExpEpsilon < SymbolType > ( ) );
 			} else {
 				UnboundedRegExpConcatenation < SymbolType > tmpA;
-				tmpA.insert( tmpA.getChildren().end( ), concat->getChildren().begin( ), itStartX );
-				tmpAY.pushBackChild( ext::smart_ptr < UnboundedRegExpElement < SymbolType > > ( optimizeInner( tmpA ) ) );
+				tmpA.insert ( tmpA.getChildren ( ).end ( ), concat->getChildren().begin ( ), itStartX );
+				tmpAY.pushBackChild ( optimizeInner ( tmpA ) );
 			}
 
-			if( std::next( itC ) == concat->getChildren().end( ) ) {
-				tmpAY.pushBackChild( ext::smart_ptr < UnboundedRegExpElement < SymbolType > > ( new UnboundedRegExpEpsilon < SymbolType >( ) ) );
+			if( std::next ( itC ) == concat->getChildren().end( ) ) {
+				tmpAY.pushBackChild ( UnboundedRegExpEpsilon < SymbolType >( ) );
 			} else {
 				UnboundedRegExpConcatenation < SymbolType > tmpY;
-				tmpY.insert( tmpY.getChildren().end( ), std::next( itC ), concat->getChildren ( ).end( ) );
-				tmpAY.pushBackChild( ext::smart_ptr < UnboundedRegExpElement < SymbolType > > ( optimizeInner( tmpY ) ) );
+				tmpY.insert ( tmpY.getChildren().end( ), std::next( itC ), concat->getChildren ( ).end( ) );
+				tmpAY.pushBackChild ( optimizeInner( tmpY ) );
 			}
 
-			UnboundedRegExpElement < SymbolType > * regexpAY = optimizeInner( tmpAY );
+			ext::rvalue_ref < UnboundedRegExpElement < SymbolType > > regexpAY = optimizeInner ( tmpAY );
 
-			auto iterAY = find_if( node.getChildren().begin( ), node.getChildren().end( ), [ regexpAY ] ( const ext::smart_ptr < UnboundedRegExpElement < SymbolType > > & a ) -> bool{ return *a == *regexpAY; } );
-			delete regexpAY;
+			auto iterAY = find_if( node.getChildren().begin( ), node.getChildren().end( ), [ & ] ( const UnboundedRegExpElement < SymbolType > & a ) -> bool { return a == regexpAY.get ( ); } );
 			if( iterAY == node.getChildren().end( ) ) {
 				++ itC;
 
@@ -764,7 +747,7 @@ bool RegExpOptimize::V6( UnboundedRegExpAlternation < SymbolType > & node ) {
 			// if so make a x* y and replace a x x* y
 			tmpAY.insert( tmpAY.getChildren ( ).begin ( ) + 1, * itC );
 
-			node.setChild( ext::smart_ptr < UnboundedRegExpElement < SymbolType > > ( optimizeInner( tmpAY ) ), itA );
+			node.setChild ( optimizeInner( tmpAY ), itA );
 
 			// remove a y
 			itA = node.getChildren().erase( iterAY );
@@ -774,7 +757,7 @@ bool RegExpOptimize::V6( UnboundedRegExpAlternation < SymbolType > & node ) {
 		}
 
 		++ itA;
-	}
+	} */
 
 	return optimized;
 }
@@ -785,16 +768,16 @@ bool RegExpOptimize::V6( UnboundedRegExpAlternation < SymbolType > & node ) {
   * @return bool true if optimization applied else false
   */
 template < class SymbolType >
-bool RegExpOptimize::V8( UnboundedRegExpConcatenation < SymbolType > & node ) {
+bool RegExpOptimize::V8( UnboundedRegExpConcatenation < SymbolType > & /* node */ ) {
 	bool optimized = false;
 
 	// interpretation: if there is iteration in concatenation node, and element of iteration contains eps and is straight before this iteration, then this element can be omitted
 
-	if ( node.getChildren ( ).size ( ) == 0 )
+	/*if ( node.getChildren ( ).size ( ) == 0 )
 		return false;
 
 	for( auto it = next ( node.getChildren ( ).begin( ) ); it != node.getChildren ( ).end( ); ) {
-		UnboundedRegExpIteration < SymbolType >* iter = dynamic_cast<UnboundedRegExpIteration < SymbolType >*>( it->get() );
+		UnboundedRegExpIteration < SymbolType > * iter = dynamic_cast < UnboundedRegExpIteration < SymbolType > * > ( & * it );
 
 		if( ! iter ) {
 			++ it;
@@ -802,7 +785,7 @@ bool RegExpOptimize::V8( UnboundedRegExpConcatenation < SymbolType > & node ) {
 		}
 
 		// if element of iteration is concatenation, we need to check this specially
-		UnboundedRegExpConcatenation < SymbolType > * concat = dynamic_cast<UnboundedRegExpConcatenation < SymbolType >*>( iter->getChild ( ).get() );
+		UnboundedRegExpConcatenation < SymbolType > * concat = dynamic_cast < UnboundedRegExpConcatenation < SymbolType > * > ( & iter->getChild ( ) );
 
 		if( concat ) {
 			// check if not out of bounds
@@ -811,23 +794,22 @@ bool RegExpOptimize::V8( UnboundedRegExpConcatenation < SymbolType > & node ) {
 				continue;
 			}
 
-			//FIXME: int cast
 			auto it2 = it;
-			advance( it2, - (int) concat->getChildren().size( ) );
+			ext::retract ( it2, concat->getChildren ( ).size ( ) );
 
-			if( regexp::properties::RegExpEpsilon::languageContainsEpsilon(*concat) &&
+			if( regexp::properties::RegExpEpsilon::languageContainsEpsilon ( * concat ) &&
 				concat->getChildren().size ( ) == ( unsigned ) distance ( it2, node.getChildren ( ).end( ) ) &&
-				equal( concat->getChildren ( ).begin( ), concat->getChildren ( ).end( ), it2, [] ( const ext::smart_ptr < UnboundedRegExpElement < SymbolType > > & a, const ext::smart_ptr < UnboundedRegExpElement < SymbolType > > & b ) -> bool { return *a == *b; } ) ) {
+				equal ( concat->getChildren ( ).begin( ), concat->getChildren ( ).end( ), it2, [ ] ( const UnboundedRegExpElement < SymbolType > & a, const UnboundedRegExpElement < SymbolType > & b ) -> bool { return a == b; } ) ) {
 				optimized = true;
 
-				it = node.getChildren().erase( it2, it );
+				it = node.getChildren ( ).erase ( it2, it );
 			} else
 				++ it;
 		} else {
 			auto prev = std::prev ( it );
 
-			if( regexp::properties::RegExpEpsilon::languageContainsEpsilon(iter->getElement()) && iter->getElement ( ) == **prev ) {
-				it = node.getChildren().erase( prev );
+			if ( regexp::properties::RegExpEpsilon::languageContainsEpsilon ( iter->getElement ( ) ) && iter->getElement ( ) == * prev ) {
+				it = node.getChildren ( ).erase ( prev );
 				optimized = true;
 
 				// in case xxx*, we need to stay on the iter element, not to go behind it
@@ -836,7 +818,7 @@ bool RegExpOptimize::V8( UnboundedRegExpConcatenation < SymbolType > & node ) {
 			} else
 				++ it;
 		}
-	}
+	}*/
 
 	return optimized;
 }
@@ -847,19 +829,19 @@ bool RegExpOptimize::V8( UnboundedRegExpConcatenation < SymbolType > & node ) {
   * @return bool true if optimization applied else false
   */
 template < class SymbolType >
-bool RegExpOptimize::V9( UnboundedRegExpConcatenation < SymbolType > & node ) {
+bool RegExpOptimize::V9( UnboundedRegExpConcatenation < SymbolType > & /*node*/ ) {
 	bool optimized = false;
 
 	// interpretation: if concat (C1) with iter && iteration's element is concat (C2), then:
 	//	  simultaneously iterate through C1 and C2. (axy)*axz=ax(yax)*z -> get ax that is same and relocate them...
 
-	for( auto it = node.getChildren().begin( ) ; it != node.getChildren().end( ) ; ) {
-		UnboundedRegExpIteration < SymbolType > * iter = dynamic_cast<UnboundedRegExpIteration < SymbolType >*>( it->get() );
+	/*for( auto it = node.getChildren().begin( ) ; it != node.getChildren().end( ) ; ) {
+		UnboundedRegExpIteration < SymbolType > * iter = dynamic_cast<UnboundedRegExpIteration < SymbolType > * > ( & * it );
 		if ( ! iter ) {
 			++ it;
 			continue;
 		}
-		UnboundedRegExpConcatenation < SymbolType > * concat = dynamic_cast<UnboundedRegExpConcatenation < SymbolType >*>( iter->getChild().get() );
+		UnboundedRegExpConcatenation < SymbolType > * concat = dynamic_cast<UnboundedRegExpConcatenation < SymbolType > * > ( & iter->getChild( ) );
 		if( ! concat ) {
 			++it;
 			continue;
@@ -867,7 +849,7 @@ bool RegExpOptimize::V9( UnboundedRegExpConcatenation < SymbolType > & node ) {
 
 		// find range from <it+1;sth> and <concat.begin;sth> that is equal
 		auto c1Iter = std::next( it ), c2Iter = concat->getChildren().begin( );
-		while( c1Iter != node.getChildren().end() && c2Iter != concat->getChildren().end( ) && **c1Iter == ** c2Iter ) {
+		while( c1Iter != node.getChildren().end() && c2Iter != concat->getChildren().end( ) && *c1Iter == * c2Iter ) {
 			++ c1Iter;
 			++ c2Iter;
 		}
@@ -883,8 +865,8 @@ bool RegExpOptimize::V9( UnboundedRegExpConcatenation < SymbolType > & node ) {
 		// common::Streams::out << RegExp( tmp ) << std::endl;
 
 		// copy the range <it;sth>, delete it and go back to the iter node
-		ext::vector<ext::smart_ptr < UnboundedRegExpElement < SymbolType > > > copyRange;
-		copyRange.insert( copyRange.end(), std::next( it ), c1Iter );
+		ext::ptr_vector < UnboundedRegExpElement < SymbolType > > copyRange;
+		copyRange.insert ( copyRange.end(), std::next( it ), c1Iter );
 		it = node.getChildren().erase( std::next( it ), c1Iter );
 		it = std::prev( it );
 
@@ -896,7 +878,7 @@ bool RegExpOptimize::V9( UnboundedRegExpConcatenation < SymbolType > & node ) {
 		copyRange.insert( copyRange.end(), concat->getChildren().begin( ), c2Iter );
 		concat->getChildren().erase( concat->getChildren().begin( ), c2Iter );
 		concat->insert( concat->getChildren().end(), copyRange.begin( ), copyRange.end( ) );
-	}
+	}*/
 
 	return optimized;
 }
@@ -909,14 +891,15 @@ bool RegExpOptimize::V9( UnboundedRegExpConcatenation < SymbolType > & node ) {
   */
 template < class SymbolType >
 bool RegExpOptimize::V10( UnboundedRegExpIteration < SymbolType > & node ) {
+
 	// interpretation: if iter's child is alternation where some of its children are iteration, then they do not have to be iterations
-	UnboundedRegExpAlternation < SymbolType >* alt = dynamic_cast<UnboundedRegExpAlternation < SymbolType >*>( node.getChild ( ).get() );
-	if( ! alt || ! any_of( alt->getChildren ( ).begin( ), alt->getChildren ( ).end( ), [] ( ext::smart_ptr < UnboundedRegExpElement < SymbolType > > & a ) -> bool{ return dynamic_cast<UnboundedRegExpIteration < SymbolType > * >( a.get() ); } ) )
+	UnboundedRegExpAlternation < SymbolType > * alt = dynamic_cast < UnboundedRegExpAlternation < SymbolType > * > ( & node.getChild ( ) );
+	if ( ! alt || ! any_of ( alt->getChildren ( ).begin( ), alt->getChildren ( ).end( ), [] ( const UnboundedRegExpElement < SymbolType > & a ) -> bool { return dynamic_cast < const UnboundedRegExpIteration < SymbolType > * > ( & a ); } ) )
 		return false;
 
-	for( auto it = alt->getChildren ( ).begin( ); it != alt->getChildren ( ).end( ); ++it ) {
-		if ( dynamic_cast < UnboundedRegExpIteration < SymbolType > * > ( it->get ( ) ) )
-			alt->setChild ( std::move ( static_cast < UnboundedRegExpIteration < SymbolType > * >( it->get ( ) )->getChild ( ) ), it );
+	for ( auto it = alt->getChildren ( ).begin( ); it != alt->getChildren ( ).end ( ); ++ it ) {
+		if ( dynamic_cast < UnboundedRegExpIteration < SymbolType > * > ( & * it ) )
+			alt->setChild ( std::move ( static_cast < UnboundedRegExpIteration < SymbolType > & > ( * it ).getChild ( ) ), it );
 	}
 
 	return true;
@@ -929,11 +912,12 @@ bool RegExpOptimize::V10( UnboundedRegExpIteration < SymbolType > & node ) {
   */
 template < class SymbolType >
 bool RegExpOptimize::X1( UnboundedRegExpAlternation < SymbolType > & node ) {
+
 	// theorem: In regexp like a* + \e, \e is described twice, first in a*, second in \e.
 	//  therefore we can delete the \e as it is redundant
 
-	auto iter = find_if( node.getChildren ( ).begin( ), node.getChildren ( ).end( ), [] (const ext::smart_ptr < UnboundedRegExpElement < SymbolType > > & a ) -> bool { return dynamic_cast<UnboundedRegExpIteration < SymbolType > * >( a.get() );} );
-	auto eps = find_if( node.getChildren ( ).begin( ), node.getChildren ( ).end( ), [] (const ext::smart_ptr < UnboundedRegExpElement < SymbolType > > & a ) -> bool { return dynamic_cast<UnboundedRegExpEpsilon < SymbolType > * >( a.get() );} );
+	auto iter = find_if ( node.getChildren ( ).begin( ), node.getChildren ( ).end( ), [] ( const UnboundedRegExpElement < SymbolType > & a ) -> bool { return dynamic_cast < const UnboundedRegExpIteration < SymbolType > * > ( & a );} );
+	auto eps = find_if ( node.getChildren ( ).begin( ), node.getChildren ( ).end( ), [] ( const UnboundedRegExpElement < SymbolType > & a ) -> bool { return dynamic_cast < const UnboundedRegExpEpsilon < SymbolType > * > ( & a );} );
 
 	if( iter != node.getChildren ( ).end( ) && eps != node.getChildren ( ).end( ) ) {
 		node.getChildren ( ).erase( eps );
diff --git a/alib2algo/src/regexp/transform/RegExpDerivation.h b/alib2algo/src/regexp/transform/RegExpDerivation.h
index 4ea6f42c37..55b262d223 100644
--- a/alib2algo/src/regexp/transform/RegExpDerivation.h
+++ b/alib2algo/src/regexp/transform/RegExpDerivation.h
@@ -135,8 +135,8 @@ template < class SymbolType >
 std::unique_ptr < regexp::UnboundedRegExpElement < SymbolType > > RegExpDerivation::Unbounded < SymbolType >::visit(const regexp::UnboundedRegExpAlternation < SymbolType > & alternation, const SymbolType& argument) {
 	std::unique_ptr < regexp::UnboundedRegExpAlternation < SymbolType > > ret ( new regexp::UnboundedRegExpAlternation < SymbolType > () );
 
-	for(const auto& child : alternation.getElements())
-		ret->appendElement( * ( child->template accept<std::unique_ptr < regexp::UnboundedRegExpElement < SymbolType > >, regexp::RegExpDerivation::Unbounded < SymbolType > > ( argument ) ) );
+	for(const UnboundedRegExpElement < SymbolType > & child : alternation.getElements())
+		ret->appendElement( * ( child.template accept<std::unique_ptr < regexp::UnboundedRegExpElement < SymbolType > >, regexp::RegExpDerivation::Unbounded < SymbolType > > ( argument ) ) );
 
 	return std::unique_ptr < regexp::UnboundedRegExpElement < SymbolType > > ( std::move ( ret ) );
 }
@@ -146,16 +146,16 @@ std::unique_ptr < regexp::UnboundedRegExpElement < SymbolType > > RegExpDerivati
 	std::unique_ptr < regexp::UnboundedRegExpAlternation < SymbolType > > ret ( new regexp::UnboundedRegExpAlternation < SymbolType > () );
 
 	for(auto child = concatenation.getElements().begin(); child != concatenation.getElements().end(); ++ child) {
-		std::unique_ptr < regexp::UnboundedRegExpConcatenation < SymbolType > > concat ( new regexp::UnboundedRegExpConcatenation < SymbolType > () );
-		concat->appendElement( * ( (*child)->template accept<std::unique_ptr < regexp::UnboundedRegExpElement < SymbolType > >, regexp::RegExpDerivation::Unbounded < SymbolType > > ( argument ) ) );
+		regexp::UnboundedRegExpConcatenation < SymbolType > concat;
+		concat.appendElement( * ( child->template accept<std::unique_ptr < regexp::UnboundedRegExpElement < SymbolType > >, regexp::RegExpDerivation::Unbounded < SymbolType > > ( argument ) ) );
 
 		auto succeedingElement = child;
-		while(++succeedingElement != concatenation.getElements().end())
-			concat->appendElement(**succeedingElement);
+		while ( ++ succeedingElement != concatenation.getElements().end())
+			concat.appendElement ( * succeedingElement );
 
-		ret->appendElement(std::move(*concat));
+		ret->appendElement ( std::move ( concat ) );
 
-		if( ! regexp::properties::RegExpEpsilon::languageContainsEpsilon(**child) )
+		if( ! regexp::properties::RegExpEpsilon::languageContainsEpsilon ( * child ) )
 			break;
 	}
 
diff --git a/alib2algo/src/regexp/transform/RegExpIntegral.h b/alib2algo/src/regexp/transform/RegExpIntegral.h
index 8744335da1..0afa986039 100644
--- a/alib2algo/src/regexp/transform/RegExpIntegral.h
+++ b/alib2algo/src/regexp/transform/RegExpIntegral.h
@@ -116,8 +116,8 @@ template < class SymbolType >
 std::unique_ptr < regexp::UnboundedRegExpElement < SymbolType > > RegExpIntegral::Unbounded < SymbolType >::visit(const regexp::UnboundedRegExpAlternation < SymbolType > & alternation, const SymbolType& argument) {
 	regexp::UnboundedRegExpAlternation < SymbolType > * alt = new regexp::UnboundedRegExpAlternation < SymbolType > ();
 
-	for(const auto& child : alternation.getElements())
-		alt->appendElement(* ( child->template accept < std::unique_ptr < regexp::UnboundedRegExpElement < SymbolType > >, RegExpIntegral::Unbounded < SymbolType > > (argument) ) );
+	for(const UnboundedRegExpElement < SymbolType > & child : alternation.getElements())
+		alt->appendElement(* ( child.template accept < std::unique_ptr < regexp::UnboundedRegExpElement < SymbolType > >, RegExpIntegral::Unbounded < SymbolType > > (argument) ) );
 
 	return std::unique_ptr < UnboundedRegExpElement < SymbolType > > ( alt );
 }
@@ -127,8 +127,8 @@ std::unique_ptr < regexp::UnboundedRegExpElement < SymbolType > > RegExpIntegral
 	regexp::UnboundedRegExpConcatenation < SymbolType > * con = new regexp::UnboundedRegExpConcatenation < SymbolType > ( );
 
 	con->appendElement ( regexp::UnboundedRegExpSymbol < SymbolType > ( argument ) );
-	for ( const auto & element : concatenation.getElements() )
-		con->appendElement ( * element );
+	for ( const UnboundedRegExpElement < SymbolType > & element : concatenation.getElements() )
+		con->appendElement ( element );
 
 	return std::unique_ptr < regexp::UnboundedRegExpElement < SymbolType > > ( con );
 }
diff --git a/alib2algo/src/rte/glushkov/GlushkovFollow.h b/alib2algo/src/rte/glushkov/GlushkovFollow.h
index 40fa27e7d6..a99cf221cf 100644
--- a/alib2algo/src/rte/glushkov/GlushkovFollow.h
+++ b/alib2algo/src/rte/glushkov/GlushkovFollow.h
@@ -133,14 +133,14 @@ ext::set < GlushkovFollow::TFollowTuple < SymbolType, RankType > > GlushkovFollo
 	if ( symbolF == node.getSymbol ( ) ) {
 		ext::vector < ext::set < common::ranked_symbol < SymbolType, RankType > > > children;
 
-		for ( const ext::smart_ptr < 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 < SymbolType, RankType > & c : node.getElements ( ) )
+			children.push_back ( c.template accept < TAlphabet < SymbolType, RankType >, GlushkovFirst::Formal < SymbolType, RankType > > ( ) );
 
 		return replaceConstants ( alphabetK, children, substMapTree.at( & node ));
 	}
 
 	for ( const auto & c : node.getElements ( ) ) {
-		tmp = c->template accept < ext::set < TFollowTuple < SymbolType, RankType > >, GlushkovFollow::Formal < SymbolType, RankType > > ( symbolF, alphabetK, substMapTree );
+		tmp = c.template accept < ext::set < TFollowTuple < SymbolType, RankType > >, GlushkovFollow::Formal < SymbolType, RankType > > ( symbolF, alphabetK, substMapTree );
 		ret.insert ( tmp.begin ( ), tmp.end ( ) );
 	}
 
diff --git a/alib2algo/src/rte/glushkov/GlushkovFollowNaive.h b/alib2algo/src/rte/glushkov/GlushkovFollowNaive.h
index 7957c577a3..8dcb7df6d3 100644
--- a/alib2algo/src/rte/glushkov/GlushkovFollowNaive.h
+++ b/alib2algo/src/rte/glushkov/GlushkovFollowNaive.h
@@ -206,14 +206,14 @@ ext::set < ext::vector < common::ranked_symbol < SymbolType, RankType > > > Glus
 	if ( symbolF == node.getSymbol ( ) ) {
 		ext::vector < ext::set < common::ranked_symbol < SymbolType, RankType > > > children;
 
-		for ( const ext::smart_ptr < 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 < SymbolType, RankType > & c : node.getElements ( ) )
+			children.push_back ( c.template accept < TAlphabet < SymbolType, RankType >, GlushkovFirst::Formal < SymbolType, RankType > > ( ) );
 
 		return replaceConstants ( alphabetK, children, subMap );
 	}
 
 	for ( const auto & c : node.getElements ( ) ) {
-		tmp = c->template accept < ext::set < ext::vector < common::ranked_symbol < SymbolType, RankType > > >, GlushkovFollowNaive::Formal < SymbolType, RankType > > ( symbolF, alphabetK, subMap );
+		tmp = c.template accept < ext::set < ext::vector < common::ranked_symbol < SymbolType, RankType > > >, GlushkovFollowNaive::Formal < SymbolType, RankType > > ( symbolF, alphabetK, subMap );
 		ret.insert ( tmp.begin ( ), tmp.end ( ) );
 	}
 
diff --git a/alib2algo/src/rte/glushkov/GlushkovIndexate.cpp b/alib2algo/src/rte/glushkov/GlushkovIndexate.cpp
index 937747e83f..71427481be 100644
--- a/alib2algo/src/rte/glushkov/GlushkovIndexate.cpp
+++ b/alib2algo/src/rte/glushkov/GlushkovIndexate.cpp
@@ -30,10 +30,9 @@ FormalRTE < > GlushkovIndexate::index ( const rte::FormalRTE < > & rte ) {
 
 ext::rvalue_ref < FormalRTEElement < DefaultSymbolType, primitive::Unsigned > > GlushkovIndexate::Formal::visit ( const rte::FormalRTESymbolAlphabet < DefaultSymbolType, primitive::Unsigned > & node, int & i ) {
 	DefaultSymbolsPairType sps = DefaultSymbolsPairType ( ext::make_pair ( DefaultSymbolType ( node.getSymbol ( ).getSymbol ( ) ), DefaultSymbolType ( i++ ) ) );
-	ext::vector < ext::smart_ptr < rte::FormalRTEElement < DefaultSymbolType, primitive::Unsigned > > > children;
-	for ( const ext::smart_ptr < const rte::FormalRTEElement < DefaultSymbolType, primitive::Unsigned > > & e : node.getElements ( ) ) {
-		ext::rvalue_ref < FormalRTEElement < DefaultSymbolType, primitive::Unsigned > > child = e->accept < ext::rvalue_ref < rte::FormalRTEElement < DefaultSymbolType, primitive::Unsigned > >, GlushkovIndexate::Formal > ( i );
-		children.push_back ( ext::smart_ptr < rte::FormalRTEElement < DefaultSymbolType, primitive::Unsigned > > ( ( ( FormalRTEElement < DefaultSymbolType, primitive::Unsigned > && ) child ).clone ( ) ) );
+	ext::ptr_vector < rte::FormalRTEElement < DefaultSymbolType, primitive::Unsigned > > children;
+	for ( const rte::FormalRTEElement < DefaultSymbolType, primitive::Unsigned > & e : node.getElements ( ) ) {
+		children.push_back ( ( FormalRTEElement < DefaultSymbolType, primitive::Unsigned > && ) e.accept < ext::rvalue_ref < rte::FormalRTEElement < DefaultSymbolType, primitive::Unsigned > >, GlushkovIndexate::Formal > ( i ) );
 	}
 
 	return ext::rvalue_ref < FormalRTESymbolAlphabet < DefaultSymbolType, primitive::Unsigned > > ( new FormalRTESymbolAlphabet < DefaultSymbolType, primitive::Unsigned > ( common::ranked_symbol < > ( DefaultSymbolType ( sps ), node.getSymbol ( ).getRank ( ) ), std::move ( children ) ) );
diff --git a/alib2algo/src/rte/glushkov/GlushkovPos.h b/alib2algo/src/rte/glushkov/GlushkovPos.h
index 1d8271a37b..bcce9ff7cf 100644
--- a/alib2algo/src/rte/glushkov/GlushkovPos.h
+++ b/alib2algo/src/rte/glushkov/GlushkovPos.h
@@ -60,8 +60,8 @@ template < class SymbolType, class RankType >
 bool GlushkovPos::Formal < SymbolType, RankType >::visit ( const rte::FormalRTESymbolAlphabet < SymbolType, RankType > & node, const common::ranked_symbol < SymbolType, RankType > & symbolF ) {
 	if ( symbolF == node.getSymbol ( ) ) return true;
 
-	for ( const ext::smart_ptr < const rte::FormalRTEElement < SymbolType, RankType > > & element : node.getElements ( ) )
-		if ( element->template accept < bool, GlushkovPos::Formal < SymbolType, RankType > > ( symbolF ) )
+	for ( const rte::FormalRTEElement < SymbolType, RankType > & element : node.getElements ( ) )
+		if ( element.template accept < bool, GlushkovPos::Formal < SymbolType, RankType > > ( symbolF ) )
 			return true;
 
 	return false;
diff --git a/alib2algo/src/rte/glushkov/GlushkovSubstitutionMap.h b/alib2algo/src/rte/glushkov/GlushkovSubstitutionMap.h
index 42ddcfe2ee..c8ccc895a9 100644
--- a/alib2algo/src/rte/glushkov/GlushkovSubstitutionMap.h
+++ b/alib2algo/src/rte/glushkov/GlushkovSubstitutionMap.h
@@ -154,7 +154,7 @@ void GlushkovSubstitutionMap::Formal < SymbolType, RankType >::visit ( const rte
 	subMapTree.insert ( std::make_pair ( & node, subMap ) );
 
 	for ( const auto & c : node.getElements ( ) ) {
-		c -> template accept < void, GlushkovSubstitutionMap::Formal < SymbolType, RankType > > ( subMap, subMapTree );
+		c . template accept < void, GlushkovSubstitutionMap::Formal < SymbolType, RankType > > ( subMap, subMapTree );
 	}
 }
 
diff --git a/alib2algo/test-src/regexp/simplify/RegExpOptimizeTest.cpp b/alib2algo/test-src/regexp/simplify/RegExpOptimizeTest.cpp
index dfe632e5e1..62834047e8 100644
--- a/alib2algo/test-src/regexp/simplify/RegExpOptimizeTest.cpp
+++ b/alib2algo/test-src/regexp/simplify/RegExpOptimizeTest.cpp
@@ -48,7 +48,7 @@ void RegExpOptimizeTest::testOptimize() {
 
 		CPPUNIT_ASSERT ( regexpRes == res );
 	}
-	{
+	/*{
 		std::string input = "a z + a b* b z";
 		regexp::UnboundedRegExp < > regexp = factory::StringDataFactory::fromString ( input );
 
@@ -60,8 +60,120 @@ void RegExpOptimizeTest::testOptimize() {
 		std::cout << res << std::endl;
 		std::cout << regexpRes << std::endl;
 
+		CPPUNIT_ASSERT ( regexpRes == res );
+	}*/
+	{
+		std::string input = "a***";
+		regexp::UnboundedRegExp < > regexp = factory::StringDataFactory::fromString ( input );
+
+		regexp::UnboundedRegExp < > res = regexp::simplify::RegExpOptimize::optimize ( regexp );
+
+		std::string inputRes = "a*";
+		regexp::UnboundedRegExp < > regexpRes = factory::StringDataFactory::fromString ( inputRes );
+
+		std::cout << res << std::endl;
+		std::cout << regexpRes << std::endl;
+
+		CPPUNIT_ASSERT ( regexpRes == res );
+	}
+	{
+		std::string input = "a***";
+		regexp::UnboundedRegExp < > regexp = factory::StringDataFactory::fromString ( input );
+
+		regexp::UnboundedRegExp < > res = regexp::simplify::RegExpOptimize::optimize ( regexp );
+
+		std::string inputRes = "a*";
+		regexp::UnboundedRegExp < > regexpRes = factory::StringDataFactory::fromString ( inputRes );
+
+		std::cout << res << std::endl;
+		std::cout << regexpRes << std::endl;
+
 		CPPUNIT_ASSERT ( regexpRes == res );
 	}
+	{
+		std::string input = "(a*+b*)*";
+		regexp::UnboundedRegExp < > regexp = factory::StringDataFactory::fromString ( input );
+
+		regexp::UnboundedRegExp < > res = regexp::simplify::RegExpOptimize::optimize ( regexp );
+
+		std::string inputRes = "(a+b)*";
+		regexp::UnboundedRegExp < > regexpRes = factory::StringDataFactory::fromString ( inputRes );
+
+		std::cout << res << std::endl;
+		std::cout << regexpRes << std::endl;
+
+		CPPUNIT_ASSERT ( regexpRes == res );
+	}
+	{
+		std::string input = "(a*b*)*";
+		regexp::UnboundedRegExp < > regexp = factory::StringDataFactory::fromString ( input );
+
+		regexp::UnboundedRegExp < > res = regexp::simplify::RegExpOptimize::optimize ( regexp );
+
+		std::string inputRes = "(a+b)*";
+		regexp::UnboundedRegExp < > regexpRes = factory::StringDataFactory::fromString ( inputRes );
+
+		std::cout << res << std::endl;
+		std::cout << regexpRes << std::endl;
+
+		CPPUNIT_ASSERT ( regexpRes == res );
+	}
+	{
+		std::string input = "#0*+a*";
+		regexp::UnboundedRegExp < > regexp = factory::StringDataFactory::fromString ( input );
+
+		regexp::UnboundedRegExp < > res = regexp::simplify::RegExpOptimize::optimize ( regexp );
+
+		std::string inputRes = "a*";
+		regexp::UnboundedRegExp < > regexpRes = factory::StringDataFactory::fromString ( inputRes );
+
+		std::cout << res << std::endl;
+		std::cout << regexpRes << std::endl;
+
+		CPPUNIT_ASSERT ( regexpRes == res );
+	}
+	{
+		std::string input = "a+(a+a)";
+		regexp::UnboundedRegExp < > regexp = factory::StringDataFactory::fromString ( input );
+
+		regexp::UnboundedRegExp < > res = regexp::simplify::RegExpOptimize::optimize ( regexp );
+
+		std::string inputRes = "a";
+		regexp::UnboundedRegExp < > regexpRes = factory::StringDataFactory::fromString ( inputRes );
+
+		std::cout << res << std::endl;
+		std::cout << regexpRes << std::endl;
+
+		CPPUNIT_ASSERT ( regexpRes == res );
+	}
+/*	{ // implemented but skipped because ( a + b* )* gets simplified to ( a + b )* //FIXME
+		std::string input = "(a+b*)(a+b*)*";
+		regexp::UnboundedRegExp < > regexp = factory::StringDataFactory::fromString ( input );
+
+		regexp::UnboundedRegExp < > res = regexp::simplify::RegExpOptimize::optimize ( regexp );
+
+		std::string inputRes = "(a+b*)*";
+		regexp::UnboundedRegExp < > regexpRes = factory::StringDataFactory::fromString ( inputRes );
+
+		std::cout << res << std::endl;
+		std::cout << regexpRes << std::endl;
+
+		CPPUNIT_ASSERT ( regexpRes == res );
+	}*/
+	/*{
+		std::string input = "(x y)*x";
+		regexp::UnboundedRegExp < > regexp = factory::StringDataFactory::fromString ( input );
+
+		regexp::UnboundedRegExp < > res = regexp::simplify::RegExpOptimize::optimize ( regexp );
+
+		std::string inputRes = "x(y x)*";
+		regexp::UnboundedRegExp < > regexpRes = factory::StringDataFactory::fromString ( inputRes );
+
+		std::cout << res << std::endl;
+		std::cout << regexpRes << std::endl;
+
+		CPPUNIT_ASSERT ( regexpRes == res );
+	}*/
 
 }
 
@@ -138,34 +250,37 @@ void RegExpOptimizeTest::testOptimizeTemplated() {
 
 		CPPUNIT_ASSERT ( regexpRes == res );
 	}
+	std::cout << std::endl;
 	{
-		regexp::UnboundedRegExpConcatenation < char > con1;
-		con1.appendElement ( a );
-		con1.appendElement ( z );
+		regexp::UnboundedRegExpSymbol < char > symb { 'b' };
+		regexp::UnboundedRegExpIteration < char > iter { symb };
 
-		regexp::UnboundedRegExpIteration < char > iter { b };
-		regexp::UnboundedRegExpConcatenation < char > con2;
-		con2.appendElement ( a );
-		con2.appendElement ( iter );
-		con2.appendElement ( b );
-		con2.appendElement ( z );
+		regexp::UnboundedRegExpConcatenation < char > con1;
+		con1.appendElement ( symb );
+		con1.appendElement ( iter );
 
 		regexp::UnboundedRegExpAlternation < char > alt1;
 		alt1.appendElement ( con1 );
-		alt1.appendElement ( con2);
 
-		regexp::UnboundedRegExp < char > regexp( regexp::UnboundedRegExpStructure < char > { alt1 } );
+		regexp::UnboundedRegExpAlternation < char > alt2;
 
-		regexp::UnboundedRegExp < char > res = regexp::simplify::RegExpOptimize::optimize(regexp);
+		regexp::UnboundedRegExpConcatenation < char > con2;
+		con2.appendElement ( alt1 );
+		con2.appendElement ( alt2 );
 
-		regexp::UnboundedRegExpConcatenation < char > con3;
-		con3.appendElement ( a );
-		con3.appendElement ( iter );
-		con3.appendElement ( z );
+		regexp::UnboundedRegExpAlternation < char > alt3;
 
-		regexp::UnboundedRegExp < char > regexpRes( regexp::UnboundedRegExpStructure < char > { con3 } );
+		regexp::UnboundedRegExpAlternation < char > alt4;
+		alt4.appendElement ( alt3 );
+		alt4.appendElement ( con2 );
+
+		regexp::UnboundedRegExp < char > regexp( regexp::UnboundedRegExpStructure < char > { alt4 } );
+		std::cout << regexp << std::endl;
 
+		regexp::UnboundedRegExp < char > res = regexp::simplify::RegExpOptimize::optimize(regexp);
 		std::cout << res << std::endl;
+
+		regexp::UnboundedRegExp < char > regexpRes( regexp::UnboundedRegExpStructure < char > { } );
 		std::cout << regexpRes << std::endl;
 
 		CPPUNIT_ASSERT ( regexpRes == res );
diff --git a/alib2data/src/regexp/formal/FormalRegExpAlternation.h b/alib2data/src/regexp/formal/FormalRegExpAlternation.h
index a3bd6070a0..e153f27d1d 100644
--- a/alib2data/src/regexp/formal/FormalRegExpAlternation.h
+++ b/alib2data/src/regexp/formal/FormalRegExpAlternation.h
@@ -43,7 +43,7 @@ namespace regexp {
  * \tparam SymbolType used for the terminal alphabet
  */
 template < class SymbolType >
-class FormalRegExpAlternation : public FormalRegExpElement < SymbolType >, public ext::BinaryNode < ext::smart_ptr < FormalRegExpElement < SymbolType > >, ext::smart_ptr < const FormalRegExpElement < SymbolType > >, FormalRegExpAlternation < SymbolType > > {
+class FormalRegExpAlternation : public FormalRegExpElement < SymbolType >, public ext::BinaryNode < FormalRegExpElement < SymbolType >, FormalRegExpAlternation < SymbolType > > {
 	/**
 	 * @copydoc regexp::FormalRegExpElement < SymbolType >::accept ( ) const
 	 */
@@ -197,7 +197,7 @@ public:
 namespace regexp {
 
 template < class SymbolType >
-FormalRegExpAlternation < SymbolType >::FormalRegExpAlternation ( FormalRegExpElement < SymbolType > && leftElement, FormalRegExpElement < SymbolType > && rightElement ) : ext::BinaryNode < ext::smart_ptr < FormalRegExpElement < SymbolType > >, ext::smart_ptr < const FormalRegExpElement < SymbolType > >, FormalRegExpAlternation < SymbolType > > ( ext::smart_ptr < FormalRegExpElement < SymbolType > > ( std::move ( leftElement ).clone ( ) ), ext::smart_ptr < FormalRegExpElement < SymbolType > > ( std::move ( rightElement ).clone ( ) ) ) {
+FormalRegExpAlternation < SymbolType >::FormalRegExpAlternation ( FormalRegExpElement < SymbolType > && leftElement, FormalRegExpElement < SymbolType > && rightElement ) : ext::BinaryNode < FormalRegExpElement < SymbolType >, FormalRegExpAlternation < SymbolType > > ( std::move ( leftElement ), std::move ( rightElement ) ) {
 }
 
 template < class SymbolType >
@@ -206,27 +206,27 @@ FormalRegExpAlternation < SymbolType >::FormalRegExpAlternation ( const FormalRe
 
 template < class SymbolType >
 const FormalRegExpElement < SymbolType > & FormalRegExpAlternation < SymbolType >::getLeftElement ( ) const {
-	return * this->getLeft ( );
+	return this->getLeft ( );
 }
 
 template < class SymbolType >
 const FormalRegExpElement < SymbolType > & FormalRegExpAlternation < SymbolType >::getRightElement ( ) const {
-	return * this->getRight ( );
+	return this->getRight ( );
 }
 
 template < class SymbolType >
 FormalRegExpElement < SymbolType > & FormalRegExpAlternation < SymbolType >::getLeftElement ( ) {
-	return * this->getLeft ( );
+	return this->getLeft ( );
 }
 
 template < class SymbolType >
 FormalRegExpElement < SymbolType > & FormalRegExpAlternation < SymbolType >::getRightElement ( ) {
-	return * this->getRight ( );
+	return this->getRight ( );
 }
 
 template < class SymbolType >
 void FormalRegExpAlternation < SymbolType >::setLeftElement ( FormalRegExpElement < SymbolType > && element ) {
-	this->setLeft ( ext::smart_ptr < FormalRegExpElement < SymbolType > > ( std::move ( element ).clone ( ) ) );
+	this->setLeft ( std::move ( element ) );
 }
 
 template < class SymbolType >
@@ -236,7 +236,7 @@ void FormalRegExpAlternation < SymbolType >::setLeftElement ( const FormalRegExp
 
 template < class SymbolType >
 void FormalRegExpAlternation < SymbolType >::setRightElement ( FormalRegExpElement < SymbolType > && element ) {
-	this->setRight ( ext::smart_ptr < FormalRegExpElement < SymbolType > > ( std::move ( element ).clone ( ) ) );
+	this->setRight ( std::move ( element ) );
 }
 
 template < class SymbolType >
diff --git a/alib2data/src/regexp/formal/FormalRegExpConcatenation.h b/alib2data/src/regexp/formal/FormalRegExpConcatenation.h
index 7ce5fe0c55..e1ab19a0b9 100644
--- a/alib2data/src/regexp/formal/FormalRegExpConcatenation.h
+++ b/alib2data/src/regexp/formal/FormalRegExpConcatenation.h
@@ -43,7 +43,7 @@ namespace regexp {
  * \tparam SymbolType used for the terminal alphabet
  */
 template < class SymbolType >
-class FormalRegExpConcatenation : public FormalRegExpElement < SymbolType >, public ext::BinaryNode < ext::smart_ptr < FormalRegExpElement < SymbolType > >, ext::smart_ptr < const FormalRegExpElement < SymbolType > >, FormalRegExpConcatenation < SymbolType > > {
+class FormalRegExpConcatenation : public FormalRegExpElement < SymbolType >, public ext::BinaryNode < FormalRegExpElement < SymbolType >, FormalRegExpConcatenation < SymbolType > > {
 	/**
 	 * @copydoc regexp::FormalRegExpElement < SymbolType >::accept ( ) const
 	 */
@@ -197,7 +197,7 @@ public:
 namespace regexp {
 
 template < class SymbolType >
-FormalRegExpConcatenation < SymbolType >::FormalRegExpConcatenation ( FormalRegExpElement < SymbolType > && leftElement, FormalRegExpElement < SymbolType > && rightElement ) : ext::BinaryNode < ext::smart_ptr < FormalRegExpElement < SymbolType > >, ext::smart_ptr < const FormalRegExpElement < SymbolType > >, FormalRegExpConcatenation < SymbolType > > ( ext::smart_ptr < FormalRegExpElement < SymbolType > > ( std::move ( leftElement ).clone ( ) ), ext::smart_ptr < FormalRegExpElement < SymbolType > > ( std::move ( rightElement ).clone ( ) ) ) {
+FormalRegExpConcatenation < SymbolType >::FormalRegExpConcatenation ( FormalRegExpElement < SymbolType > && leftElement, FormalRegExpElement < SymbolType > && rightElement ) : ext::BinaryNode < FormalRegExpElement < SymbolType >, FormalRegExpConcatenation < SymbolType > > ( std::move ( leftElement ), std::move ( rightElement ) ) {
 }
 
 template < class SymbolType >
@@ -206,27 +206,27 @@ FormalRegExpConcatenation < SymbolType >::FormalRegExpConcatenation ( const Form
 
 template < class SymbolType >
 const FormalRegExpElement < SymbolType > & FormalRegExpConcatenation < SymbolType >::getLeftElement ( ) const {
-	return * this->getLeft ( );
+	return this->getLeft ( );
 }
 
 template < class SymbolType >
 const FormalRegExpElement < SymbolType > & FormalRegExpConcatenation < SymbolType >::getRightElement ( ) const {
-	return * this->getRight ( );
+	return this->getRight ( );
 }
 
 template < class SymbolType >
 FormalRegExpElement < SymbolType > & FormalRegExpConcatenation < SymbolType >::getLeftElement ( ) {
-	return * this->getLeft ( );
+	return this->getLeft ( );
 }
 
 template < class SymbolType >
 FormalRegExpElement < SymbolType > & FormalRegExpConcatenation < SymbolType >::getRightElement ( ) {
-	return * this->getRight ( );
+	return this->getRight ( );
 }
 
 template < class SymbolType >
 void FormalRegExpConcatenation < SymbolType >::setLeftElement ( FormalRegExpElement < SymbolType > && element ) {
-	this->setLeft( ext::smart_ptr < FormalRegExpElement < SymbolType > > ( std::move ( element ).clone ( ) ) );
+	this->setLeft ( std::move ( element ) );
 }
 
 template < class SymbolType >
@@ -236,7 +236,7 @@ void FormalRegExpConcatenation < SymbolType >::setLeftElement ( const FormalRegE
 
 template < class SymbolType >
 void FormalRegExpConcatenation < SymbolType >::setRightElement ( FormalRegExpElement < SymbolType > && element ) {
-	this->setRight ( ext::smart_ptr < FormalRegExpElement < SymbolType > > ( std::move ( element ).clone ( ) ) );
+	this->setRight ( std::move ( element ) );
 }
 
 template < class SymbolType >
@@ -283,7 +283,7 @@ void FormalRegExpConcatenation < SymbolType >::operator >>( std::ostream & out )
 
 template < class SymbolType >
 bool FormalRegExpConcatenation < SymbolType >::testSymbol ( const SymbolType & symbol ) const {
-	return getLeftElement ( ).testSymbol ( symbol ) && this->getRight ( )->testSymbol ( symbol );
+	return getLeftElement ( ).testSymbol ( symbol ) && getRightElement ( ).testSymbol ( symbol );
 }
 
 template < class SymbolType >
diff --git a/alib2data/src/regexp/formal/FormalRegExpEmpty.h b/alib2data/src/regexp/formal/FormalRegExpEmpty.h
index 7dea992112..c678078222 100644
--- a/alib2data/src/regexp/formal/FormalRegExpEmpty.h
+++ b/alib2data/src/regexp/formal/FormalRegExpEmpty.h
@@ -40,7 +40,7 @@ namespace regexp {
  * \tparam SymbolType used for the terminal alphabet
  */
 template < class SymbolType >
-class FormalRegExpEmpty : public FormalRegExpElement < SymbolType >, public ext::NullaryNode < ext::smart_ptr < FormalRegExpElement < SymbolType > >, ext::smart_ptr < const FormalRegExpElement < SymbolType > >, FormalRegExpSymbol < SymbolType > > {
+class FormalRegExpEmpty : public FormalRegExpElement < SymbolType >, public ext::NullaryNode < FormalRegExpElement < SymbolType >, FormalRegExpEmpty < SymbolType > > {
 	/**
 	 * @copydoc regexp::FormalRegExpElement < SymbolType >::accept ( ) const
 	 */
diff --git a/alib2data/src/regexp/formal/FormalRegExpEpsilon.h b/alib2data/src/regexp/formal/FormalRegExpEpsilon.h
index 6fb280b7f5..5a95479971 100644
--- a/alib2data/src/regexp/formal/FormalRegExpEpsilon.h
+++ b/alib2data/src/regexp/formal/FormalRegExpEpsilon.h
@@ -40,7 +40,7 @@ namespace regexp {
  * \tparam SymbolType used for the terminal alphabet
  */
 template < class SymbolType >
-class FormalRegExpEpsilon : public FormalRegExpElement < SymbolType >, public ext::NullaryNode < ext::smart_ptr < FormalRegExpElement < SymbolType > >, ext::smart_ptr < const FormalRegExpElement < SymbolType > >, FormalRegExpSymbol < SymbolType > > {
+class FormalRegExpEpsilon : public FormalRegExpElement < SymbolType >, public ext::NullaryNode < FormalRegExpElement < SymbolType >, FormalRegExpEpsilon < SymbolType > > {
 	/**
 	 * @copydoc regexp::FormalRegExpElement < SymbolType >::accept ( ) const
 	 */
diff --git a/alib2data/src/regexp/formal/FormalRegExpIteration.h b/alib2data/src/regexp/formal/FormalRegExpIteration.h
index 1edd828211..5f43503621 100644
--- a/alib2data/src/regexp/formal/FormalRegExpIteration.h
+++ b/alib2data/src/regexp/formal/FormalRegExpIteration.h
@@ -43,7 +43,7 @@ namespace regexp {
  * \tparam SymbolType used for the terminal alphabet
  */
 template < class SymbolType >
-class FormalRegExpIteration : public FormalRegExpElement < SymbolType >, public ext::UnaryNode < ext::smart_ptr < FormalRegExpElement < SymbolType > >, ext::smart_ptr < const FormalRegExpElement < SymbolType > >, FormalRegExpIteration < SymbolType > > {
+class FormalRegExpIteration : public FormalRegExpElement < SymbolType >, public ext::UnaryNode < FormalRegExpElement < SymbolType >, FormalRegExpIteration < SymbolType > > {
 	/**
 	 * @copydoc regexp::FormalRegExpElement < SymbolType >::accept ( ) const
 	 */
@@ -168,7 +168,7 @@ public:
 namespace regexp {
 
 template < class SymbolType >
-FormalRegExpIteration < SymbolType >::FormalRegExpIteration ( FormalRegExpElement < SymbolType > && element ) : ext::UnaryNode < ext::smart_ptr < FormalRegExpElement < SymbolType > >, ext::smart_ptr < const FormalRegExpElement < SymbolType > >, FormalRegExpIteration < SymbolType > > ( ext::smart_ptr < FormalRegExpElement < SymbolType > > ( std::move ( element ).clone ( ) ) ) {
+FormalRegExpIteration < SymbolType >::FormalRegExpIteration ( FormalRegExpElement < SymbolType > && element ) : ext::UnaryNode < FormalRegExpElement < SymbolType >, FormalRegExpIteration < SymbolType > > ( std::move ( element ) ) {
 }
 
 template < class SymbolType >
@@ -177,17 +177,17 @@ FormalRegExpIteration < SymbolType >::FormalRegExpIteration ( const FormalRegExp
 
 template < class SymbolType >
 const FormalRegExpElement < SymbolType > & FormalRegExpIteration < SymbolType >::getElement ( ) const {
-	return * this->getChild ( );
+	return this->getChild ( );
 }
 
 template < class SymbolType >
 FormalRegExpElement < SymbolType > & FormalRegExpIteration < SymbolType >::getElement ( ) {
-	return * this->getChild ( );
+	return this->getChild ( );
 }
 
 template < class SymbolType >
 void FormalRegExpIteration < SymbolType >::setElement ( FormalRegExpElement < SymbolType > && elementParam ) {
-	this->setChild ( ext::smart_ptr < FormalRegExpElement < SymbolType > > ( std::move ( elementParam ).clone ( ) ) );
+	this->setChild ( std::move ( elementParam ) );
 }
 
 template < class SymbolType >
diff --git a/alib2data/src/regexp/formal/FormalRegExpSymbol.h b/alib2data/src/regexp/formal/FormalRegExpSymbol.h
index 1d22fadf7a..5d408a9316 100644
--- a/alib2data/src/regexp/formal/FormalRegExpSymbol.h
+++ b/alib2data/src/regexp/formal/FormalRegExpSymbol.h
@@ -41,7 +41,7 @@ namespace regexp {
  * \tparam SymbolType used for the terminal alphabet
  */
 template < class SymbolType >
-class FormalRegExpSymbol : public FormalRegExpElement < SymbolType >, public ext::NullaryNode < ext::smart_ptr < FormalRegExpElement < SymbolType > >, ext::smart_ptr < const FormalRegExpElement < SymbolType > >, FormalRegExpSymbol < SymbolType > > {
+class FormalRegExpSymbol : public FormalRegExpElement < SymbolType >, public ext::NullaryNode < FormalRegExpElement < SymbolType >, FormalRegExpSymbol < SymbolType > > {
 	/**
 	 * The symbol of the node.
 	 */
diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpAlternation.h b/alib2data/src/regexp/unbounded/UnboundedRegExpAlternation.h
index 6151170d2c..28619dde91 100644
--- a/alib2data/src/regexp/unbounded/UnboundedRegExpAlternation.h
+++ b/alib2data/src/regexp/unbounded/UnboundedRegExpAlternation.h
@@ -24,7 +24,7 @@
 #ifndef UNBOUNDED_REG_EXP_ALTERNATION_H_
 #define UNBOUNDED_REG_EXP_ALTERNATION_H_
 
-#include <alib/vector>
+#include <alib/ptr_vector>
 #include <sstream>
 
 #include <exception/CommonException.h>
@@ -43,7 +43,7 @@ namespace regexp {
  * \tparam SymbolType used for the terminal alphabet
  */
 template < class SymbolType >
-class UnboundedRegExpAlternation : public UnboundedRegExpElement < SymbolType >, public ext::VararyNode < ext::smart_ptr < UnboundedRegExpElement < SymbolType > >, ext::smart_ptr < const UnboundedRegExpElement < SymbolType > >, UnboundedRegExpAlternation < SymbolType > > {
+class UnboundedRegExpAlternation : public UnboundedRegExpElement < SymbolType >, public ext::VararyNode < UnboundedRegExpElement < SymbolType >, UnboundedRegExpAlternation < SymbolType > > {
 	/**
 	 * @copydoc regexp::UnboundedRegExpElement < SymbolType >::accept ( ) const
 	 */
@@ -92,14 +92,14 @@ public:
 	 *
 	 * \return child nodes
 	 */
-	const ext::vector < ext::smart_ptr < const UnboundedRegExpElement < SymbolType > > > & getElements ( ) const;
+	const ext::ptr_vector < UnboundedRegExpElement < SymbolType > > & getElements ( ) const;
 
 	/**
 	 * Getter of child nodes of the regexp node
 	 *
 	 * \return child nodes
 	 */
-	const ext::vector < ext::smart_ptr < UnboundedRegExpElement < SymbolType > > > & getElements ( );
+	ext::ptr_vector < UnboundedRegExpElement < SymbolType > > & getElements ( );
 
 	/**
 	 * Node appending method. The node is added to the current list of nodes.
@@ -149,8 +149,8 @@ public:
 	virtual ext::smart_ptr < UnboundedRegExpElement < DefaultSymbolType > > normalize ( ) && override {
 		UnboundedRegExpAlternation < DefaultSymbolType > * res = new UnboundedRegExpAlternation < DefaultSymbolType > ( );
 
-		for ( ext::smart_ptr < UnboundedRegExpElement < SymbolType > > & element : this->getChildren ( ) )
-			res->appendElement ( std::move ( * std::move ( * element ).normalize ( ) ) );
+		for ( UnboundedRegExpElement < SymbolType > & element : this->getChildren ( ) )
+			res->appendElement ( std::move ( * std::move ( element ).normalize ( ) ) );
 
 		return ext::smart_ptr < UnboundedRegExpElement < DefaultSymbolType > > ( res );
 	}
@@ -168,18 +168,18 @@ UnboundedRegExpAlternation < SymbolType >::UnboundedRegExpAlternation ( ) {
 }
 
 template < class SymbolType >
-const ext::vector < ext::smart_ptr < const UnboundedRegExpElement < SymbolType > > > & UnboundedRegExpAlternation < SymbolType >::getElements ( ) const {
+const ext::ptr_vector < UnboundedRegExpElement < SymbolType > > & UnboundedRegExpAlternation < SymbolType >::getElements ( ) const {
 	return this->getChildren();
 }
 
 template < class SymbolType >
-const ext::vector < ext::smart_ptr < UnboundedRegExpElement < SymbolType > > > & UnboundedRegExpAlternation < SymbolType >::getElements ( ) {
+ext::ptr_vector < UnboundedRegExpElement < SymbolType > > & UnboundedRegExpAlternation < SymbolType >::getElements ( ) {
 	return this->getChildren();
 }
 
 template < class SymbolType >
 void UnboundedRegExpAlternation < SymbolType >::appendElement ( UnboundedRegExpElement < SymbolType > && element ) {
-	this->pushBackChild ( ext::smart_ptr < UnboundedRegExpElement < SymbolType > > ( std::move ( element ).clone ( ) ) );
+	this->pushBackChild ( std::move ( element ) );
 }
 
 template < class SymbolType >
@@ -201,10 +201,10 @@ template < class SymbolType >
 ext::smart_ptr < FormalRegExpElement < SymbolType > > UnboundedRegExpAlternation < SymbolType >::asFormal ( ) const {
 	if ( getElements ( ).size ( ) == 0 ) return ext::smart_ptr < FormalRegExpElement < SymbolType > > ( new FormalRegExpEmpty < SymbolType > ( ) );
 
-	ext::smart_ptr < FormalRegExpElement < SymbolType > > res = getElements ( )[getElements ( ).size ( ) - 1]->asFormal ( );
+	ext::smart_ptr < FormalRegExpElement < SymbolType > > res = getElements ( ) [ getElements ( ).size ( ) - 1 ].asFormal ( );
 
 	for ( unsigned i = getElements ( ).size ( ) - 1; i >= 1; i-- )
-		res = ext::smart_ptr < FormalRegExpElement < SymbolType > > ( new FormalRegExpAlternation < SymbolType > ( std::move ( * getElements ( )[i - 1]->asFormal ( ) ), std::move ( * res ) ) );
+		res = ext::smart_ptr < FormalRegExpElement < SymbolType > > ( new FormalRegExpAlternation < SymbolType > ( std::move ( * getElements ( ) [ i - 1 ].asFormal ( ) ), std::move ( * res ) ) );
 
 	return res;
 }
@@ -220,32 +220,32 @@ template < class SymbolType >
 void UnboundedRegExpAlternation < SymbolType >::operator >>( std::ostream & out ) const {
 	out << "(UnboundedRegExpAlternation";
 
-	for ( const auto & child : getElements() )
-		out << " " << * child;
+	for ( UnboundedRegExpElement < SymbolType > & element : this->getElements ( ) )
+		out << " " << element;
 
 	out << ")";
 }
 
 template < class SymbolType >
 bool UnboundedRegExpAlternation < SymbolType >::testSymbol ( const SymbolType & symbol ) const {
-	for ( const auto & child : getElements() )
-		if ( child->testSymbol ( symbol ) ) return true;
+	for ( UnboundedRegExpElement < SymbolType > & element : this->getElements ( ) )
+		if ( element.testSymbol ( symbol ) ) return true;
 
 	return false;
 }
 
 template < class SymbolType >
 bool UnboundedRegExpAlternation < SymbolType >::checkAlphabet ( const ext::set < SymbolType > & alphabet ) const {
-	for ( const auto & child : getElements() )
-		if ( !child->checkAlphabet ( alphabet ) ) return false;
+	for ( UnboundedRegExpElement < SymbolType > & element : this->getElements ( ) )
+		if ( ! element.checkAlphabet ( alphabet ) ) return false;
 
 	return true;
 }
 
 template < class SymbolType >
 void UnboundedRegExpAlternation < SymbolType >::computeMinimalAlphabet ( ext::set < SymbolType > & alphabet ) const {
-	for ( const auto & child : getElements() )
-		child->computeMinimalAlphabet ( alphabet );
+	for ( UnboundedRegExpElement < SymbolType > & element : this->getElements ( ) )
+		element.computeMinimalAlphabet ( alphabet );
 }
 
 template < class SymbolType >
diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpConcatenation.h b/alib2data/src/regexp/unbounded/UnboundedRegExpConcatenation.h
index fa7200c4fa..a64717eb3c 100644
--- a/alib2data/src/regexp/unbounded/UnboundedRegExpConcatenation.h
+++ b/alib2data/src/regexp/unbounded/UnboundedRegExpConcatenation.h
@@ -24,7 +24,7 @@
 #ifndef UNBOUNDED_REG_EXP_CONCATENATION_H_
 #define UNBOUNDED_REG_EXP_CONCATENATION_H_
 
-#include <alib/vector>
+#include <alib/ptr_vector>
 #include <sstream>
 
 #include <exception/CommonException.h>
@@ -43,7 +43,7 @@ namespace regexp {
  * \tparam SymbolType used for the terminal alphabet
  */
 template < class SymbolType >
-class UnboundedRegExpConcatenation : public UnboundedRegExpElement < SymbolType >, public ext::VararyNode < ext::smart_ptr < UnboundedRegExpElement < SymbolType > >, ext::smart_ptr < const UnboundedRegExpElement < SymbolType > >, UnboundedRegExpConcatenation < SymbolType > > {
+class UnboundedRegExpConcatenation : public UnboundedRegExpElement < SymbolType >, public ext::VararyNode < UnboundedRegExpElement < SymbolType >, UnboundedRegExpConcatenation < SymbolType > > {
 	/**
 	 * @copydoc regexp::UnboundedRegExpElement < SymbolType >::accept ( ) const
 	 */
@@ -92,14 +92,14 @@ public:
 	 *
 	 * \return child nodes
 	 */
-	const ext::vector < ext::smart_ptr < const UnboundedRegExpElement < SymbolType > > > & getElements ( ) const;
+	const ext::ptr_vector < UnboundedRegExpElement < SymbolType > > & getElements ( ) const;
 
 	/**
 	 * Getter of child nodes of the regexp node
 	 *
 	 * \return child nodes
 	 */
-	const ext::vector < ext::smart_ptr < UnboundedRegExpElement < SymbolType > > > & getElements ( );
+	ext::ptr_vector < UnboundedRegExpElement < SymbolType > > & getElements ( );
 
 	/**
 	 * Node appending method. The node is added to the current list of nodes.
@@ -149,8 +149,8 @@ public:
 	virtual ext::smart_ptr < UnboundedRegExpElement < DefaultSymbolType > > normalize ( ) && override {
 		UnboundedRegExpConcatenation < DefaultSymbolType > * res = new UnboundedRegExpConcatenation < DefaultSymbolType > ( );
 
-		for ( ext::smart_ptr < UnboundedRegExpElement < SymbolType > > & element : this->getChildren ( ) )
-			res->appendElement ( std::move ( * std::move ( * element ).normalize ( ) ) );
+		for ( UnboundedRegExpElement < SymbolType > & element : this->getChildren ( ) )
+			res->appendElement ( std::move ( * std::move ( element ).normalize ( ) ) );
 
 		return ext::smart_ptr < UnboundedRegExpElement < DefaultSymbolType > > ( res );
 	}
@@ -168,18 +168,18 @@ UnboundedRegExpConcatenation < SymbolType >::UnboundedRegExpConcatenation ( ) {
 }
 
 template < class SymbolType >
-const ext::vector < ext::smart_ptr < const UnboundedRegExpElement < SymbolType > > > & UnboundedRegExpConcatenation < SymbolType >::getElements ( ) const {
+const ext::ptr_vector < UnboundedRegExpElement < SymbolType > > & UnboundedRegExpConcatenation < SymbolType >::getElements ( ) const {
 	return this->getChildren();
 }
 
 template < class SymbolType >
-const ext::vector < ext::smart_ptr < UnboundedRegExpElement < SymbolType > > > & UnboundedRegExpConcatenation < SymbolType >::getElements ( ) {
+ext::ptr_vector < UnboundedRegExpElement < SymbolType > > & UnboundedRegExpConcatenation < SymbolType >::getElements ( ) {
 	return this->getChildren();
 }
 
 template < class SymbolType >
 void UnboundedRegExpConcatenation < SymbolType >::appendElement ( UnboundedRegExpElement < SymbolType > && element ) {
-	this->pushBackChild ( ext::smart_ptr < UnboundedRegExpElement < SymbolType > > ( std::move ( element ).clone ( ) ) );
+	this->pushBackChild ( std::move ( element ) );
 }
 
 template < class SymbolType >
@@ -201,10 +201,10 @@ template < class SymbolType >
 ext::smart_ptr < FormalRegExpElement < SymbolType > > UnboundedRegExpConcatenation < SymbolType >::asFormal ( ) const {
 	if ( getElements ( ).size ( ) == 0 ) return ext::smart_ptr < FormalRegExpElement < SymbolType > > ( new FormalRegExpEpsilon < SymbolType > ( ) );
 
-	ext::smart_ptr < FormalRegExpElement < SymbolType > > res = getElements ( )[getElements ( ).size ( ) - 1]->asFormal ( );
+	ext::smart_ptr < FormalRegExpElement < SymbolType > > res = getElements ( )[ getElements ( ).size ( ) - 1 ].asFormal ( );
 
 	for ( unsigned i = getElements ( ).size ( ) - 1; i >= 1; i-- )
-		res = ext::smart_ptr < FormalRegExpElement < SymbolType > > ( new FormalRegExpConcatenation < SymbolType > ( std::move ( * getElements ( )[i - 1]->asFormal ( ) ), std::move ( * res ) ) );
+		res = ext::smart_ptr < FormalRegExpElement < SymbolType > > ( new FormalRegExpConcatenation < SymbolType > ( std::move ( * getElements ( )[ i - 1 ].asFormal ( ) ), std::move ( * res ) ) );
 
 	return res;
 }
@@ -220,32 +220,32 @@ template < class SymbolType >
 void UnboundedRegExpConcatenation < SymbolType >::operator >>( std::ostream & out ) const {
 	out << "(UnboundedRegExpConcatenation";
 
-	for ( const auto & child : getElements() )
-		out << " " << * child;
+	for ( UnboundedRegExpElement < SymbolType > & element : this->getElements ( ) )
+		out << " " << element;
 
 	out << ")";
 }
 
 template < class SymbolType >
 bool UnboundedRegExpConcatenation < SymbolType >::testSymbol ( const SymbolType & symbol ) const {
-	for ( const auto & child : getElements() )
-		if ( child->testSymbol ( symbol ) ) return true;
+	for ( UnboundedRegExpElement < SymbolType > & element : this->getElements ( ) )
+		if ( element.testSymbol ( symbol ) ) return true;
 
 	return false;
 }
 
 template < class SymbolType >
 bool UnboundedRegExpConcatenation < SymbolType >::checkAlphabet ( const ext::set < SymbolType > & alphabet ) const {
-	for ( const auto & child : getElements() )
-		if ( !child->checkAlphabet ( alphabet ) ) return false;
+	for ( UnboundedRegExpElement < SymbolType > & element : this->getElements ( ) )
+		if ( ! element.checkAlphabet ( alphabet ) ) return false;
 
 	return true;
 }
 
 template < class SymbolType >
 void UnboundedRegExpConcatenation < SymbolType >::computeMinimalAlphabet ( ext::set < SymbolType > & alphabet ) const {
-	for ( const auto & child : getElements() )
-		child->computeMinimalAlphabet ( alphabet );
+	for ( UnboundedRegExpElement < SymbolType > & element : this->getElements ( ) )
+		element.computeMinimalAlphabet ( alphabet );
 }
 
 template < class SymbolType >
diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpEmpty.h b/alib2data/src/regexp/unbounded/UnboundedRegExpEmpty.h
index 649630098d..06fd8fd737 100644
--- a/alib2data/src/regexp/unbounded/UnboundedRegExpEmpty.h
+++ b/alib2data/src/regexp/unbounded/UnboundedRegExpEmpty.h
@@ -40,7 +40,7 @@ namespace regexp {
  * \tparam SymbolType used for the terminal alphabet
  */
 template < class SymbolType >
-class UnboundedRegExpEmpty : public UnboundedRegExpElement < SymbolType >, public ext::NullaryNode < ext::smart_ptr < UnboundedRegExpElement < SymbolType > >, ext::smart_ptr < const UnboundedRegExpElement < SymbolType > >, UnboundedRegExpSymbol < SymbolType > > {
+class UnboundedRegExpEmpty : public UnboundedRegExpElement < SymbolType >, public ext::NullaryNode < UnboundedRegExpElement < SymbolType >, UnboundedRegExpEmpty < SymbolType > > {
 	/**
 	 * @copydoc regexp::UnboundedRegExpElement < SymbolType >::accept ( ) const
 	 */
diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpEpsilon.h b/alib2data/src/regexp/unbounded/UnboundedRegExpEpsilon.h
index 5be59a4a85..93d8d8e6c5 100644
--- a/alib2data/src/regexp/unbounded/UnboundedRegExpEpsilon.h
+++ b/alib2data/src/regexp/unbounded/UnboundedRegExpEpsilon.h
@@ -40,7 +40,7 @@ namespace regexp {
  * \tparam SymbolType used for the terminal alphabet
  */
 template < class SymbolType >
-class UnboundedRegExpEpsilon : public UnboundedRegExpElement < SymbolType >, public ext::NullaryNode < ext::smart_ptr < UnboundedRegExpElement < SymbolType > >, ext::smart_ptr < const UnboundedRegExpElement < SymbolType > >, UnboundedRegExpSymbol < SymbolType > > {
+class UnboundedRegExpEpsilon : public UnboundedRegExpElement < SymbolType >, public ext::NullaryNode < UnboundedRegExpElement < SymbolType >, UnboundedRegExpEpsilon < SymbolType > > {
 	/**
 	 * @copydoc regexp::UnboundedRegExpElement < SymbolType >::accept ( ) const
 	 */
diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpIteration.h b/alib2data/src/regexp/unbounded/UnboundedRegExpIteration.h
index 357e58a2ff..e8b143d15e 100644
--- a/alib2data/src/regexp/unbounded/UnboundedRegExpIteration.h
+++ b/alib2data/src/regexp/unbounded/UnboundedRegExpIteration.h
@@ -42,7 +42,7 @@ namespace regexp {
  * \tparam SymbolType used for the terminal alphabet
  */
 template < class SymbolType >
-class UnboundedRegExpIteration : public UnboundedRegExpElement < SymbolType >, public ext::UnaryNode < ext::smart_ptr < UnboundedRegExpElement < SymbolType > >, ext::smart_ptr < const UnboundedRegExpElement < SymbolType > >, UnboundedRegExpIteration < SymbolType > > {
+class UnboundedRegExpIteration : public UnboundedRegExpElement < SymbolType >, public ext::UnaryNode < UnboundedRegExpElement < SymbolType >, UnboundedRegExpIteration < SymbolType > > {
 	/**
 	 * @copydoc regexp::UnboundedRegExpElement < SymbolType >::accept ( ) const
 	 */
@@ -167,7 +167,7 @@ public:
 namespace regexp {
 
 template < class SymbolType >
-UnboundedRegExpIteration < SymbolType >::UnboundedRegExpIteration ( UnboundedRegExpElement < SymbolType > && element ) : ext::UnaryNode < ext::smart_ptr < UnboundedRegExpElement < SymbolType > >, ext::smart_ptr < const UnboundedRegExpElement < SymbolType > >, UnboundedRegExpIteration < SymbolType > > ( ext::smart_ptr < UnboundedRegExpElement < SymbolType > > ( std::move ( element ).clone ( ) ) ) {
+UnboundedRegExpIteration < SymbolType >::UnboundedRegExpIteration ( UnboundedRegExpElement < SymbolType > && element ) : ext::UnaryNode < UnboundedRegExpElement < SymbolType >, UnboundedRegExpIteration < SymbolType > > ( std::move ( element ) ) {
 }
 
 template < class SymbolType >
@@ -176,17 +176,17 @@ UnboundedRegExpIteration < SymbolType >::UnboundedRegExpIteration ( const Unboun
 
 template < class SymbolType >
 const UnboundedRegExpElement < SymbolType > & UnboundedRegExpIteration < SymbolType >::getElement ( ) const {
-	return * this->getChild ( );
+	return this->getChild ( );
 }
 
 template < class SymbolType >
 UnboundedRegExpElement < SymbolType > & UnboundedRegExpIteration < SymbolType >::getElement ( ) {
-	return * this->getChild ( );
+	return this->getChild ( );
 }
 
 template < class SymbolType >
 void UnboundedRegExpIteration < SymbolType >::setElement ( UnboundedRegExpElement < SymbolType > && elementParam ) {
-	this->setChild ( ext::smart_ptr < UnboundedRegExpElement < SymbolType > > ( std::move ( elementParam ).clone ( ) ) );
+	this->setChild ( std::move ( elementParam ) );
 }
 
 template < class SymbolType >
diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpSymbol.h b/alib2data/src/regexp/unbounded/UnboundedRegExpSymbol.h
index a1b377ecde..a84c801510 100644
--- a/alib2data/src/regexp/unbounded/UnboundedRegExpSymbol.h
+++ b/alib2data/src/regexp/unbounded/UnboundedRegExpSymbol.h
@@ -41,7 +41,7 @@ namespace regexp {
  * \tparam SymbolType used for the terminal alphabet
  */
 template < class SymbolType >
-class UnboundedRegExpSymbol : public UnboundedRegExpElement < SymbolType >, public ext::NullaryNode < ext::smart_ptr < UnboundedRegExpElement < SymbolType > >, ext::smart_ptr < const UnboundedRegExpElement < SymbolType > >, UnboundedRegExpSymbol < SymbolType > > {
+class UnboundedRegExpSymbol : public UnboundedRegExpElement < SymbolType >, public ext::NullaryNode < UnboundedRegExpElement < SymbolType >, UnboundedRegExpSymbol < SymbolType > > {
 	/**
 	 * The symbol of the node.
 	 */
diff --git a/alib2data/src/regexp/xml/common/RegExpToXmlComposer.h b/alib2data/src/regexp/xml/common/RegExpToXmlComposer.h
index 791431b1d3..996213f4df 100644
--- a/alib2data/src/regexp/xml/common/RegExpToXmlComposer.h
+++ b/alib2data/src/regexp/xml/common/RegExpToXmlComposer.h
@@ -62,8 +62,8 @@ public:
 template < class SymbolType >
 void RegExpToXmlComposer::Unbounded::visit(const UnboundedRegExpAlternation < SymbolType > & alternation, ext::deque<sax::Token>& out) {
 	out.emplace_back("alternation", sax::Token::TokenType::START_ELEMENT);
-	for (const auto& element : alternation.getElements()) {
-		element->template accept < void, RegExpToXmlComposer::Unbounded > ( out );
+	for (const UnboundedRegExpElement < SymbolType > & element : alternation.getElements()) {
+		element.template accept < void, RegExpToXmlComposer::Unbounded > ( out );
 	}
 	out.emplace_back("alternation", sax::Token::TokenType::END_ELEMENT);
 }
@@ -71,8 +71,8 @@ void RegExpToXmlComposer::Unbounded::visit(const UnboundedRegExpAlternation < Sy
 template < class SymbolType >
 void RegExpToXmlComposer::Unbounded::visit(const UnboundedRegExpConcatenation < SymbolType > & concatenation, ext::deque<sax::Token>& out) {
 	out.emplace_back("concatenation", sax::Token::TokenType::START_ELEMENT);
-	for (auto element : concatenation.getElements()) {
-		element->template accept < void, RegExpToXmlComposer::Unbounded > ( out );
+	for (const UnboundedRegExpElement < SymbolType > & element : concatenation.getElements()) {
+		element.template accept < void, RegExpToXmlComposer::Unbounded > ( out );
 	}
 	out.emplace_back("concatenation", sax::Token::TokenType::END_ELEMENT);
 }
@@ -144,7 +144,7 @@ void RegExpToXmlComposer::Formal::visit(const FormalRegExpEmpty < SymbolType > &
 template < class SymbolType >
 void RegExpToXmlComposer::composeAlphabet(ext::deque<sax::Token>& out, const ext::set<SymbolType>& alphabet) {
 	out.emplace_back("alphabet", sax::Token::TokenType::START_ELEMENT);
-	for (const auto& symbol : alphabet) {
+	for (const SymbolType & symbol : alphabet) {
 		core::xmlApi<SymbolType>::compose(out, symbol);
 	}
 	out.emplace_back("alphabet", sax::Token::TokenType::END_ELEMENT);
diff --git a/alib2data/src/rte/formal/FormalRTEAlternation.h b/alib2data/src/rte/formal/FormalRTEAlternation.h
index 9b5ced90b3..23d38feced 100644
--- a/alib2data/src/rte/formal/FormalRTEAlternation.h
+++ b/alib2data/src/rte/formal/FormalRTEAlternation.h
@@ -44,7 +44,7 @@ namespace rte {
  * \tparam RankType used for the rank part of the ranked symbol
  */
 template < class SymbolType, class RankType >
-class FormalRTEAlternation : public FormalRTEElement < SymbolType, RankType >, public ext::BinaryNode < ext::smart_ptr < FormalRTEElement < SymbolType, RankType > >, ext::smart_ptr < FormalRTEElement < SymbolType, RankType > >, FormalRTEAlternation < SymbolType, RankType > > {
+class FormalRTEAlternation : public FormalRTEElement < SymbolType, RankType >, public ext::BinaryNode < FormalRTEElement < SymbolType, RankType >, FormalRTEAlternation < SymbolType, RankType > > {
 	/**
 	 * @copydoc regexp::FormalRTEElement < SymbolType, RankType >::accept ( ) const
 	 */
@@ -187,7 +187,7 @@ public:
 };
 
 template < class SymbolType, class RankType >
-FormalRTEAlternation < SymbolType, RankType >::FormalRTEAlternation ( FormalRTEElement < SymbolType, RankType > && left, FormalRTEElement < SymbolType, RankType > && right ) : ext::BinaryNode < ext::smart_ptr < FormalRTEElement < SymbolType, RankType > >, ext::smart_ptr < FormalRTEElement < SymbolType, RankType > >, FormalRTEAlternation < SymbolType, RankType > > ( ext::smart_ptr < FormalRTEElement < SymbolType, RankType > > ( std::move ( left ).clone ( ) ), ext::smart_ptr < FormalRTEElement < SymbolType, RankType > > ( std::move ( right ).clone ( ) ) ) {
+FormalRTEAlternation < SymbolType, RankType >::FormalRTEAlternation ( FormalRTEElement < SymbolType, RankType > && left, FormalRTEElement < SymbolType, RankType > && right ) : ext::BinaryNode < FormalRTEElement < SymbolType, RankType >, FormalRTEAlternation < SymbolType, RankType > > ( std::move ( left ), std::move ( right ) ) {
 }
 
 template < class SymbolType, class RankType >
@@ -196,22 +196,22 @@ FormalRTEAlternation < SymbolType, RankType >::FormalRTEAlternation ( const Form
 
 template < class SymbolType, class RankType >
 const FormalRTEElement < SymbolType, RankType > & FormalRTEAlternation < SymbolType, RankType >::getLeftElement ( ) const {
-	return * this->getLeft ( );
+	return this->getLeft ( );
 }
 
 template < class SymbolType, class RankType >
 const FormalRTEElement < SymbolType, RankType > & FormalRTEAlternation < SymbolType, RankType >::getRightElement ( ) const {
-	return * this->getRight ( );
+	return this->getRight ( );
 }
 
 template < class SymbolType, class RankType >
 FormalRTEElement < SymbolType, RankType > & FormalRTEAlternation < SymbolType, RankType >::getLeftElement ( ) {
-	return * this->getLeft ( );
+	return this->getLeft ( );
 }
 
 template < class SymbolType, class RankType >
 FormalRTEElement < SymbolType, RankType > & FormalRTEAlternation < SymbolType, RankType >::getRightElement ( ) {
-	return * this->getRight ( );
+	return this->getRight ( );
 }
 
 template < class SymbolType, class RankType >
@@ -221,7 +221,7 @@ void FormalRTEAlternation < SymbolType, RankType >::setLeftElement ( const Forma
 
 template < class SymbolType, class RankType >
 void FormalRTEAlternation < SymbolType, RankType >::setLeftElement ( FormalRTEElement < SymbolType, RankType > && element ) {
-	setLeft ( ext::smart_ptr < FormalRTEElement < SymbolType, RankType > > ( std::move ( element ).clone ( ) ) );
+	setLeft ( std::move ( element ) );
 }
 
 template < class SymbolType, class RankType >
@@ -231,7 +231,7 @@ void FormalRTEAlternation < SymbolType, RankType >::setRightElement ( const Form
 
 template < class SymbolType, class RankType >
 void FormalRTEAlternation < SymbolType, RankType >::setRightElement ( FormalRTEElement < SymbolType, RankType > && element ) {
-	setRight ( ext::smart_ptr < FormalRTEElement < SymbolType, RankType > > ( std::move ( element ).clone ( ) ) );
+	setRight ( std::move ( element ) );
 }
 
 template < class SymbolType, class RankType >
diff --git a/alib2data/src/rte/formal/FormalRTEIteration.h b/alib2data/src/rte/formal/FormalRTEIteration.h
index e41246cca6..17ded8c7e2 100644
--- a/alib2data/src/rte/formal/FormalRTEIteration.h
+++ b/alib2data/src/rte/formal/FormalRTEIteration.h
@@ -45,7 +45,7 @@ namespace rte {
  * \tparam RankType used for the rank part of the ranked symbol
  */
 template < class SymbolType, class RankType >
-class FormalRTEIteration : public FormalRTEElement < SymbolType, RankType >, public ext::UnaryNode < ext::smart_ptr < FormalRTEElement < SymbolType, RankType > >, ext::smart_ptr < const FormalRTEElement < SymbolType, RankType > >, FormalRTEIteration < SymbolType, RankType > > {
+class FormalRTEIteration : public FormalRTEElement < SymbolType, RankType >, public ext::UnaryNode < FormalRTEElement < SymbolType, RankType >, FormalRTEIteration < SymbolType, RankType > > {
 	/**
 	 * The substitution symbol of the node. The symbol will be substitued in left tree by right
 	 */
@@ -187,7 +187,7 @@ public:
 };
 
 template < class SymbolType, class RankType >
-FormalRTEIteration < SymbolType, RankType >::FormalRTEIteration ( FormalRTEElement < SymbolType, RankType > && element, FormalRTESymbolSubst < SymbolType, RankType > substitutionSymbol ) : ext::UnaryNode < ext::smart_ptr < FormalRTEElement < SymbolType, RankType > >, ext::smart_ptr < const FormalRTEElement < SymbolType, RankType > >, FormalRTEIteration < SymbolType, RankType > > ( ext::smart_ptr < FormalRTEElement < SymbolType, RankType > > ( std::move ( element ).clone ( ) ) ), m_substitutionSymbol ( std::move ( substitutionSymbol ) ) {
+FormalRTEIteration < SymbolType, RankType >::FormalRTEIteration ( FormalRTEElement < SymbolType, RankType > && element, FormalRTESymbolSubst < SymbolType, RankType > substitutionSymbol ) : ext::UnaryNode < FormalRTEElement < SymbolType, RankType >, FormalRTEIteration < SymbolType, RankType > > ( std::move ( element ) ), m_substitutionSymbol ( std::move ( substitutionSymbol ) ) {
 }
 
 template < class SymbolType, class RankType >
@@ -196,12 +196,12 @@ FormalRTEIteration < SymbolType, RankType >::FormalRTEIteration ( const FormalRT
 
 template < class SymbolType, class RankType >
 const FormalRTEElement < SymbolType, RankType > & FormalRTEIteration < SymbolType, RankType >::getElement ( ) const {
-	return * this->getChild ( );
+	return this->getChild ( );
 }
 
 template < class SymbolType, class RankType >
 FormalRTEElement < SymbolType, RankType > & FormalRTEIteration < SymbolType, RankType >::getElement ( ) {
-	return * this->getChild ( );
+	return this->getChild ( );
 }
 
 template < class SymbolType, class RankType >
@@ -221,7 +221,7 @@ void FormalRTEIteration < SymbolType, RankType >::setElement ( const FormalRTEEl
 
 template < class SymbolType, class RankType >
 void FormalRTEIteration < SymbolType, RankType >::setElement ( FormalRTEElement < SymbolType, RankType > && elementParam ) {
-	setChild ( ext::smart_ptr < FormalRTEElement < SymbolType, RankType > > ( std::move ( elementParam ).clone ( ) ) );
+	setChild ( std::move ( elementParam ) );
 }
 
 template < class SymbolType, class RankType >
@@ -256,13 +256,13 @@ void FormalRTEIteration < SymbolType, RankType >::operator >>( std::ostream & ou
 
 template < class SymbolType, class RankType >
 bool FormalRTEIteration < SymbolType, RankType >::testSymbol ( const common::ranked_symbol < SymbolType, RankType > & symbol ) const {
-	return this->getChild ( )->testSymbol ( symbol );
+	return this->getElement ( ).testSymbol ( symbol );
 }
 
 template < class SymbolType, class RankType >
 void FormalRTEIteration < SymbolType, RankType >::computeMinimalAlphabet ( ext::set < common::ranked_symbol < SymbolType, RankType > > & alphabetF, ext::set < common::ranked_symbol < SymbolType, RankType > > & alphabetK ) const {
 	alphabetK.insert ( m_substitutionSymbol.getSymbol ( ) );
-	this->getChild ( )->computeMinimalAlphabet ( alphabetF, alphabetK );
+	this->getElement ( ).computeMinimalAlphabet ( alphabetF, alphabetK );
 }
 
 template < class SymbolType, class RankType >
diff --git a/alib2data/src/rte/formal/FormalRTESubstitution.h b/alib2data/src/rte/formal/FormalRTESubstitution.h
index f88f7f6bbf..7a9dff58ba 100644
--- a/alib2data/src/rte/formal/FormalRTESubstitution.h
+++ b/alib2data/src/rte/formal/FormalRTESubstitution.h
@@ -44,7 +44,7 @@ namespace rte {
  * \tparam RankType used for the rank part of the ranked symbol
  */
 template < class SymbolType, class RankType >
-class FormalRTESubstitution : public FormalRTEElement < SymbolType, RankType >, public ext::BinaryNode < ext::smart_ptr < FormalRTEElement < SymbolType, RankType > >, ext::smart_ptr < FormalRTEElement < SymbolType, RankType > >, FormalRTESubstitution < SymbolType, RankType > > {
+class FormalRTESubstitution : public FormalRTEElement < SymbolType, RankType >, public ext::BinaryNode < FormalRTEElement < SymbolType, RankType >, FormalRTESubstitution < SymbolType, RankType > > {
 	/**
 	 * The substitution symbol of the node. The symbol will be substitued in left tree by right
 	 */
@@ -216,7 +216,7 @@ public:
 };
 
 template < class SymbolType, class RankType >
-FormalRTESubstitution < SymbolType, RankType >::FormalRTESubstitution ( FormalRTEElement < SymbolType, RankType > && left, FormalRTEElement < SymbolType, RankType > && right, FormalRTESymbolSubst < SymbolType, RankType > substitutionSymbol ) : ext::BinaryNode < ext::smart_ptr < FormalRTEElement < SymbolType, RankType > >, ext::smart_ptr < FormalRTEElement < SymbolType, RankType > >, FormalRTESubstitution < SymbolType, RankType > > ( ext::smart_ptr < FormalRTEElement < SymbolType, RankType > > ( std::move ( left ).clone ( ) ), ext::smart_ptr < FormalRTEElement < SymbolType, RankType > > ( std::move ( right ).clone ( ) ) ), m_substitutionSymbol ( std::move ( substitutionSymbol ) ) {
+FormalRTESubstitution < SymbolType, RankType >::FormalRTESubstitution ( FormalRTEElement < SymbolType, RankType > && left, FormalRTEElement < SymbolType, RankType > && right, FormalRTESymbolSubst < SymbolType, RankType > substitutionSymbol ) : ext::BinaryNode < FormalRTEElement < SymbolType, RankType >, FormalRTESubstitution < SymbolType, RankType > > ( std::move ( left ), std::move ( right ) ), m_substitutionSymbol ( std::move ( substitutionSymbol ) ) {
 }
 
 template < class SymbolType, class RankType >
@@ -225,12 +225,12 @@ FormalRTESubstitution < SymbolType, RankType >::FormalRTESubstitution ( const Fo
 
 template < class SymbolType, class RankType >
 const FormalRTEElement < SymbolType, RankType > & FormalRTESubstitution < SymbolType, RankType >::getLeftElement ( ) const {
-	return * this->getLeft ( );
+	return this->getLeft ( );
 }
 
 template < class SymbolType, class RankType >
 const FormalRTEElement < SymbolType, RankType > & FormalRTESubstitution < SymbolType, RankType >::getRightElement ( ) const {
-	return * this->getRight ( );
+	return this->getRight ( );
 }
 
 template < class SymbolType, class RankType >
@@ -240,12 +240,12 @@ const FormalRTESymbolSubst < SymbolType, RankType > & FormalRTESubstitution < Sy
 
 template < class SymbolType, class RankType >
 FormalRTEElement < SymbolType, RankType > & FormalRTESubstitution < SymbolType, RankType >::getLeftElement ( ) {
-	return * this->getLeft ( );
+	return this->getLeft ( );
 }
 
 template < class SymbolType, class RankType >
 FormalRTEElement < SymbolType, RankType > & FormalRTESubstitution < SymbolType, RankType >::getRightElement ( ) {
-	return * this->getRight ( );
+	return this->getRight ( );
 }
 
 template < class SymbolType, class RankType >
@@ -260,7 +260,7 @@ void FormalRTESubstitution < SymbolType, RankType >::setLeftElement ( const Form
 
 template < class SymbolType, class RankType >
 void FormalRTESubstitution < SymbolType, RankType >::setLeftElement ( FormalRTEElement < SymbolType, RankType > && element ) {
-	setLeft ( ext::smart_ptr < FormalRTEElement < SymbolType, RankType > > ( std::move ( element ).clone ( ) ) );
+	setLeft ( std::move ( element ) );
 }
 
 template < class SymbolType, class RankType >
@@ -270,7 +270,7 @@ void FormalRTESubstitution < SymbolType, RankType >::setRightElement ( const For
 
 template < class SymbolType, class RankType >
 void FormalRTESubstitution < SymbolType, RankType >::setRightElement ( FormalRTEElement < SymbolType, RankType > && element ) {
-	setRight ( ext::smart_ptr < FormalRTEElement < SymbolType, RankType > > ( std::move ( element ).clone ( ) ) );
+	setRight ( std::move ( element ) );
 }
 
 template < class SymbolType, class RankType >
diff --git a/alib2data/src/rte/formal/FormalRTESymbolAlphabet.h b/alib2data/src/rte/formal/FormalRTESymbolAlphabet.h
index c09103bedd..7980552c2f 100644
--- a/alib2data/src/rte/formal/FormalRTESymbolAlphabet.h
+++ b/alib2data/src/rte/formal/FormalRTESymbolAlphabet.h
@@ -44,7 +44,7 @@ namespace rte {
  * \tparam RankType used for the rank part of the ranked symbol
  */
 template < class SymbolType, class RankType >
-class FormalRTESymbolAlphabet : public FormalRTESymbol < SymbolType, RankType >, public ext::VararyNode < ext::smart_ptr < FormalRTEElement < SymbolType, RankType > >, ext::smart_ptr < const FormalRTEElement < SymbolType, RankType > >, FormalRTESymbolAlphabet < SymbolType, RankType > > {
+class FormalRTESymbolAlphabet : public FormalRTESymbol < SymbolType, RankType >, public ext::VararyNode < FormalRTEElement < SymbolType, RankType >, FormalRTESymbolAlphabet < SymbolType, RankType > > {
 	/**
 	 * @copydoc regexp::FormalRTEElement < SymbolType, RankType >::accept ( ) const
 	 */
@@ -58,7 +58,7 @@ public:
 	 *
 	 * \param symbol the value of the represented symbol
 	 */
-	explicit FormalRTESymbolAlphabet ( common::ranked_symbol < SymbolType, RankType > symbol, ext::vector < ext::smart_ptr < FormalRTEElement < SymbolType, RankType > > > children );
+	explicit FormalRTESymbolAlphabet ( common::ranked_symbol < SymbolType, RankType > symbol, ext::ptr_vector < FormalRTEElement < SymbolType, RankType > > children );
 
 	/**
 	 * @copydoc FormalRTEElement::clone ( ) const &
@@ -90,14 +90,14 @@ public:
 	 *
 	 * \return child nodes
 	 */
-	const ext::vector < ext::smart_ptr < const FormalRTEElement < SymbolType, RankType > > > & getElements ( ) const;
+	const ext::ptr_vector < FormalRTEElement < SymbolType, RankType > > & getElements ( ) const;
 
 	/**
 	 * Getter of child nodes of the rte node
 	 *
 	 * \return child nodes
 	 */
-	const ext::vector < ext::smart_ptr < FormalRTEElement < SymbolType, RankType > > > & getElements ( );
+	ext::ptr_vector < FormalRTEElement < SymbolType, RankType > > & getElements ( );
 
 	/**
 	 * @copydoc alib::CommonBase < FormalRTEElement < SymbolType, RankType > >::compare ( const FormalRTEElement < SymbolType, RankType > & )
@@ -131,16 +131,16 @@ public:
 	 * @copydoc regexp::FormalRTEElement < SymbolType, RankType >::normalize ( ) &&
 	 */
 	virtual ext::smart_ptr < FormalRTEElement < DefaultSymbolType, DefaultRankType > > normalize ( ) && override {
-		ext::vector < ext::smart_ptr < FormalRTEElement < DefaultSymbolType, DefaultRankType > > > children;
-		for ( const ext::smart_ptr < FormalRTEElement < SymbolType, RankType > > & element : this->getChildren ( ) )
-			children.push_back ( ext::smart_ptr < FormalRTEElement < SymbolType, RankType > > ( std::move ( * element ).normalize ( ) ) );
+		ext::ptr_vector < FormalRTEElement < DefaultSymbolType, DefaultRankType > > children;
+		for ( FormalRTEElement < SymbolType, RankType > & element : this->getElements ( ) )
+			children.push_back ( std::move ( * std::move ( element ).normalize ( ) ) );
 
 		return ext::smart_ptr < FormalRTEElement < DefaultSymbolType, DefaultRankType > > ( new FormalRTESymbolAlphabet < DefaultSymbolType, DefaultRankType > ( alphabet::SymbolNormalize::normalizeRankedSymbol ( std::move ( this->m_symbol ) ), std::move ( children ) ) );
 	}
 };
 
 template < class SymbolType, class RankType >
-FormalRTESymbolAlphabet < SymbolType, RankType >::FormalRTESymbolAlphabet ( common::ranked_symbol < SymbolType, RankType > symbol, ext::vector < ext::smart_ptr < FormalRTEElement < SymbolType, RankType > > > children ) : FormalRTESymbol < SymbolType, RankType > ( symbol ), ext::VararyNode < ext::smart_ptr < FormalRTEElement < SymbolType, RankType > >, ext::smart_ptr < const FormalRTEElement < SymbolType, RankType > >, FormalRTESymbolAlphabet < SymbolType, RankType > > ( std::move ( children ) ) {
+FormalRTESymbolAlphabet < SymbolType, RankType >::FormalRTESymbolAlphabet ( common::ranked_symbol < SymbolType, RankType > symbol, ext::ptr_vector < FormalRTEElement < SymbolType, RankType > > children ) : FormalRTESymbol < SymbolType, RankType > ( symbol ), ext::VararyNode < FormalRTEElement < SymbolType, RankType >, FormalRTESymbolAlphabet < SymbolType, RankType > > ( std::move ( children ) ) {
 	if ( this->getChildren ( ).size ( ) != ( size_t ) this->getSymbol ( ).getRank ( ) )
 		throw exception::CommonException ( "Symbol's rank and number of children differ. Rank is " + ext::to_string ( this->getSymbol ( ).getRank ( ) ) + ", number of children is " + ext::to_string ( this->getChildren ( ).size ( ) ) + "." );
 
@@ -157,12 +157,12 @@ FormalRTESymbolAlphabet < SymbolType, RankType > * FormalRTESymbolAlphabet < Sym
 }
 
 template < class SymbolType, class RankType >
-const ext::vector < ext::smart_ptr < const FormalRTEElement < SymbolType, RankType > > > & FormalRTESymbolAlphabet < SymbolType, RankType >::getElements ( ) const {
+const ext::ptr_vector < FormalRTEElement < SymbolType, RankType > > & FormalRTESymbolAlphabet < SymbolType, RankType >::getElements ( ) const {
 	return this->getChildren ( );
 }
 
 template < class SymbolType, class RankType >
-const ext::vector < ext::smart_ptr < FormalRTEElement < SymbolType, RankType > > > & FormalRTESymbolAlphabet < SymbolType, RankType >::getElements ( ) {
+ext::ptr_vector < FormalRTEElement < SymbolType, RankType > > & FormalRTESymbolAlphabet < SymbolType, RankType >::getElements ( ) {
 	return this->getChildren ( );
 }
 
@@ -190,14 +190,14 @@ template < class SymbolType, class RankType >
 void FormalRTESymbolAlphabet < SymbolType, RankType >::computeMinimalAlphabet ( ext::set < common::ranked_symbol < SymbolType, RankType > > & alphabetF, ext::set < common::ranked_symbol < SymbolType, RankType > > & alphabetK ) const {
 	alphabetF.insert ( this->getSymbol ( ) );
 
-	for ( const ext::smart_ptr < const FormalRTEElement < SymbolType, RankType > > & child : this->getChildren ( ) )
-		child->computeMinimalAlphabet ( alphabetF, alphabetK );
+	for ( const FormalRTEElement < SymbolType, RankType > & child : this->getElements ( ) )
+		child.computeMinimalAlphabet ( alphabetF, alphabetK );
 }
 
 template < class SymbolType, class RankType >
 bool FormalRTESymbolAlphabet < SymbolType, RankType >::checkAlphabet ( const ext::set < common::ranked_symbol < SymbolType, RankType > > & alphabetF, const ext::set < common::ranked_symbol < SymbolType, RankType > > & alphabetK ) const {
-	return alphabetF.count ( this->getSymbol ( ) ) > 0 && std::all_of ( getElements ( ).begin ( ), getElements ( ).end ( ), [&] ( const ext::smart_ptr < const FormalRTEElement < SymbolType, RankType > > & e ) {
-			return e->checkAlphabet ( alphabetF, alphabetK );
+	return alphabetF.count ( this->getSymbol ( ) ) > 0 && std::all_of ( getElements ( ).begin ( ), getElements ( ).end ( ), [&] ( const FormalRTEElement < SymbolType, RankType > & e ) {
+			return e.checkAlphabet ( alphabetF, alphabetK );
 		} );
 }
 
diff --git a/alib2data/src/rte/xml/common/RTEFromXmlParser.h b/alib2data/src/rte/xml/common/RTEFromXmlParser.h
index 7bc933e673..74c714357f 100644
--- a/alib2data/src/rte/xml/common/RTEFromXmlParser.h
+++ b/alib2data/src/rte/xml/common/RTEFromXmlParser.h
@@ -138,10 +138,10 @@ template < class SymbolType, class RankType >
 ext::rvalue_ref < FormalRTESymbolAlphabet < SymbolType, RankType > > RTEFromXmlParser::parseFormalRTESymbolAlphabet ( ext::deque < sax::Token >::iterator & input ) {
 	sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, "symbol" );
 	common::ranked_symbol < SymbolType, RankType > symbol = core::xmlApi < common::ranked_symbol < SymbolType, RankType > >::parse ( input );
-	ext::vector < ext::smart_ptr < FormalRTEElement < SymbolType, RankType > > > elements;
+	ext::ptr_vector < FormalRTEElement < SymbolType, RankType > > elements;
 
 	while ( sax::FromXMLParserHelper::isTokenType ( input, sax::Token::TokenType::START_ELEMENT ) )
-		elements.push_back ( ext::smart_ptr < FormalRTEElement < SymbolType, RankType > > ( ( ( FormalRTEElement < SymbolType, RankType > && ) parseFormalRTEElement < SymbolType, RankType > ( input ) ).clone ( ) ) );
+		elements.push_back ( ( FormalRTEElement < SymbolType, RankType > && ) parseFormalRTEElement < SymbolType, RankType > ( input ) );
 
 	ext::rvalue_ref < FormalRTESymbolAlphabet < SymbolType, RankType > > ret ( new FormalRTESymbolAlphabet < SymbolType, RankType > ( std::move ( symbol ), std::move ( elements ) ) );
 
diff --git a/alib2data/src/rte/xml/common/RTEToXmlComposer.h b/alib2data/src/rte/xml/common/RTEToXmlComposer.h
index 533aace461..eabf059137 100644
--- a/alib2data/src/rte/xml/common/RTEToXmlComposer.h
+++ b/alib2data/src/rte/xml/common/RTEToXmlComposer.h
@@ -78,8 +78,8 @@ void RTEToXmlComposer::Formal::visit ( const FormalRTESymbolAlphabet < SymbolTyp
 	out.emplace_back ( sax::Token ( "symbol", sax::Token::TokenType::START_ELEMENT ) );
 	core::xmlApi < common::ranked_symbol < SymbolType, RankType > >::compose ( out, symbol.getSymbol ( ) );
 
-	for ( const ext::smart_ptr < const FormalRTEElement < SymbolType, RankType > > & element : symbol.getElements ( ) )
-		element->template accept < void, RTEToXmlComposer::Formal > ( out );
+	for ( const FormalRTEElement < SymbolType, RankType > & element : symbol.getElements ( ) )
+		element.template accept < void, RTEToXmlComposer::Formal > ( out );
 
 	out.emplace_back ( sax::Token ( "symbol", sax::Token::TokenType::END_ELEMENT ) );
 }
diff --git a/alib2data/test-src/rte/RTETest.cpp b/alib2data/test-src/rte/RTETest.cpp
index f78353a9db..ae4283cb92 100644
--- a/alib2data/test-src/rte/RTETest.cpp
+++ b/alib2data/test-src/rte/RTETest.cpp
@@ -69,9 +69,9 @@ void RTETest::testCopyConstruct ( ) {
 
 		rte::FormalRTEAlternation < DefaultSymbolType, primitive::Unsigned > alt = rte::FormalRTEAlternation < DefaultSymbolType, primitive::Unsigned > ( b, c );
 
-		ext::vector < ext::smart_ptr < rte::FormalRTEElement < DefaultSymbolType, primitive::Unsigned > > > children;
-		children.push_back ( ext::smart_ptr < rte::FormalRTEElement < DefaultSymbolType, primitive::Unsigned > > ( std::move ( y ).clone ( ) ) );
-		children.push_back ( ext::smart_ptr < rte::FormalRTEElement < DefaultSymbolType, primitive::Unsigned > > ( std::move ( z ).clone ( ) ) );
+		ext::ptr_vector < rte::FormalRTEElement < DefaultSymbolType, primitive::Unsigned > > children;
+		children.push_back ( std::move ( y ) );
+		children.push_back ( std::move ( z ) );
 		rte::FormalRTESymbolAlphabet < DefaultSymbolType, primitive::Unsigned > a = rte::FormalRTESymbolAlphabet < DefaultSymbolType, primitive::Unsigned > ( symb_a2, std::move ( children ) );
 
 		rte::FormalRTEIteration < DefaultSymbolType, primitive::Unsigned > iter = rte::FormalRTEIteration < DefaultSymbolType, primitive::Unsigned > ( a, rte::FormalRTESymbolSubst < DefaultSymbolType, primitive::Unsigned > ( symb_y0 ) );
@@ -106,13 +106,13 @@ void RTETest::testXMLParser ( ) {
 
 	rte::FormalRTEAlternation < DefaultSymbolType, primitive::Unsigned > alt = rte::FormalRTEAlternation < DefaultSymbolType, primitive::Unsigned > ( b, c );
 
-	ext::vector < ext::smart_ptr < rte::FormalRTEElement < DefaultSymbolType, primitive::Unsigned > > > children_a;
-	children_a.push_back ( ext::smart_ptr < rte::FormalRTEElement < DefaultSymbolType, primitive::Unsigned > > ( std::move ( y ).clone ( ) ) );
-	children_a.push_back ( ext::smart_ptr < rte::FormalRTEElement < DefaultSymbolType, primitive::Unsigned > > ( std::move ( z ).clone ( ) ) );
+	ext::ptr_vector < rte::FormalRTEElement < DefaultSymbolType, primitive::Unsigned > > children_a;
+	children_a.push_back ( std::move ( y ) );
+	children_a.push_back ( std::move ( z ) );
 	rte::FormalRTESymbolAlphabet < DefaultSymbolType, primitive::Unsigned > a = rte::FormalRTESymbolAlphabet < DefaultSymbolType, primitive::Unsigned > ( symb_a2, std::move ( children_a ) );
 
-	ext::vector < ext::smart_ptr < rte::FormalRTEElement < DefaultSymbolType, primitive::Unsigned > > > children_d;
-	children_d.push_back ( ext::smart_ptr < rte::FormalRTEElement < DefaultSymbolType, primitive::Unsigned > > ( std::move ( a ).clone ( ) ) );
+	ext::ptr_vector < rte::FormalRTEElement < DefaultSymbolType, primitive::Unsigned > > children_d;
+	children_d.push_back ( std::move ( a ) );
 	rte::FormalRTESymbolAlphabet < DefaultSymbolType, primitive::Unsigned > d = rte::FormalRTESymbolAlphabet < DefaultSymbolType, primitive::Unsigned > ( symb_d1, children_d );
 
 	rte::FormalRTEIteration < DefaultSymbolType, primitive::Unsigned > iter = rte::FormalRTEIteration < DefaultSymbolType, primitive::Unsigned > ( d, rte::FormalRTESymbolSubst < DefaultSymbolType, primitive::Unsigned > ( symb_y0 ) );
diff --git a/alib2str/src/regexp/string/UnboundedRegExp.h b/alib2str/src/regexp/string/UnboundedRegExp.h
index c7cb92cc3b..37672a06f2 100644
--- a/alib2str/src/regexp/string/UnboundedRegExp.h
+++ b/alib2str/src/regexp/string/UnboundedRegExp.h
@@ -177,7 +177,7 @@ void stringApi < regexp::UnboundedRegExpStructure < SymbolType > >::Unbounded::v
 	if ( alternation.getElements ( ).size ( ) == 0) {
 		std::get < 1 > ( out ) << "#0";
 	} else if ( alternation.getElements ( ).size ( ) == 1) {
-		alternation.getElements ( ) [ 0 ]->template accept < void, core::stringApi < regexp::UnboundedRegExpStructure < SymbolType > >::Unbounded > ( out );
+		alternation.getElements ( ) [ 0 ].template accept < void, core::stringApi < regexp::UnboundedRegExpStructure < SymbolType > >::Unbounded > ( out );
 	} else {
 		Priority outerPriorityMinimum = std::get < 0 > ( out );
 		if ( outerPriorityMinimum == Priority::CONCATENATION || outerPriorityMinimum == Priority::FACTOR )
@@ -190,7 +190,7 @@ void stringApi < regexp::UnboundedRegExpStructure < SymbolType > >::Unbounded::v
 				std::get < 1 > ( out ) << '+';
 			}
 			std::get < 0 > ( out ) = Priority::ALTERNATION;
-			element->template accept < void, core::stringApi < regexp::UnboundedRegExpStructure < SymbolType > >::Unbounded > ( out );
+			element.template accept < void, core::stringApi < regexp::UnboundedRegExpStructure < SymbolType > >::Unbounded > ( out );
 		}
 		if ( outerPriorityMinimum == Priority::CONCATENATION || outerPriorityMinimum == Priority::FACTOR )
 			std::get < 1 > ( out ) << ')';
@@ -203,7 +203,7 @@ void stringApi < regexp::UnboundedRegExpStructure < SymbolType > >::Unbounded::v
 	if ( concatenation.getElements ( ).size ( ) == 0) {
 		std::get < 1 > ( out ) << "#E";
 	} else if ( concatenation.getElements ( ).size ( ) == 1 ) {
-		concatenation.getElements ( ) [ 0 ]->template accept < void, core::stringApi < regexp::UnboundedRegExpStructure < SymbolType > >::Unbounded > ( out );
+		concatenation.getElements ( ) [ 0 ].template accept < void, core::stringApi < regexp::UnboundedRegExpStructure < SymbolType > >::Unbounded > ( out );
 	} else {
 		if ( outerPriorityMinimum == Priority::FACTOR )
 			std::get < 1 > ( out ) << '(';
@@ -215,7 +215,7 @@ void stringApi < regexp::UnboundedRegExpStructure < SymbolType > >::Unbounded::v
 				std::get < 1 > ( out ) << ' ';
 			}
 			std::get < 0 > ( out ) = Priority::CONCATENATION;
-			element->template accept < void, core::stringApi < regexp::UnboundedRegExpStructure < SymbolType > >::Unbounded > ( out );
+			element.template accept < void, core::stringApi < regexp::UnboundedRegExpStructure < SymbolType > >::Unbounded > ( out );
 		}
 		if ( outerPriorityMinimum == Priority::FACTOR )
 			std::get < 1 > ( out ) << ')';
-- 
GitLab