diff --git a/alib2algo/src/automaton/convert/ToRegExpAlgebraic.cpp b/alib2algo/src/automaton/convert/ToRegExpAlgebraic.cpp
index a2306259faafee6843e89c897de84864a53c3212..161e31e4b9dc05fe2af649a509bc553e3641895e 100644
--- a/alib2algo/src/automaton/convert/ToRegExpAlgebraic.cpp
+++ b/alib2algo/src/automaton/convert/ToRegExpAlgebraic.cpp
@@ -78,10 +78,10 @@ regexp::UnboundedRegExp ToRegExpAlgebraic::convert( const automaton::MultiInitia
 		// set symbol for which the solver will solve equation system
 		alphabet::Symbol tmp { alphabet::LabeledSymbol ( initialSymbol ) };
 
-		alternation.appendElement( solver.solve( tmp ).getRegExp() );
+		alternation.appendElement( solver.solve( tmp ).getRegExp().getStructure() );
 	}
 
-	return regexp::UnboundedRegExp { alternation };
+	return regexp::UnboundedRegExp { regexp::UnboundedRegExpStructure ( alternation ) };
 }
 
 auto ToRegExpAlgebraicMultiInitialStateNFA = ToRegExpAlgebraic::RegistratorWrapper<regexp::UnboundedRegExp, automaton::MultiInitialStateNFA < > >(ToRegExpAlgebraic::convert);
diff --git a/alib2algo/src/automaton/convert/ToRegExpStateElimination.cpp b/alib2algo/src/automaton/convert/ToRegExpStateElimination.cpp
index be91b71206f6ad55c4a713de40cde72db3f63531..a20c8c8c01aa5fa90570bddb0f1cff2a78f4b6e5 100644
--- a/alib2algo/src/automaton/convert/ToRegExpStateElimination.cpp
+++ b/alib2algo/src/automaton/convert/ToRegExpStateElimination.cpp
@@ -25,7 +25,7 @@ regexp::RegExp ToRegExpStateElimination::convert(const automaton::Automaton& aut
 template<class T>
 regexp::RegExp ToRegExpStateElimination::convert(const T& automaton) {
 	if(automaton.getFinalStates().size() == 0)
-		return regexp::RegExp(regexp::UnboundedRegExp(regexp::UnboundedRegExpEmpty()));
+		return regexp::RegExp(regexp::UnboundedRegExp(regexp::UnboundedRegExpStructure(regexp::UnboundedRegExpEmpty())));
 
 	// steps 1 + 2
 	automaton::ExtendedNFA extendedAutomaton(automaton);
@@ -79,7 +79,7 @@ automaton::ExtendedNFA ToRegExpStateElimination::eliminateState(const automaton:
 }
 
 const regexp::RegExp ToRegExpStateElimination::transition(const automaton::ExtendedNFA& automaton, const label::Label& from, const label::Label& to) {
-	regexp::RegExp ret(regexp::UnboundedRegExp(regexp::UnboundedRegExpEmpty { }));
+	regexp::RegExp ret(regexp::UnboundedRegExp(regexp::UnboundedRegExpStructure(regexp::UnboundedRegExpEmpty { })));
 
 	for(const auto& transition: automaton.getTransitionsFromState(from))
 		if(transition.second.count(to) > 0)
@@ -95,7 +95,7 @@ void ToRegExpStateElimination::extendExtendedNFA(automaton::ExtendedNFA& automat
 		label::Label q0 = label::createUniqueLabel(initState, automaton.getStates());
 		automaton.addState(q0);
 
-		regexp::UnboundedRegExp regexp { regexp::UnboundedRegExpEpsilon() };
+		regexp::UnboundedRegExp regexp { regexp::UnboundedRegExpStructure ( regexp::UnboundedRegExpEpsilon() ) };
 		automaton.addTransition(q0, regexp::RegExp{regexp}, initState);
 
 		automaton.setInitialState(q0);
@@ -107,7 +107,7 @@ void ToRegExpStateElimination::extendExtendedNFA(automaton::ExtendedNFA& automat
 		automaton.addState(f);
 
 		for(const auto &state : automaton.getFinalStates() ) {
-			regexp::UnboundedRegExp regexp { regexp::UnboundedRegExpEpsilon() };
+			regexp::UnboundedRegExp regexp { regexp::UnboundedRegExpStructure ( regexp::UnboundedRegExpEpsilon() ) };
 			automaton.addTransition(state, regexp::RegExp{regexp}, f);
 
 			automaton.removeFinalState(state);
diff --git a/alib2algo/src/equations/LeftRegularEquationSolver.cpp b/alib2algo/src/equations/LeftRegularEquationSolver.cpp
index 19bb0e99e2024e1077cc95653e2853c68015a082..41c517e5e7bcd1a871a22c7adc869d072251ba9c 100644
--- a/alib2algo/src/equations/LeftRegularEquationSolver.cpp
+++ b/alib2algo/src/equations/LeftRegularEquationSolver.cpp
@@ -74,7 +74,7 @@ regexp::UnboundedRegExp LeftRegularEquationSolver::eliminate(void) {
 		}
 	}
 
-	return regexp::simplify::RegExpOptimize::optimize(regexp::UnboundedRegExp(std::move( equationFinal.find(*nonterminalSymbolsByDepth.begin())->second)));
+	return regexp::simplify::RegExpOptimize::optimize(regexp::UnboundedRegExp(regexp::UnboundedRegExpStructure(std::move( equationFinal.find(*nonterminalSymbolsByDepth.begin())->second))));
 }
 
 } /* namespace equations */
diff --git a/alib2algo/src/equations/RightRegularEquationSolver.cpp b/alib2algo/src/equations/RightRegularEquationSolver.cpp
index 71c515d5f2e95cec9318606fa048d99c07aa2e05..05756e16f24b8051688bd6fd2d46d4f2b6d370ae 100644
--- a/alib2algo/src/equations/RightRegularEquationSolver.cpp
+++ b/alib2algo/src/equations/RightRegularEquationSolver.cpp
@@ -74,7 +74,7 @@ regexp::UnboundedRegExp RightRegularEquationSolver::eliminate(void) {
 		}
 	}
 
-	return regexp::simplify::RegExpOptimize::optimize(regexp::UnboundedRegExp(std::move( equationFinal.find(*nonterminalSymbolsByDepth.begin())->second)));
+	return regexp::simplify::RegExpOptimize::optimize(regexp::UnboundedRegExp(regexp::UnboundedRegExpStructure(std::move( equationFinal.find(*nonterminalSymbolsByDepth.begin())->second))));
 }
 
 } /* namespace equations */
diff --git a/alib2algo/src/regexp/convert/ToAutomatonThompson.cpp b/alib2algo/src/regexp/convert/ToAutomatonThompson.cpp
index e8d2b461316091f80dc7ee754ad59e5a18aa36c7..150947b19d3755610c23ca4035d4d6bf3e9bc864 100644
--- a/alib2algo/src/regexp/convert/ToAutomatonThompson.cpp
+++ b/alib2algo/src/regexp/convert/ToAutomatonThompson.cpp
@@ -24,7 +24,7 @@ automaton::EpsilonNFA < > ToAutomatonThompson::convert(const regexp::FormalRegEx
 	automaton::EpsilonNFA < >& automaton = std::get<0>(out);
 	automaton.setInputAlphabet(regexp.getAlphabet());
 
-	regexp.getRegExp().Accept((void*) &out, ToAutomatonThompson::Formal::FORMAL);
+	regexp.getRegExp().getStructure().Accept((void*) &out, ToAutomatonThompson::Formal::FORMAL);
 
 	automaton.setInitialState(*std::get<2>(out));
 	automaton.setFinalStates(std::set<label::Label>{*std::get<3>(out)});
@@ -43,7 +43,7 @@ automaton::EpsilonNFA < > ToAutomatonThompson::convert(const regexp::UnboundedRe
 	automaton::EpsilonNFA < >& automaton = std::get<0>(out);
 	automaton.setInputAlphabet(regexp.getAlphabet());
 
-	regexp.getRegExp().Accept((void*) &out, ToAutomatonThompson::Unbounded::UNBOUNDED);
+	regexp.getRegExp().getStructure().Accept((void*) &out, ToAutomatonThompson::Unbounded::UNBOUNDED);
 
 	automaton.setInitialState(*std::get<2>(out));
 	automaton.setFinalStates(std::set<label::Label>{*std::get<3>(out)});
diff --git a/alib2algo/src/regexp/generate/RandomRegExpFactory.cpp b/alib2algo/src/regexp/generate/RandomRegExpFactory.cpp
index 2294629b5011472920020a307e3e63d1d0c43443..cdb4b5776fcb3a332c7fa37c7c0cc209bbb441b8 100644
--- a/alib2algo/src/regexp/generate/RandomRegExpFactory.cpp
+++ b/alib2algo/src/regexp/generate/RandomRegExpFactory.cpp
@@ -67,7 +67,7 @@ regexp::UnboundedRegExp RandomRegExpFactory::generateUnboundedRegExp( size_t lea
 }
 
 regexp::UnboundedRegExp RandomRegExpFactory::SimpleUnboundedRegExp( size_t n, size_t h, const std::vector<const regexp::UnboundedRegExpElement*> & elems) {
-	return regexp::UnboundedRegExp (SimpleUnboundedRegExpElement(n, h, elems));
+	return regexp::UnboundedRegExp (regexp::UnboundedRegExpStructure ( SimpleUnboundedRegExpElement(n, h, elems)));
 }
 
 std::rvalue_ref < regexp::UnboundedRegExpElement > RandomRegExpFactory::SimpleUnboundedRegExpElement(size_t n, size_t h, const std::vector<const regexp::UnboundedRegExpElement*> & elems) {
diff --git a/alib2algo/src/regexp/glushkov/GlushkovTraversal.cpp b/alib2algo/src/regexp/glushkov/GlushkovTraversal.cpp
index e9eebff36eece37c5d7cba0c4d4c3c309c2f4b2d..45a6fca314013d7dd0baf8f56569894c3fcc2e2e 100644
--- a/alib2algo/src/regexp/glushkov/GlushkovTraversal.cpp
+++ b/alib2algo/src/regexp/glushkov/GlushkovTraversal.cpp
@@ -24,19 +24,19 @@ alphabet::Symbol GlushkovTraversal::getSymbolFromGlushkovPair ( const alphabet::
 // -----------------------------------------------------------------------------
 
 bool GlushkovTraversal::pos ( const UnboundedRegExpSymbol & symbol, const regexp::UnboundedRegExp & node ) {
-	return pos ( node.getRegExp ( ), symbol );
+	return pos ( node.getRegExp ( ).getStructure ( ), symbol );
 }
 
 std::set < UnboundedRegExpSymbol > GlushkovTraversal::first ( const regexp::UnboundedRegExp & re ) {
-	return first ( re.getRegExp ( ) );
+	return first ( re.getRegExp ( ).getStructure ( ) );
 }
 
 std::set < UnboundedRegExpSymbol > GlushkovTraversal::last ( const regexp::UnboundedRegExp & re ) {
-	return last ( re.getRegExp ( ) );
+	return last ( re.getRegExp ( ).getStructure ( ) );
 }
 
 std::set < UnboundedRegExpSymbol > GlushkovTraversal::follow ( const regexp::UnboundedRegExp & re, const UnboundedRegExpSymbol & symbol ) {
-	return follow ( re.getRegExp ( ), symbol );
+	return follow ( re.getRegExp ( ).getStructure ( ), symbol );
 }
 
 // -----------------------------------------------------------------------------
@@ -330,7 +330,7 @@ bool GlushkovTraversal::pos ( const regexp::UnboundedRegExpEpsilon & /* node */,
 UnboundedRegExp GlushkovTraversal::index ( const regexp::UnboundedRegExp & re ) {
 	int i = 1;
 
-	return UnboundedRegExp ( index ( re.getRegExp ( ), i ) );
+	return UnboundedRegExp ( regexp::UnboundedRegExpStructure ( index ( re.getRegExp ( ).getStructure ( ), i ) ) );
 }
 
 std::rvalue_ref < UnboundedRegExpElement > GlushkovTraversal::index ( const regexp::UnboundedRegExpElement & node, int & i ) {
diff --git a/alib2algo/src/regexp/properties/RegExpEmpty.cpp b/alib2algo/src/regexp/properties/RegExpEmpty.cpp
index beb2250f6e14eee87105281f3dbe2075848bbfb5..3d3155936ff6aa27726154043fe287440b276f63 100644
--- a/alib2algo/src/regexp/properties/RegExpEmpty.cpp
+++ b/alib2algo/src/regexp/properties/RegExpEmpty.cpp
@@ -24,7 +24,7 @@ bool RegExpEmpty::languageIsEmpty(const regexp::FormalRegExpElement& regexp) {
 }
 
 bool RegExpEmpty::languageIsEmpty(const regexp::FormalRegExp& regexp) {
-	return languageIsEmpty(regexp.getRegExp());
+	return languageIsEmpty(regexp.getRegExp().getStructure());
 }
 
 auto RegExpEmptyFormalRegExp = RegExpEmpty::RegistratorWrapper<bool, regexp::FormalRegExp>( RegExpEmpty::languageIsEmpty);
@@ -36,7 +36,7 @@ bool RegExpEmpty::languageIsEmpty(const regexp::UnboundedRegExpElement& regexp)
 }
 
 bool RegExpEmpty::languageIsEmpty(const regexp::UnboundedRegExp& regexp) {
-	return languageIsEmpty(regexp.getRegExp());
+	return languageIsEmpty(regexp.getRegExp().getStructure());
 }
 
 auto RegExpEmptyUnboundedRegExp = RegExpEmpty::RegistratorWrapper<bool, regexp::UnboundedRegExp>( RegExpEmpty::languageIsEmpty);
diff --git a/alib2algo/src/regexp/properties/RegExpEpsilon.cpp b/alib2algo/src/regexp/properties/RegExpEpsilon.cpp
index faa983486722b553b7d1e7588c0a27a4c8e4ea87..94fc179be8ba818cb80d941db995f497828d348c 100644
--- a/alib2algo/src/regexp/properties/RegExpEpsilon.cpp
+++ b/alib2algo/src/regexp/properties/RegExpEpsilon.cpp
@@ -24,7 +24,7 @@ bool RegExpEpsilon::languageContainsEpsilon(const regexp::FormalRegExpElement& r
 }
 
 bool RegExpEpsilon::languageContainsEpsilon(const regexp::FormalRegExp& regexp) {
-	return languageContainsEpsilon(regexp.getRegExp());
+	return languageContainsEpsilon(regexp.getRegExp().getStructure());
 }
 
 auto RegExpEpsilonFormalRegExp = RegExpEpsilon::RegistratorWrapper<bool, regexp::FormalRegExp>( RegExpEpsilon::languageContainsEpsilon);
@@ -36,7 +36,7 @@ bool RegExpEpsilon::languageContainsEpsilon(const regexp::UnboundedRegExpElement
 }
 
 bool RegExpEpsilon::languageContainsEpsilon(const regexp::UnboundedRegExp& regexp) {
-	return languageContainsEpsilon(regexp.getRegExp());
+	return languageContainsEpsilon(regexp.getRegExp().getStructure());
 }
 
 auto RegExpEpsilonUnboundedRegExp = RegExpEpsilon::RegistratorWrapper<bool, regexp::UnboundedRegExp>( RegExpEpsilon::languageContainsEpsilon);
diff --git a/alib2algo/src/regexp/simplify/RegExpOptimize.cpp b/alib2algo/src/regexp/simplify/RegExpOptimize.cpp
index 17714e9740d7a3d2fd9ccc9804eac56a4059170b..c11146e6bea794c54522fc99dd24a669d807f22b 100644
--- a/alib2algo/src/regexp/simplify/RegExpOptimize.cpp
+++ b/alib2algo/src/regexp/simplify/RegExpOptimize.cpp
@@ -23,17 +23,17 @@ regexp::RegExp RegExpOptimize::optimize(const regexp::RegExp& regexp) {
 }
 
 FormalRegExp RegExpOptimize::optimize( FormalRegExp const & regexp ) {
-	FormalRegExpElement* optimized = optimizeInner( regexp.getRegExp( ) );
+	FormalRegExpElement* optimized = optimizeInner( regexp.getRegExp( ).getStructure ( ) );
 
-	return FormalRegExp ( std::manage_move ( optimized ) );
+	return FormalRegExp ( regexp::FormalRegExpStructure ( std::manage_move ( optimized ) ) );
 }
 
 auto RegExpOptimizeFormalRegEpx = RegExpOptimize::RegistratorWrapper<FormalRegExp, FormalRegExp>(RegExpOptimize::optimize);
 
 UnboundedRegExp RegExpOptimize::optimize( UnboundedRegExp const & regexp ) {
-	UnboundedRegExpElement* optimized = optimizeInner( regexp.getRegExp( ) );
+	UnboundedRegExpElement* optimized = optimizeInner( regexp.getRegExp( ).getStructure( ) );
 
-	return UnboundedRegExp ( std::manage_move ( optimized ) );
+	return UnboundedRegExp ( regexp::UnboundedRegExpStructure ( std::manage_move ( optimized ) ) );
 }
 
 auto RegExpOptimizeUnboundedRegEpx = RegExpOptimize::RegistratorWrapper<UnboundedRegExp, UnboundedRegExp>(RegExpOptimize::optimize);
diff --git a/alib2algo/src/regexp/transform/RegExpAlternate.cpp b/alib2algo/src/regexp/transform/RegExpAlternate.cpp
index 6a08eecbfdba1cd50bc8097c666b66b32a74b062..c522c39e42fc1df41758ab45f318ab7699a0cab4 100644
--- a/alib2algo/src/regexp/transform/RegExpAlternate.cpp
+++ b/alib2algo/src/regexp/transform/RegExpAlternate.cpp
@@ -17,16 +17,16 @@ regexp::RegExp RegExpAlternate::alternate(const regexp::RegExp& first, const reg
 }
 
 regexp::FormalRegExp RegExpAlternate::alternate(const regexp::FormalRegExp& first, const regexp::FormalRegExp& second) {
-	return regexp::FormalRegExp(regexp::FormalRegExpAlternation(first.getRegExp(), second.getRegExp()));
+	return regexp::FormalRegExp(regexp::FormalRegExpStructure(regexp::FormalRegExpAlternation(first.getRegExp().getStructure(), second.getRegExp().getStructure())));
 }
 
 auto RegExpAlternateFormalRegExp = RegExpAlternate::RegistratorWrapper<regexp::FormalRegExp, regexp::FormalRegExp>(RegExpAlternate::alternate);
 
 regexp::UnboundedRegExp RegExpAlternate::alternate(const regexp::UnboundedRegExp& first, const regexp::UnboundedRegExp& second) {
 	regexp::UnboundedRegExpAlternation con;
-	con.appendElement(first.getRegExp());
-	con.appendElement(second.getRegExp());
-	return regexp::UnboundedRegExp(con);
+	con.appendElement(first.getRegExp().getStructure());
+	con.appendElement(second.getRegExp().getStructure());
+	return regexp::UnboundedRegExp(regexp::UnboundedRegExpStructure(con));
 }
 
 auto RegExpAlternateUnboundedRegExp = RegExpAlternate::RegistratorWrapper<regexp::UnboundedRegExp, regexp::UnboundedRegExp>(RegExpAlternate::alternate);
diff --git a/alib2algo/src/regexp/transform/RegExpConcatenate.cpp b/alib2algo/src/regexp/transform/RegExpConcatenate.cpp
index d2b721048c96bb5a43ca4387241da7fb3fb5a8fa..a04990afa2b737b08e2f73ab9e36928801ea8be8 100644
--- a/alib2algo/src/regexp/transform/RegExpConcatenate.cpp
+++ b/alib2algo/src/regexp/transform/RegExpConcatenate.cpp
@@ -17,16 +17,16 @@ regexp::RegExp RegExpConcatenate::concatenate(const regexp::RegExp& first, const
 }
 
 regexp::FormalRegExp RegExpConcatenate::concatenate(const regexp::FormalRegExp& first, const regexp::FormalRegExp& second) {
-	return regexp::FormalRegExp(regexp::FormalRegExpConcatenation(first.getRegExp(), second.getRegExp()));
+	return regexp::FormalRegExp(regexp::FormalRegExpStructure(regexp::FormalRegExpConcatenation(first.getRegExp().getStructure(), second.getRegExp().getStructure())));
 }
 
 auto RegExpConcatenateFormalRegExp = RegExpConcatenate::RegistratorWrapper<regexp::FormalRegExp, regexp::FormalRegExp>(RegExpConcatenate::concatenate);
 
 regexp::UnboundedRegExp RegExpConcatenate::concatenate(const regexp::UnboundedRegExp& first, const regexp::UnboundedRegExp& second) {
 	regexp::UnboundedRegExpConcatenation con;
-	con.appendElement(first.getRegExp());
-	con.appendElement(second.getRegExp());
-	return regexp::UnboundedRegExp(con);
+	con.appendElement(first.getRegExp().getStructure());
+	con.appendElement(second.getRegExp().getStructure());
+	return regexp::UnboundedRegExp(regexp::UnboundedRegExpStructure(con));
 }
 
 auto RegExpConcatenateUnboundedRegExp = RegExpConcatenate::RegistratorWrapper<regexp::UnboundedRegExp, regexp::UnboundedRegExp>(RegExpConcatenate::concatenate);
diff --git a/alib2algo/src/regexp/transform/RegExpDerivation.cpp b/alib2algo/src/regexp/transform/RegExpDerivation.cpp
index 2414c50ba79ea01c6e7ffc88ec7e4db952480e2a..ca1287e112a7023d39a50cb7b76cd6a94a83749e 100644
--- a/alib2algo/src/regexp/transform/RegExpDerivation.cpp
+++ b/alib2algo/src/regexp/transform/RegExpDerivation.cpp
@@ -18,7 +18,7 @@ regexp::RegExp RegExpDerivation::derivation(const regexp::RegExp& regexp, const
 }
 
 regexp::FormalRegExp RegExpDerivation::derivation(const regexp::FormalRegExp& regexp, const string::LinearString < >& string) {
-	std::unique_ptr < regexp::FormalRegExpElement > newRegExp ( regexp.getRegExp().clone() );
+	std::unique_ptr < regexp::FormalRegExpElement > newRegExp ( regexp.getRegExp().getStructure().clone() );
 
 	for(const auto& symbol : string.getContent()) {
 		std::pair<alphabet::Symbol, std::unique_ptr < regexp::FormalRegExpElement > > out(symbol, nullptr);
@@ -26,13 +26,13 @@ regexp::FormalRegExp RegExpDerivation::derivation(const regexp::FormalRegExp& re
 		newRegExp = std::move ( out.second );
 	}
 
-	return regexp::FormalRegExp ( std::move ( * newRegExp ) );
+	return regexp::FormalRegExp ( regexp::FormalRegExpStructure ( std::move ( * newRegExp ) ) );
 }
 
 auto RegExpDerivationFormalRegExp = RegExpDerivation::RegistratorWrapper<regexp::FormalRegExp, regexp::FormalRegExp>(RegExpDerivation::derivation);
 
 regexp::UnboundedRegExp RegExpDerivation::derivation(const regexp::UnboundedRegExp& regexp, const string::LinearString < >& string) {
-	std::unique_ptr < regexp::UnboundedRegExpElement > newRegExp ( regexp.getRegExp().clone() );
+	std::unique_ptr < regexp::UnboundedRegExpElement > newRegExp ( regexp.getRegExp().getStructure().clone() );
 
 	for(const auto& symbol : string.getContent()) {
 		std::pair<alphabet::Symbol, std::unique_ptr < regexp::UnboundedRegExpElement > > out(symbol, nullptr);
@@ -40,7 +40,7 @@ regexp::UnboundedRegExp RegExpDerivation::derivation(const regexp::UnboundedRegE
 		newRegExp = std::move ( out.second );
 	}
 
-	return regexp::UnboundedRegExp (std::move (* newRegExp));
+	return regexp::UnboundedRegExp ( regexp::UnboundedRegExpStructure ( std::move ( * newRegExp ) ) );
 }
 
 auto RegExpDerivationUnboundedRegExp = RegExpDerivation::RegistratorWrapper<regexp::UnboundedRegExp, regexp::UnboundedRegExp>(RegExpDerivation::derivation);
diff --git a/alib2algo/src/regexp/transform/RegExpIntegral.cpp b/alib2algo/src/regexp/transform/RegExpIntegral.cpp
index 15442a71bd2af4d998de0d260011c9caedd256e7..047b2c5db8f9e76d3327d5d3affc73854bf3ab9e 100644
--- a/alib2algo/src/regexp/transform/RegExpIntegral.cpp
+++ b/alib2algo/src/regexp/transform/RegExpIntegral.cpp
@@ -16,7 +16,7 @@ regexp::RegExp RegExpIntegral::integral(const regexp::RegExp& regexp, const stri
 }
 
 regexp::FormalRegExp RegExpIntegral::integral(const regexp::FormalRegExp& regexp, const string::LinearString < >& string) {
-	std::unique_ptr < regexp::FormalRegExpElement > newRegExp ( regexp.getRegExp().clone() );
+	std::unique_ptr < regexp::FormalRegExpElement > newRegExp ( regexp.getRegExp().getStructure().clone() );
 
 	for(const auto& symbol : string.getContent()) {
 		std::pair<alphabet::Symbol, std::unique_ptr < regexp::FormalRegExpElement > > out(symbol, nullptr);
@@ -24,13 +24,13 @@ regexp::FormalRegExp RegExpIntegral::integral(const regexp::FormalRegExp& regexp
 		newRegExp = std::move ( out.second );
 	}
 
-	return regexp::FormalRegExp (* newRegExp);
+	return regexp::FormalRegExp ( regexp::FormalRegExpStructure ( * newRegExp ) );
 }
 
 auto RegExpIntegralFormalRegExp = RegExpIntegral::RegistratorWrapper<regexp::FormalRegExp, regexp::FormalRegExp>(RegExpIntegral::integral);
 
 regexp::UnboundedRegExp RegExpIntegral::integral(const regexp::UnboundedRegExp& regexp, const string::LinearString < >& string) {
-	std::unique_ptr < regexp::UnboundedRegExpElement > newRegExp ( regexp.getRegExp().clone() );
+	std::unique_ptr < regexp::UnboundedRegExpElement > newRegExp ( regexp.getRegExp().getStructure().clone() );
 
 	for(const auto& symbol : string.getContent()) {
 		std::pair<alphabet::Symbol, std::unique_ptr < regexp::UnboundedRegExpElement > > out(symbol, nullptr);
@@ -38,7 +38,7 @@ regexp::UnboundedRegExp RegExpIntegral::integral(const regexp::UnboundedRegExp&
 		newRegExp = std::move ( out.second );
 	}
 
-	return regexp::UnboundedRegExp (* newRegExp);
+	return regexp::UnboundedRegExp ( regexp::UnboundedRegExpStructure( * newRegExp ) );
 }
 
 auto RegExpIntegralUnboundedRegExp = RegExpIntegral::RegistratorWrapper<regexp::UnboundedRegExp, regexp::UnboundedRegExp>(RegExpIntegral::integral);
diff --git a/alib2algo/src/regexp/transform/RegExpIterate.cpp b/alib2algo/src/regexp/transform/RegExpIterate.cpp
index 68aa68e99ba7e4f6044e128f24fa9b066b5d0b01..3728e4d8702417e45bd9fc2a4740f63e1e1fe547 100644
--- a/alib2algo/src/regexp/transform/RegExpIterate.cpp
+++ b/alib2algo/src/regexp/transform/RegExpIterate.cpp
@@ -16,13 +16,13 @@ regexp::RegExp RegExpIterate::iterate(const regexp::RegExp& regexp) {
 }
 
 regexp::FormalRegExp RegExpIterate::iterate(const regexp::FormalRegExp& regexp) {
-	return regexp::FormalRegExp(regexp::FormalRegExpIteration(regexp.getRegExp()));
+	return regexp::FormalRegExp(regexp::FormalRegExpStructure(regexp::FormalRegExpIteration(regexp.getRegExp().getStructure())));
 }
 
 auto RegExpIterateFormalRegExpFormalRegExp = RegExpIterate::RegistratorWrapper<regexp::FormalRegExp, regexp::FormalRegExp>(RegExpIterate::iterate);
 
 regexp::UnboundedRegExp RegExpIterate::iterate(const regexp::UnboundedRegExp& regexp) {
-	return regexp::UnboundedRegExp(regexp::UnboundedRegExpIteration(regexp.getRegExp()));
+	return regexp::UnboundedRegExp(regexp::UnboundedRegExpStructure(regexp::UnboundedRegExpIteration(regexp.getRegExp().getStructure())));
 }
 
 auto RegExpIterateUnboundedRegExpUnboundedRegExp = RegExpIterate::RegistratorWrapper<regexp::UnboundedRegExp, regexp::UnboundedRegExp>(RegExpIterate::iterate);
diff --git a/alib2algo/test-src/regexp/transform/RegExpConcatenateTest.cpp b/alib2algo/test-src/regexp/transform/RegExpConcatenateTest.cpp
index ec9d299307ac7082dbc767b234e6edb8d1702a1f..3292c4d67120392b90d0be71607a8f646d1135f4 100644
--- a/alib2algo/test-src/regexp/transform/RegExpConcatenateTest.cpp
+++ b/alib2algo/test-src/regexp/transform/RegExpConcatenateTest.cpp
@@ -35,7 +35,7 @@ void RegExpConcatenateTest::testRegExpConcatenate() {
 		std::string input1 = "(#E a b)";
 		regexp::RegExp re1 = alib::StringDataFactory::fromString<regexp::RegExp>(input1);
 
-		regexp::RegExp re2(regexp::FormalRegExp(regexp::FormalRegExpConcatenation(regexp::FormalRegExpEmpty {}, regexp::FormalRegExpEpsilon {})));
+		regexp::RegExp re2(regexp::FormalRegExp(regexp::FormalRegExpStructure(regexp::FormalRegExpConcatenation(regexp::FormalRegExpEmpty {}, regexp::FormalRegExpEpsilon {}))));
 
 		regexp::RegExp re = regexp::RegExpConcatenate::concatenate(re1, re2);
 
@@ -45,7 +45,7 @@ void RegExpConcatenateTest::testRegExpConcatenate() {
 		CPPUNIT_ASSERT(re == rer);
 	}
 	{
-		regexp::RegExp re1(regexp::FormalRegExp(regexp::FormalRegExpConcatenation(regexp::FormalRegExpEmpty {}, regexp::FormalRegExpEpsilon {})));
+		regexp::RegExp re1(regexp::FormalRegExp(regexp::FormalRegExpStructure(regexp::FormalRegExpConcatenation(regexp::FormalRegExpEmpty {}, regexp::FormalRegExpEpsilon {}))));
 
 		std::string input2 = "(#E a b)";
 		regexp::RegExp re2 = alib::StringDataFactory::fromString<regexp::RegExp>(input2);
diff --git a/alib2data/src/regexp/RegExp.cpp b/alib2data/src/regexp/RegExp.cpp
index d6a542d951fe6d71de4d155e2be5a3ccc65e0740..d82f1c9e7a58c8df94d342f7f291ae51965e6ba9 100644
--- a/alib2data/src/regexp/RegExp.cpp
+++ b/alib2data/src/regexp/RegExp.cpp
@@ -13,6 +13,7 @@
 #include "unbounded/UnboundedRegExpConcatenation.h"
 
 #include "unbounded/UnboundedRegExp.h"
+#include "unbounded/UnboundedRegExpStructure.h"
 #include <core/xmlApi.hpp>
 
 namespace regexp {
@@ -35,7 +36,7 @@ regexp::RegExp regexpFrom ( std::vector < alphabet::Symbol > string ) {
 	for ( auto & symbol : string )
 		con.appendElement ( regexp::UnboundedRegExpSymbol ( symbol ) );
 
-	return regexp::RegExp { regexp::UnboundedRegExp ( std::move ( con ) ) };
+	return regexp::RegExp { regexp::UnboundedRegExp ( regexp::UnboundedRegExpStructure ( std::move ( con ) ) ) };
 }
 
 regexp::RegExp regexpFrom ( string::LinearString < > string ) {
@@ -44,15 +45,15 @@ regexp::RegExp regexpFrom ( string::LinearString < > string ) {
 	for ( auto & symbol : string.getContent ( ) )
 		con.appendElement ( regexp::UnboundedRegExpSymbol ( symbol ) );
 
-	return regexp::RegExp { regexp::UnboundedRegExp ( std::move ( con ) ) };
+	return regexp::RegExp { regexp::UnboundedRegExp ( regexp::UnboundedRegExpStructure ( std::move ( con ) ) ) };
 }
 
 regexp::RegExp regexpFrom ( alphabet::Symbol symbol ) {
-	return regexp::RegExp { regexp::UnboundedRegExp ( regexp::UnboundedRegExpSymbol ( std::move ( symbol ) ) ) };
+	return regexp::RegExp { regexp::UnboundedRegExp ( regexp::UnboundedRegExpStructure ( regexp::UnboundedRegExpSymbol ( std::move ( symbol ) ) ) ) };
 }
 
 regexp::RegExp regexpFrom ( ) {
-	return regexp::RegExp { regexp::UnboundedRegExp ( regexp::UnboundedRegExpEmpty { } ) };
+	return regexp::RegExp { regexp::UnboundedRegExp ( regexp::UnboundedRegExpStructure ( regexp::UnboundedRegExpEmpty { } ) ) };
 }
 
 } /* namespace regexp */
diff --git a/alib2data/src/regexp/RegExpFeatures.h b/alib2data/src/regexp/RegExpFeatures.h
index cd1c24f8fa4e3c681f46a13721ded931fd9794f0..71a183c4b54284aee2bca954bcdd56f6023bcd6f 100644
--- a/alib2data/src/regexp/RegExpFeatures.h
+++ b/alib2data/src/regexp/RegExpFeatures.h
@@ -19,6 +19,7 @@ class RegExp;
 class RegExpBase;
 
 class UnboundedRegExp;
+class UnboundedRegExpStructure;
 
 class UnboundedRegExpElement;
 class UnboundedRegExpAlternation;
@@ -30,6 +31,7 @@ class UnboundedRegExpEpsilon;
 
 
 class FormalRegExp;
+class FormalRegExpStructure;
 
 class FormalRegExpElement;
 class FormalRegExpAlternation;
diff --git a/alib2data/src/regexp/formal/FormalRegExp.cpp b/alib2data/src/regexp/formal/FormalRegExp.cpp
index 6d4ff0fb61cacf11e83282cdf514b8cbda0305fc..49962d3a232c34332f404ec4bf6a860a1dfc4adf 100644
--- a/alib2data/src/regexp/formal/FormalRegExp.cpp
+++ b/alib2data/src/regexp/formal/FormalRegExp.cpp
@@ -25,23 +25,18 @@
 
 namespace regexp {
 
-FormalRegExp::FormalRegExp ( std::set < alphabet::Symbol > alphabet, FormalRegExpElement && regExp ) : std::Components < FormalRegExp, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::move ( alphabet ) ), std::tuple < > ( ) ), regExp ( NULL ) {
-	setRegExp ( std::move ( regExp ) );
-}
-
-FormalRegExp::FormalRegExp ( std::set < alphabet::Symbol > alphabet, const FormalRegExpElement & regExp ) : FormalRegExp ( std::move ( alphabet ), std::move_copy ( regExp ) ) {
-}
-
-FormalRegExp::FormalRegExp ( ) : FormalRegExp ( std::set < alphabet::Symbol > ( ), FormalRegExpEmpty ( ) ) {
+FormalRegExp::FormalRegExp ( std::set < alphabet::Symbol > alphabet, FormalRegExpStructure regExp ) : std::Components < FormalRegExp, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::move ( alphabet ) ), std::tuple < > ( ) ), regExp ( std::move ( regExp ) ) {
+	if ( !this->regExp.getStructure ( ).checkAlphabet ( getAlphabet ( ) ) )
+		throw exception::CommonException ( "Input symbols not in the alphabet." );
 }
 
-FormalRegExp::FormalRegExp ( FormalRegExpElement && regExp ) : FormalRegExp ( regExp.computeMinimalAlphabet ( ), regExp ) {
+FormalRegExp::FormalRegExp ( ) : FormalRegExp ( std::set < alphabet::Symbol > ( ), FormalRegExpStructure ( ) ) {
 }
 
-FormalRegExp::FormalRegExp ( const FormalRegExpElement & regExp ) : FormalRegExp ( regExp.computeMinimalAlphabet ( ), std::move_copy ( regExp ) ) {
+FormalRegExp::FormalRegExp ( FormalRegExpStructure regExp ) : FormalRegExp ( regExp.getStructure ( ).computeMinimalAlphabet ( ), regExp ) {
 }
 
-FormalRegExp::FormalRegExp ( const UnboundedRegExp & other ) : FormalRegExp ( other.getAlphabet ( ), std::move ( * other.getRegExp ( ).asFormal ( ) ) ) {
+FormalRegExp::FormalRegExp ( const UnboundedRegExp & other ) : FormalRegExp ( other.getAlphabet ( ), FormalRegExpStructure ( other.getRegExp ( ) ) ) {
 }
 
 RegExpBase * FormalRegExp::clone ( ) const {
@@ -52,32 +47,28 @@ RegExpBase * FormalRegExp::plunder ( ) && {
 	return new FormalRegExp ( std::move ( * this ) );
 }
 
-const FormalRegExpElement & FormalRegExp::getRegExp ( ) const {
-	return * regExp;
+const FormalRegExpStructure & FormalRegExp::getRegExp ( ) const {
+	return regExp;
 }
 
-FormalRegExpElement & FormalRegExp::getRegExp ( ) {
-	return * regExp;
+FormalRegExpStructure & FormalRegExp::getRegExp ( ) {
+	return regExp;
 }
 
-void FormalRegExp::setRegExp ( const FormalRegExpElement & regExp ) {
-	setRegExp ( std::move_copy ( regExp ) );
-}
-
-void FormalRegExp::setRegExp ( FormalRegExpElement && param ) {
-	this->regExp = std::smart_ptr < FormalRegExpElement > ( std::move ( param ).plunder ( ) );
-
-	if ( !regExp->checkAlphabet ( getAlphabet ( ) ) )
+void FormalRegExp::setRegExp ( FormalRegExpStructure param ) {
+	if ( !param.getStructure ( ).checkAlphabet ( getAlphabet ( ) ) )
 		throw exception::CommonException ( "Input symbols not in the alphabet." );
+
+	this->regExp = std::move ( param );
 }
 
 void FormalRegExp::operator >>( std::ostream & out ) const {
-	out << "(FormalRegExp " << * ( this->regExp ) << ")";
+	out << "(FormalRegExp " << this->regExp.getStructure ( ) << ")";
 }
 
 int FormalRegExp::compare ( const FormalRegExp & other ) const {
-	auto first = std::tie ( regExp, getAlphabet ( ) );
-	auto second = std::tie ( other.regExp, other.getAlphabet ( ) );
+	auto first = std::tie ( regExp.getStructure ( ), getAlphabet ( ) );
+	auto second = std::tie ( other.regExp.getStructure ( ), other.getAlphabet ( ) );
 
 	std::compare < decltype ( first ) > comp;
 
@@ -95,7 +86,7 @@ FormalRegExp FormalRegExp::parse ( std::deque < sax::Token >::iterator & input )
 
 	std::set < alphabet::Symbol > alphabet = RegExpFromXMLParser::parseAlphabet ( input );
 
-	std::rvalue_ref < FormalRegExpElement > element ( alib::xmlApi < regexp::FormalRegExpElement >::parse ( input ) );
+	FormalRegExpStructure element ( alib::xmlApi < regexp::FormalRegExpStructure >::parse ( input ) );
 	FormalRegExp regexp ( std::move ( alphabet ), std::move ( element ) );
 
 	sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, FormalRegExp::getXmlTagName() );
@@ -106,7 +97,7 @@ FormalRegExp FormalRegExp::parse ( std::deque < sax::Token >::iterator & input )
 void FormalRegExp::compose ( std::deque < sax::Token > & out ) const {
 	out.emplace_back ( FormalRegExp::getXmlTagName(), sax::Token::TokenType::START_ELEMENT );
 	RegExpToXMLComposer::composeAlphabet ( out, getAlphabet ( ) );
-	alib::xmlApi < FormalRegExpElement >::compose ( out, this->getRegExp ( ) );
+	alib::xmlApi < FormalRegExpStructure >::compose ( out, this->getRegExp ( ) );
 	out.emplace_back ( FormalRegExp::getXmlTagName(), sax::Token::TokenType::END_ELEMENT );
 }
 
diff --git a/alib2data/src/regexp/formal/FormalRegExp.h b/alib2data/src/regexp/formal/FormalRegExp.h
index 3d67488551d9c970cf0ed85c4b6e8137aff68b46..bd320398d792d72092cb082ad9bee412c5e559ca 100644
--- a/alib2data/src/regexp/formal/FormalRegExp.h
+++ b/alib2data/src/regexp/formal/FormalRegExp.h
@@ -13,7 +13,7 @@
 #include <core/components.hpp>
 
 #include "../RegExpBase.h"
-#include "FormalRegExpElement.h"
+#include "FormalRegExpStructure.h"
 #include "../../alphabet/Symbol.h"
 
 namespace regexp {
@@ -27,7 +27,7 @@ class GeneralAlphabet;
  */
 class FormalRegExp : public RegExpBase, public std::Components < FormalRegExp, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > {
 protected:
-	std::smart_ptr < FormalRegExpElement > regExp;
+	FormalRegExpStructure regExp;
 
 public:
 	/**
@@ -42,28 +42,25 @@ public:
 
 	explicit FormalRegExp ( );
 
-	explicit FormalRegExp ( std::set < alphabet::Symbol > alphabet, FormalRegExpElement && regExp );
-	explicit FormalRegExp ( std::set < alphabet::Symbol > alphabet, const FormalRegExpElement & regExp );
-	explicit FormalRegExp ( FormalRegExpElement && regExp );
-	explicit FormalRegExp ( const FormalRegExpElement & regExp );
+	explicit FormalRegExp ( std::set < alphabet::Symbol > alphabet, FormalRegExpStructure regExp );
+	explicit FormalRegExp ( FormalRegExpStructure regExp );
 	explicit FormalRegExp ( const UnboundedRegExp & other );
 
 	/**
 	 * @return Root node of the regular expression tree
 	 */
-	const FormalRegExpElement & getRegExp ( ) const;
+	const FormalRegExpStructure & getRegExp ( ) const;
 
 	/**
 	 * @return Root node of the regular expression tree
 	 */
-	FormalRegExpElement & getRegExp ( );
+	FormalRegExpStructure & getRegExp ( );
 
 	/**
 	 * Sets the root node of the regular expression tree
 	 * @param regExp root node to set
 	 */
-	void setRegExp ( FormalRegExpElement && regExp );
-	void setRegExp ( const FormalRegExpElement & regExp );
+	void setRegExp ( FormalRegExpStructure regExp );
 
 	virtual const std::set < alphabet::Symbol > & getAlphabet ( ) const {
 		return accessComponent < GeneralAlphabet > ( ).get ( );
@@ -105,7 +102,7 @@ template < >
 class ComponentConstraint< regexp::FormalRegExp, alphabet::Symbol, regexp::GeneralAlphabet > {
 public:
 	static bool used ( const regexp::FormalRegExp & regexp, const alphabet::Symbol & symbol ) {
-		return regexp.getRegExp ( ).testSymbol ( symbol );
+		return regexp.getRegExp ( ).getStructure ( ).testSymbol ( symbol );
 	}
 
 	static bool available ( const regexp::FormalRegExp &, const alphabet::Symbol & ) {
diff --git a/alib2data/src/regexp/formal/FormalRegExpElement.cpp b/alib2data/src/regexp/formal/FormalRegExpElement.cpp
index 5ba40c0c06b48ed00f172d13f085fe6d080f0c32..8047bae0a48540e7edc5093a094d31466850f531 100644
--- a/alib2data/src/regexp/formal/FormalRegExpElement.cpp
+++ b/alib2data/src/regexp/formal/FormalRegExpElement.cpp
@@ -6,13 +6,6 @@
  */
 
 #include "FormalRegExpElement.h"
-#include <typeinfo>
-
-#include "FormalRegExpElements.h"
-
-#include "../common/RegExpFromXMLParser.h"
-#include "../common/RegExpToXMLComposer.h"
-#include <exception/CommonException.h>
 
 namespace regexp {
 
@@ -24,19 +17,3 @@ std::set < alphabet::Symbol > FormalRegExpElement::computeMinimalAlphabet ( ) co
 }
 
 } /* namespace regexp */
-
-namespace alib {
-
-std::rvalue_ref < regexp::FormalRegExpElement > xmlApi < regexp::FormalRegExpElement >::parse ( std::deque < sax::Token >::iterator & input ) {
-	return regexp::RegExpFromXMLParser::parseFormalRegExpElement ( input );
-}
-
-bool xmlApi < regexp::FormalRegExpElement >::first ( const std::deque < sax::Token >::const_iterator & ) {
-	throw exception::CommonException ( "Unimplemented" );
-}
-
-void xmlApi < regexp::FormalRegExpElement >::compose ( std::deque < sax::Token > & output, const regexp::FormalRegExpElement & data ) {
-	data.Accept ( ( void * ) & output, regexp::RegExpToXMLComposer::Formal::FORMAL );
-}
-
-} /* namespace alib */
diff --git a/alib2data/src/regexp/formal/FormalRegExpElement.h b/alib2data/src/regexp/formal/FormalRegExpElement.h
index bff3f0c3cbf65783a9104b621e3b53d4f5552280..b694ce8ba42b62cc0ce7772bfc493e21dd2cabca 100644
--- a/alib2data/src/regexp/formal/FormalRegExpElement.h
+++ b/alib2data/src/regexp/formal/FormalRegExpElement.h
@@ -82,15 +82,4 @@ public:
 
 } /* namespace regexp */
 
-namespace alib {
-
-template < >
-struct xmlApi < regexp::FormalRegExpElement > {
-	static std::rvalue_ref < regexp::FormalRegExpElement > parse ( std::deque < sax::Token >::iterator & input );
-	static bool first ( const std::deque < sax::Token >::const_iterator & input );
-	static void compose ( std::deque < sax::Token > & output, const regexp::FormalRegExpElement & data );
-};
-
-} /* namespace alib */
-
 #endif /* FORMAL_REG_EXP_ELEMENT_H_ */
diff --git a/alib2data/src/regexp/formal/FormalRegExpElements.h b/alib2data/src/regexp/formal/FormalRegExpElements.h
index 7355a911e5b8b6b60b5ef1784b380d837462083d..c1b145fe36ad91f564a6cb788ffeb1f577465497 100644
--- a/alib2data/src/regexp/formal/FormalRegExpElements.h
+++ b/alib2data/src/regexp/formal/FormalRegExpElements.h
@@ -8,10 +8,10 @@
 #ifndef FORMAL_REG_EXP_ELEMENTS_H_
 #define FORMAL_REG_EXP_ELEMENTS_H_
 
+#include "FormalRegExpElement.h"
 #include "FormalRegExpAlternation.h"
 #include "FormalRegExpConcatenation.h"
 #include "FormalRegExpIteration.h"
-#include "FormalRegExpElement.h"
 #include "FormalRegExpEpsilon.h"
 #include "FormalRegExpEmpty.h"
 #include "FormalRegExpSymbol.h"
diff --git a/alib2data/src/regexp/formal/FormalRegExpStructure.cpp b/alib2data/src/regexp/formal/FormalRegExpStructure.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ba50e5ef31465593593fd7b3a6bda4a1bf584f7f
--- /dev/null
+++ b/alib2data/src/regexp/formal/FormalRegExpStructure.cpp
@@ -0,0 +1,64 @@
+/*
+ * FormalRegExpStructure.cpp
+ *
+ *  Created on: Oct 20, 2016
+ *      Author: Jan Travnicek
+ */
+
+#include "FormalRegExpStructure.h"
+#include "FormalRegExpEmpty.h"
+
+#include "../unbounded/UnboundedRegExpStructure.h"
+
+#include "../common/RegExpFromXMLParser.h"
+#include "../common/RegExpToXMLComposer.h"
+#include <exception/CommonException.h>
+
+namespace regexp {
+
+FormalRegExpStructure::FormalRegExpStructure ( FormalRegExpElement && structure ) : structure ( NULL ) {
+	setStructure ( std::move ( structure ) );
+}
+
+FormalRegExpStructure::FormalRegExpStructure ( const FormalRegExpElement & structure ) : FormalRegExpStructure ( std::move_copy ( structure ) ) {
+}
+
+FormalRegExpStructure::FormalRegExpStructure ( ) : FormalRegExpStructure ( FormalRegExpEmpty ( ) ) {
+}
+
+FormalRegExpStructure::FormalRegExpStructure ( const UnboundedRegExpStructure & other ) : FormalRegExpStructure ( * other.getStructure ( ).asFormal ( ) ) {
+}
+
+const FormalRegExpElement & FormalRegExpStructure::getStructure ( ) const {
+	return * structure;
+}
+
+FormalRegExpElement & FormalRegExpStructure::getStructure ( ) {
+	return * structure;
+}
+
+void FormalRegExpStructure::setStructure ( const FormalRegExpElement & structure ) {
+	setStructure ( std::move_copy ( structure ) );
+}
+
+void FormalRegExpStructure::setStructure ( FormalRegExpElement && param ) {
+	this->structure = std::smart_ptr < FormalRegExpElement > ( std::move ( param ).plunder ( ) );
+}
+
+} /* namespace regexp */
+
+namespace alib {
+
+regexp::FormalRegExpStructure xmlApi < regexp::FormalRegExpStructure >::parse ( std::deque < sax::Token >::iterator & input ) {
+	return regexp::FormalRegExpStructure ( regexp::RegExpFromXMLParser::parseFormalRegExpElement ( input ) );
+}
+
+bool xmlApi < regexp::FormalRegExpStructure >::first ( const std::deque < sax::Token >::const_iterator & ) {
+	throw exception::CommonException ( "Unimplemented" );
+}
+
+void xmlApi < regexp::FormalRegExpStructure >::compose ( std::deque < sax::Token > & output, const regexp::FormalRegExpStructure & data ) {
+	data.getStructure ( ).Accept ( ( void * ) & output, regexp::RegExpToXMLComposer::Formal::FORMAL );
+}
+
+} /* namespace alib */
diff --git a/alib2data/src/regexp/formal/FormalRegExpStructure.h b/alib2data/src/regexp/formal/FormalRegExpStructure.h
new file mode 100644
index 0000000000000000000000000000000000000000..533b7f7bd1b74d5ad38c10b0e68a936ed30e7387
--- /dev/null
+++ b/alib2data/src/regexp/formal/FormalRegExpStructure.h
@@ -0,0 +1,88 @@
+/*
+ * FormalRegExpStructure.h
+ *
+ *  Created on: Oct 20, 2016
+ *      Author: Jan Travnicek
+ */
+
+#ifndef FORMAL_REG_EXP_STRUCTURE_H_
+#define FORMAL_REG_EXP_STRUCTURE_H_
+
+#include <memory>
+#include "FormalRegExpElement.h"
+
+namespace regexp {
+
+class UnboundedRegExpStructure;
+
+/**
+ * Represents formal regular expression structure as parsed from the XML. Regular expression is stored
+ * as a tree of FormalRegExpElement.
+ */
+class FormalRegExpStructure {
+protected:
+	std::smart_ptr < FormalRegExpElement > structure;
+
+public:
+	explicit FormalRegExpStructure ( );
+
+	explicit FormalRegExpStructure ( FormalRegExpElement && structure );
+	explicit FormalRegExpStructure ( const FormalRegExpElement & structure );
+	explicit FormalRegExpStructure ( const UnboundedRegExpStructure & other );
+
+	/**
+	 * @return Root node of the formal regular expression tree
+	 */
+	const FormalRegExpElement & getStructure ( ) const;
+
+	/**
+	 * @return Root node of the formal regular expression tree
+	 */
+	FormalRegExpElement & getStructure ( );
+
+	/**
+	 * Sets the root node of the formal regular expression tree
+	 * @param structure root node to set
+	 */
+	void setStructure ( FormalRegExpElement && structure );
+	void setStructure ( const FormalRegExpElement & structure );
+
+	friend std::ostream & operator << ( std::ostream & out, const FormalRegExpStructure & structure ) {
+		out << structure.getStructure ( );
+		return out;
+	}
+
+	friend bool operator < ( const FormalRegExpStructure & first, const FormalRegExpStructure & second ) {
+		return first.getStructure().compare(second.getStructure()) < 0;
+	}
+
+	friend bool operator == ( const FormalRegExpStructure & first, const FormalRegExpStructure & second ) {
+		return first.getStructure().compare(second.getStructure()) == 0;
+	}
+};
+
+} /* namespace regexp */
+
+namespace alib {
+
+template < >
+struct xmlApi < regexp::FormalRegExpStructure > {
+	static regexp::FormalRegExpStructure parse ( std::deque < sax::Token >::iterator & input );
+	static bool first ( const std::deque < sax::Token >::const_iterator & input );
+	static void compose ( std::deque < sax::Token > & output, const regexp::FormalRegExpStructure & data );
+};
+
+} /* namespace alib */
+
+namespace std {
+
+template < >
+struct compare < regexp::FormalRegExpStructure > {
+	int operator()(const regexp::FormalRegExpStructure& first, const regexp::FormalRegExpStructure& second) const {
+		return first.getStructure().compare(second.getStructure());
+	}
+};
+
+} /* namespace std */
+
+#endif /* FORMAL_REG_EXP_STRUCTURE_H_ */
diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExp.cpp b/alib2data/src/regexp/unbounded/UnboundedRegExp.cpp
index dee35244b16c66b9ee123ad50558acfbb6e6e1fa..8444ae4e0139be964aa096b3cdaeecbed4d7bdd2 100644
--- a/alib2data/src/regexp/unbounded/UnboundedRegExp.cpp
+++ b/alib2data/src/regexp/unbounded/UnboundedRegExp.cpp
@@ -25,23 +25,18 @@
 
 namespace regexp {
 
-UnboundedRegExp::UnboundedRegExp ( std::set < alphabet::Symbol > alphabet, UnboundedRegExpElement && regExp ) : std::Components < UnboundedRegExp, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::move ( alphabet ) ), std::tuple < > ( ) ), regExp ( NULL ) {
-	setRegExp ( std::move ( regExp ) );
-}
-
-UnboundedRegExp::UnboundedRegExp ( std::set < alphabet::Symbol > alphabet, const UnboundedRegExpElement & regExp ) : UnboundedRegExp ( std::move ( alphabet ), std::move_copy ( regExp ) ) {
-}
-
-UnboundedRegExp::UnboundedRegExp ( ) : UnboundedRegExp ( std::set < alphabet::Symbol > ( ), UnboundedRegExpEmpty ( ) ) {
+UnboundedRegExp::UnboundedRegExp ( std::set < alphabet::Symbol > alphabet, UnboundedRegExpStructure regExp ) : std::Components < UnboundedRegExp, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::move ( alphabet ) ), std::tuple < > ( ) ), regExp ( std::move ( regExp ) ) {
+	if ( !this->regExp.getStructure ( ).checkAlphabet ( getAlphabet ( ) ) )
+		throw exception::CommonException ( "Input symbols not in the alphabet." );
 }
 
-UnboundedRegExp::UnboundedRegExp ( UnboundedRegExpElement && regExp ) : UnboundedRegExp ( regExp.computeMinimalAlphabet ( ), std::move ( regExp ) ) {
+UnboundedRegExp::UnboundedRegExp ( ) : UnboundedRegExp ( std::set < alphabet::Symbol > ( ), UnboundedRegExpStructure ( ) ) {
 }
 
-UnboundedRegExp::UnboundedRegExp ( const UnboundedRegExpElement & regExp ) : UnboundedRegExp ( regExp.computeMinimalAlphabet ( ), std::move_copy ( regExp ) ) {
+UnboundedRegExp::UnboundedRegExp ( UnboundedRegExpStructure regExp ) : UnboundedRegExp ( regExp.getStructure ( ).computeMinimalAlphabet ( ), regExp ) {
 }
 
-UnboundedRegExp::UnboundedRegExp ( const FormalRegExp & other ) : UnboundedRegExp ( other.getAlphabet ( ), * other.getRegExp ( ).asUnbounded ( ) ) {
+UnboundedRegExp::UnboundedRegExp ( const FormalRegExp & other ) : UnboundedRegExp ( other.getAlphabet ( ), UnboundedRegExpStructure ( other.getRegExp ( ) ) ) {
 }
 
 RegExpBase * UnboundedRegExp::clone ( ) const {
@@ -52,32 +47,28 @@ RegExpBase * UnboundedRegExp::plunder ( ) && {
 	return new UnboundedRegExp ( std::move ( * this ) );
 }
 
-const UnboundedRegExpElement & UnboundedRegExp::getRegExp ( ) const {
-	return * regExp;
+const UnboundedRegExpStructure & UnboundedRegExp::getRegExp ( ) const {
+	return regExp;
 }
 
-UnboundedRegExpElement & UnboundedRegExp::getRegExp ( ) {
-	return * regExp;
+UnboundedRegExpStructure & UnboundedRegExp::getRegExp ( ) {
+	return regExp;
 }
 
-void UnboundedRegExp::setRegExp ( const UnboundedRegExpElement & regExp ) {
-	setRegExp ( std::move_copy ( regExp ) );
-}
-
-void UnboundedRegExp::setRegExp ( UnboundedRegExpElement && param ) {
-	this->regExp = std::smart_ptr < UnboundedRegExpElement > ( std::move ( param ).plunder ( ) );
-
-	if ( !regExp->checkAlphabet ( getAlphabet ( ) ) )
+void UnboundedRegExp::setRegExp ( UnboundedRegExpStructure param ) {
+	if ( !param.getStructure ( ).checkAlphabet ( getAlphabet ( ) ) )
 		throw exception::CommonException ( "Input symbols not in the alphabet." );
+
+	this->regExp = std::move ( param );
 }
 
 void UnboundedRegExp::operator >>( std::ostream & out ) const {
-	out << "(UnboundedRegExp " << * ( this->regExp ) << ")";
+	out << "(UnboundedRegExp " << this->regExp.getStructure ( ) << ")";
 }
 
 int UnboundedRegExp::compare ( const UnboundedRegExp & other ) const {
-	auto first = std::tie ( regExp, getAlphabet ( ) );
-	auto second = std::tie ( other.regExp, other.getAlphabet ( ) );
+	auto first = std::tie ( regExp.getStructure ( ), getAlphabet ( ) );
+	auto second = std::tie ( other.regExp.getStructure ( ), other.getAlphabet ( ) );
 
 	std::compare < decltype ( first ) > comp;
 
@@ -95,8 +86,8 @@ UnboundedRegExp UnboundedRegExp::parse ( std::deque < sax::Token >::iterator & i
 
 	std::set < alphabet::Symbol > alphabet = RegExpFromXMLParser::parseAlphabet ( input );
 
-	std::rvalue_ref < UnboundedRegExpElement > element ( alib::xmlApi < regexp::UnboundedRegExpElement >::parse ( input ) );
-	UnboundedRegExp regexp ( std::move ( alphabet ), std::move ( element ) );
+	UnboundedRegExpStructure structure ( alib::xmlApi < regexp::UnboundedRegExpStructure >::parse ( input ) );
+	UnboundedRegExp regexp ( std::move ( alphabet ), std::move ( structure ) );
 
 	sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, UnboundedRegExp::getXmlTagName() );
 
@@ -106,7 +97,7 @@ UnboundedRegExp UnboundedRegExp::parse ( std::deque < sax::Token >::iterator & i
 void UnboundedRegExp::compose ( std::deque < sax::Token > & out ) const {
 	out.emplace_back ( UnboundedRegExp::getXmlTagName(), sax::Token::TokenType::START_ELEMENT );
 	RegExpToXMLComposer::composeAlphabet ( out, this->getAlphabet ( ) );
-	alib::xmlApi < UnboundedRegExpElement >::compose ( out, this->getRegExp ( ) );
+	alib::xmlApi < UnboundedRegExpStructure >::compose ( out, this->getRegExp ( ) );
 	out.emplace_back ( UnboundedRegExp::getXmlTagName(), sax::Token::TokenType::END_ELEMENT );
 }
 
diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExp.h b/alib2data/src/regexp/unbounded/UnboundedRegExp.h
index ec015f73e4a4b4f0acff91f9bc5715ffbab8f9e2..eab1d42ded6912319046ef721a146187ff0785b0 100644
--- a/alib2data/src/regexp/unbounded/UnboundedRegExp.h
+++ b/alib2data/src/regexp/unbounded/UnboundedRegExp.h
@@ -13,7 +13,7 @@
 #include <core/components.hpp>
 
 #include "../RegExpBase.h"
-#include "UnboundedRegExpElement.h"
+#include "UnboundedRegExpStructure.h"
 #include "../../alphabet/Symbol.h"
 
 namespace regexp {
@@ -27,7 +27,7 @@ class GeneralAlphabet;
  */
 class UnboundedRegExp : public RegExpBase, public std::Components < UnboundedRegExp, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > {
 protected:
-	std::smart_ptr < UnboundedRegExpElement > regExp;
+	UnboundedRegExpStructure regExp;
 
 public:
 	/**
@@ -42,28 +42,25 @@ public:
 
 	explicit UnboundedRegExp ( );
 
-	explicit UnboundedRegExp ( std::set < alphabet::Symbol > alphabet, UnboundedRegExpElement && regExp );
-	explicit UnboundedRegExp ( std::set < alphabet::Symbol > alphabet, const UnboundedRegExpElement & regExp );
-	explicit UnboundedRegExp ( UnboundedRegExpElement && regExp );
-	explicit UnboundedRegExp ( const UnboundedRegExpElement & regExp );
+	explicit UnboundedRegExp ( std::set < alphabet::Symbol > alphabet, UnboundedRegExpStructure regExp );
+	explicit UnboundedRegExp ( UnboundedRegExpStructure regExp );
 	explicit UnboundedRegExp ( const FormalRegExp & other );
 
 	/**
 	 * @return Root node of the regular expression tree
 	 */
-	const UnboundedRegExpElement & getRegExp ( ) const;
+	const UnboundedRegExpStructure & getRegExp ( ) const;
 
 	/**
 	 * @return Root node of the regular expression tree
 	 */
-	UnboundedRegExpElement & getRegExp ( );
+	UnboundedRegExpStructure & getRegExp ( );
 
 	/**
 	 * Sets the root node of the regular expression tree
 	 * @param regExp root node to set
 	 */
-	void setRegExp ( UnboundedRegExpElement && regExp );
-	void setRegExp ( const UnboundedRegExpElement & regExp );
+	void setRegExp ( UnboundedRegExpStructure regExp );
 
 	virtual const std::set < alphabet::Symbol > & getAlphabet ( ) const {
 		return accessComponent < GeneralAlphabet > ( ).get ( );
@@ -105,7 +102,7 @@ template < >
 class ComponentConstraint< regexp::UnboundedRegExp, alphabet::Symbol, regexp::GeneralAlphabet > {
 public:
 	static bool used ( const regexp::UnboundedRegExp & regexp, const alphabet::Symbol & symbol ) {
-		return regexp.getRegExp ( ).testSymbol ( symbol );
+		return regexp.getRegExp ( ).getStructure ( ).testSymbol ( symbol );
 	}
 
 	static bool available ( const regexp::UnboundedRegExp &, const alphabet::Symbol & ) {
diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpElement.cpp b/alib2data/src/regexp/unbounded/UnboundedRegExpElement.cpp
index 6b0a3f8924279d59773af708543c595b0385a103..ea0a834d6b7426e8924b509d760787b96d50a10f 100644
--- a/alib2data/src/regexp/unbounded/UnboundedRegExpElement.cpp
+++ b/alib2data/src/regexp/unbounded/UnboundedRegExpElement.cpp
@@ -6,13 +6,6 @@
  */
 
 #include "UnboundedRegExpElement.h"
-#include <typeinfo>
-
-#include "UnboundedRegExpElements.h"
-
-#include "../common/RegExpFromXMLParser.h"
-#include "../common/RegExpToXMLComposer.h"
-#include <exception/CommonException.h>
 
 namespace regexp {
 
@@ -24,19 +17,3 @@ std::set < alphabet::Symbol > UnboundedRegExpElement::computeMinimalAlphabet ( )
 }
 
 } /* namespace regexp */
-
-namespace alib {
-
-std::rvalue_ref < regexp::UnboundedRegExpElement > xmlApi < regexp::UnboundedRegExpElement >::parse ( std::deque < sax::Token >::iterator & input ) {
-	return regexp::RegExpFromXMLParser::parseUnboundedRegExpElement ( input );
-}
-
-bool xmlApi < regexp::UnboundedRegExpElement >::first ( const std::deque < sax::Token >::const_iterator & ) {
-	throw exception::CommonException ( "Unimplemented" );
-}
-
-void xmlApi < regexp::UnboundedRegExpElement >::compose ( std::deque < sax::Token > & output, const regexp::UnboundedRegExpElement & data ) {
-	data.Accept ( ( void * ) & output, regexp::RegExpToXMLComposer::Unbounded::UNBOUNDED );
-}
-
-} /* namespace alib */
diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpElement.h b/alib2data/src/regexp/unbounded/UnboundedRegExpElement.h
index 8ceb0bbe46b5a1a213806a34ead68803c69376bb..dbccf48789a4149910e53d137cb1f8a008b1ec08 100644
--- a/alib2data/src/regexp/unbounded/UnboundedRegExpElement.h
+++ b/alib2data/src/regexp/unbounded/UnboundedRegExpElement.h
@@ -79,15 +79,4 @@ public:
 
 } /* namespace regexp */
 
-namespace alib {
-
-template < >
-struct xmlApi < regexp::UnboundedRegExpElement > {
-	static std::rvalue_ref < regexp::UnboundedRegExpElement > parse ( std::deque < sax::Token >::iterator & input );
-	static bool first ( const std::deque < sax::Token >::const_iterator & input );
-	static void compose ( std::deque < sax::Token > & output, const regexp::UnboundedRegExpElement & data );
-};
-
-} /* namespace alib */
-
 #endif /* UNBOUNDED_REG_EXP_ELEMENT_H_ */
diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpElements.h b/alib2data/src/regexp/unbounded/UnboundedRegExpElements.h
index 10e3ebb90f8a5ee46024cd69d7a2665d0824dff6..179513352c7fa191401b669365a471854764e128 100644
--- a/alib2data/src/regexp/unbounded/UnboundedRegExpElements.h
+++ b/alib2data/src/regexp/unbounded/UnboundedRegExpElements.h
@@ -8,10 +8,10 @@
 #ifndef UNBOUNDED_REG_EXP_ELEMENTS_H_
 #define UNBOUNDED_REG_EXP_ELEMENTS_H_
 
+#include "UnboundedRegExpElement.h"
 #include "UnboundedRegExpAlternation.h"
 #include "UnboundedRegExpConcatenation.h"
 #include "UnboundedRegExpIteration.h"
-#include "UnboundedRegExpElement.h"
 #include "UnboundedRegExpEpsilon.h"
 #include "UnboundedRegExpEmpty.h"
 #include "UnboundedRegExpSymbol.h"
diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpStructure.cpp b/alib2data/src/regexp/unbounded/UnboundedRegExpStructure.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..dd47bb4a0b0f6f1f12a468df748d4cb91931ad06
--- /dev/null
+++ b/alib2data/src/regexp/unbounded/UnboundedRegExpStructure.cpp
@@ -0,0 +1,64 @@
+/*
+ * UnboundedRegExpStructure.cpp
+ *
+ *  Created on: Oct 20, 2016
+ *      Author: Jan Travnicek
+ */
+
+#include "UnboundedRegExpStructure.h"
+#include "UnboundedRegExpEmpty.h"
+
+#include "../formal/FormalRegExpStructure.h"
+
+#include "../common/RegExpFromXMLParser.h"
+#include "../common/RegExpToXMLComposer.h"
+#include <exception/CommonException.h>
+
+namespace regexp {
+
+UnboundedRegExpStructure::UnboundedRegExpStructure ( UnboundedRegExpElement && structure ) : structure ( NULL ) {
+	setStructure ( std::move ( structure ) );
+}
+
+UnboundedRegExpStructure::UnboundedRegExpStructure ( const UnboundedRegExpElement & structure ) : UnboundedRegExpStructure ( std::move_copy ( structure ) ) {
+}
+
+UnboundedRegExpStructure::UnboundedRegExpStructure ( ) : UnboundedRegExpStructure ( UnboundedRegExpEmpty ( ) ) {
+}
+
+UnboundedRegExpStructure::UnboundedRegExpStructure ( const FormalRegExpStructure & other ) : UnboundedRegExpStructure ( * other.getStructure ( ).asUnbounded ( ) ) {
+}
+
+const UnboundedRegExpElement & UnboundedRegExpStructure::getStructure ( ) const {
+	return * structure;
+}
+
+UnboundedRegExpElement & UnboundedRegExpStructure::getStructure ( ) {
+	return * structure;
+}
+
+void UnboundedRegExpStructure::setStructure ( const UnboundedRegExpElement & structure ) {
+	setStructure ( std::move_copy ( structure ) );
+}
+
+void UnboundedRegExpStructure::setStructure ( UnboundedRegExpElement && param ) {
+	this->structure = std::smart_ptr < UnboundedRegExpElement > ( std::move ( param ).plunder ( ) );
+}
+
+} /* namespace regexp */
+
+namespace alib {
+
+regexp::UnboundedRegExpStructure xmlApi < regexp::UnboundedRegExpStructure >::parse ( std::deque < sax::Token >::iterator & input ) {
+	return regexp::UnboundedRegExpStructure ( regexp::RegExpFromXMLParser::parseUnboundedRegExpElement ( input ) );
+}
+
+bool xmlApi < regexp::UnboundedRegExpStructure >::first ( const std::deque < sax::Token >::const_iterator & ) {
+	throw exception::CommonException ( "Unimplemented" );
+}
+
+void xmlApi < regexp::UnboundedRegExpStructure >::compose ( std::deque < sax::Token > & output, const regexp::UnboundedRegExpStructure & data ) {
+	data.getStructure ( ).Accept ( ( void * ) & output, regexp::RegExpToXMLComposer::Unbounded::UNBOUNDED );
+}
+
+} /* namespace alib */
diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpStructure.h b/alib2data/src/regexp/unbounded/UnboundedRegExpStructure.h
new file mode 100644
index 0000000000000000000000000000000000000000..33b9b6542896ea5ab7267ad07a8bd44bf1427ff8
--- /dev/null
+++ b/alib2data/src/regexp/unbounded/UnboundedRegExpStructure.h
@@ -0,0 +1,89 @@
+/*
+ * UnboundedRegExpStructure.h
+ *
+ *  Created on: Oct 20, 2016
+ *      Author: Jan Travnicek
+ */
+
+#ifndef UNBOUNDED_REG_EXP_STRUCTURE_H_
+#define UNBOUNDED_REG_EXP_STRUCTURE_H_
+
+#include <memory>
+#include <compare>
+#include "UnboundedRegExpElement.h"
+
+namespace regexp {
+
+class FormalRegExpStructure;
+
+/**
+ * Represents unbounded regular expression structure as parsed from the XML. Regular expression is stored
+ * as a tree of UnboundedRegExpElement.
+ */
+class UnboundedRegExpStructure {
+protected:
+	std::smart_ptr < UnboundedRegExpElement > structure;
+
+public:
+	explicit UnboundedRegExpStructure ( );
+
+	explicit UnboundedRegExpStructure ( UnboundedRegExpElement && structure );
+	explicit UnboundedRegExpStructure ( const UnboundedRegExpElement & structure );
+	explicit UnboundedRegExpStructure ( const FormalRegExpStructure & other );
+
+	/**
+	 * @return Root node of the unbounded regular expression tree
+	 */
+	const UnboundedRegExpElement & getStructure ( ) const;
+
+	/**
+	 * @return Root node of the unbounded regular expression tree
+	 */
+	UnboundedRegExpElement & getStructure ( );
+
+	/**
+	 * Sets the root node of the unbounded regular expression tree
+	 * @param structure root node to set
+	 */
+	void setStructure ( UnboundedRegExpElement && structure );
+	void setStructure ( const UnboundedRegExpElement & structure );
+
+	friend std::ostream & operator << ( std::ostream & out, const UnboundedRegExpStructure & structure ) {
+		out << structure.getStructure ( );
+		return out;
+	}
+
+	friend bool operator < ( const UnboundedRegExpStructure & first, const UnboundedRegExpStructure & second ) {
+		return first.getStructure().compare(second.getStructure()) < 0;
+	}
+
+	friend bool operator == ( const UnboundedRegExpStructure & first, const UnboundedRegExpStructure & second ) {
+		return first.getStructure().compare(second.getStructure()) == 0;
+	}
+};
+
+} /* namespace regexp */
+
+namespace alib {
+
+template < >
+struct xmlApi < regexp::UnboundedRegExpStructure > {
+	static regexp::UnboundedRegExpStructure parse ( std::deque < sax::Token >::iterator & input );
+	static bool first ( const std::deque < sax::Token >::const_iterator & input );
+	static void compose ( std::deque < sax::Token > & output, const regexp::UnboundedRegExpStructure & data );
+};
+
+} /* namespace alib */
+
+namespace std {
+
+template < >
+struct compare < regexp::UnboundedRegExpStructure > {
+	int operator()(const regexp::UnboundedRegExpStructure& first, const regexp::UnboundedRegExpStructure& second) const {
+		return first.getStructure().compare(second.getStructure());
+	}
+};
+
+} /* namespace std */
+
+#endif /* UNBOUNDED_REG_EXP_STRUCTURE_H_ */
diff --git a/alib2data/test-src/automaton/AutomatonTest.cpp b/alib2data/test-src/automaton/AutomatonTest.cpp
index 79d6abb5967e35ed20cf1ab0b1c3615764304e24..566a7f9fb7b4e7ae5bae10cf2f51ea11845f0eb7 100644
--- a/alib2data/test-src/automaton/AutomatonTest.cpp
+++ b/alib2data/test-src/automaton/AutomatonTest.cpp
@@ -173,10 +173,10 @@ void AutomatonTest::testExtendedNFAAlphabet() {
 	badConcat.appendElement(regexp::UnboundedRegExpSymbol(alphabet::symbolFrom('b')));
 	badConcat.appendElement(regexp::UnboundedRegExpSymbol(alphabet::symbolFrom('d')));
 
-	CPPUNIT_ASSERT_THROW(automaton.addTransition(s0, regexp::RegExp{regexp::UnboundedRegExp(badConcat)}, s1), automaton::AutomatonException);
-	CPPUNIT_ASSERT_NO_THROW(automaton.addTransition(s0, regexp::RegExp{regexp::UnboundedRegExp(goodConcat1)}, s1));
-	CPPUNIT_ASSERT_NO_THROW(automaton.addTransition(s0, regexp::RegExp{regexp::UnboundedRegExp(goodConcat2)}, s1));
-	CPPUNIT_ASSERT_NO_THROW(automaton.addTransition(s0, regexp::RegExp{regexp::UnboundedRegExp(regexp::UnboundedRegExpEpsilon())}, s1));
+	CPPUNIT_ASSERT_THROW(automaton.addTransition(s0, regexp::RegExp{regexp::UnboundedRegExp(regexp::UnboundedRegExpStructure(badConcat))}, s1), automaton::AutomatonException);
+	CPPUNIT_ASSERT_NO_THROW(automaton.addTransition(s0, regexp::RegExp{regexp::UnboundedRegExp(regexp::UnboundedRegExpStructure(goodConcat1))}, s1));
+	CPPUNIT_ASSERT_NO_THROW(automaton.addTransition(s0, regexp::RegExp{regexp::UnboundedRegExp(regexp::UnboundedRegExpStructure(goodConcat2))}, s1));
+	CPPUNIT_ASSERT_NO_THROW(automaton.addTransition(s0, regexp::RegExp{regexp::UnboundedRegExp(regexp::UnboundedRegExpStructure(regexp::UnboundedRegExpEpsilon()))}, s1));
 }
 
 void AutomatonTest::testNPDATransitions() {
diff --git a/alib2data/test-src/regexp/RegExpTest.cpp b/alib2data/test-src/regexp/RegExpTest.cpp
index 0a8ec51bb1cadaaab4a13b7f88a998da975ac06c..e592cd62e1903b343da992b962a0d573b7bb85f9 100644
--- a/alib2data/test-src/regexp/RegExpTest.cpp
+++ b/alib2data/test-src/regexp/RegExpTest.cpp
@@ -40,7 +40,7 @@ void RegExpTest::testCopyConstruct() {
 		alt.appendElement(con);
 		alt.appendElement(ite);
 
-		regexp::UnboundedRegExp regexp({alphabet::symbolFrom("1"), alphabet::symbolFrom("2"), alphabet::symbolFrom("3")}, alt);
+		regexp::UnboundedRegExp regexp({alphabet::symbolFrom("1"), alphabet::symbolFrom("2"), alphabet::symbolFrom("3")}, regexp::UnboundedRegExpStructure ( alt ) );
 
 		regexp::UnboundedRegExp regexp2(regexp);
 
@@ -60,7 +60,7 @@ void RegExpTest::testCopyConstruct() {
 
 		regexp::FormalRegExpAlternation alt = regexp::FormalRegExpAlternation(con, ite);
 
-		regexp::FormalRegExp regexp({alphabet::symbolFrom("1"), alphabet::symbolFrom("2"), alphabet::symbolFrom("3")}, alt);
+		regexp::FormalRegExp regexp({alphabet::symbolFrom("1"), alphabet::symbolFrom("2"), alphabet::symbolFrom("3")}, regexp::FormalRegExpStructure ( alt ) );
 
 		regexp::FormalRegExp regexp2(regexp);
 
@@ -80,10 +80,10 @@ void RegExpTest::testCopyConstruct() {
 
 		regexp::FormalRegExpAlternation alt = regexp::FormalRegExpAlternation(con, ite);
 
-		regexp::FormalRegExp regexp({alphabet::symbolFrom("1"), alphabet::symbolFrom("3")}, regexp::FormalRegExpEmpty { });
+		regexp::FormalRegExp regexp({alphabet::symbolFrom("1"), alphabet::symbolFrom("3")}, regexp::FormalRegExpStructure ( regexp::FormalRegExpEmpty { } ) );
 
 		CPPUNIT_ASSERT_THROW(
-			regexp.setRegExp ( alt ),
+			regexp.setRegExp ( regexp::FormalRegExpStructure ( alt ) ),
 			exception::CommonException
 		);
 	}
@@ -104,7 +104,7 @@ void RegExpTest::testXMLParser() {
 	alt.appendElement(con);
 	alt.appendElement(ite);
 
-	regexp::UnboundedRegExp unboundedRegexp({alphabet::symbolFrom("1"), alphabet::symbolFrom("2"), alphabet::symbolFrom("3")}, alt);
+	regexp::UnboundedRegExp unboundedRegexp({alphabet::symbolFrom("1"), alphabet::symbolFrom("2"), alphabet::symbolFrom("3")}, regexp::UnboundedRegExpStructure(alt));
 
 	regexp::RegExp regexp(unboundedRegexp);
 
@@ -139,12 +139,12 @@ void RegExpTest::testOrder() {
 	c1.appendElement(s1);
 	c1.appendElement(s1);
 
-	regexp::UnboundedRegExp alt1(a1);
-	regexp::UnboundedRegExp con1(c1);
-	regexp::UnboundedRegExp ite1(i1);
-	regexp::UnboundedRegExp emp1(e1);
-	regexp::UnboundedRegExp eps1(e2);
-	regexp::UnboundedRegExp sym1(s1);
+	regexp::UnboundedRegExp alt1{regexp::UnboundedRegExpStructure(a1)};
+	regexp::UnboundedRegExp con1{regexp::UnboundedRegExpStructure(c1)};
+	regexp::UnboundedRegExp ite1{regexp::UnboundedRegExpStructure(i1)};
+	regexp::UnboundedRegExp emp1{regexp::UnboundedRegExpStructure(e1)};
+	regexp::UnboundedRegExp eps1{regexp::UnboundedRegExpStructure(e2)};
+	regexp::UnboundedRegExp sym1{regexp::UnboundedRegExpStructure(s1)};
 
 	CPPUNIT_EXCLUSIVE_OR(alt1 < con1, con1 < alt1);
 	CPPUNIT_EXCLUSIVE_OR(alt1 < ite1, ite1 < alt1);
@@ -395,36 +395,36 @@ void RegExpTest::testOrder2() {
 	c9.appendElement(s3);
 	c9.appendElement(s3);
 
-	regexp::UnboundedRegExp alt1(a1);
-	regexp::UnboundedRegExp alt2(a2);
-	regexp::UnboundedRegExp alt3(a3);
-	regexp::UnboundedRegExp alt4(a4);
-	regexp::UnboundedRegExp alt5(a5);
-	regexp::UnboundedRegExp alt6(a6);
-	regexp::UnboundedRegExp alt7(a7);
-	regexp::UnboundedRegExp alt8(a8);
-	regexp::UnboundedRegExp alt9(a9);
-
-	regexp::UnboundedRegExp con1(c1);
-	regexp::UnboundedRegExp con2(c2);
-	regexp::UnboundedRegExp con3(c3);
-	regexp::UnboundedRegExp con4(c4);
-	regexp::UnboundedRegExp con5(c5);
-	regexp::UnboundedRegExp con6(c6);
-	regexp::UnboundedRegExp con7(c7);
-	regexp::UnboundedRegExp con8(c8);
-	regexp::UnboundedRegExp con9(c9);
-
-	regexp::UnboundedRegExp ite1(i1);
-	regexp::UnboundedRegExp ite2(i2);
-	regexp::UnboundedRegExp ite3(i3);
-
-	regexp::UnboundedRegExp emp1(e1);
-	regexp::UnboundedRegExp eps1(e2);
-
-	regexp::UnboundedRegExp sym1(s1);
-	regexp::UnboundedRegExp sym2(s2);
-	regexp::UnboundedRegExp sym3(s3);
+	regexp::UnboundedRegExp alt1{regexp::UnboundedRegExpStructure(a1)};
+	regexp::UnboundedRegExp alt2{regexp::UnboundedRegExpStructure(a2)};
+	regexp::UnboundedRegExp alt3{regexp::UnboundedRegExpStructure(a3)};
+	regexp::UnboundedRegExp alt4{regexp::UnboundedRegExpStructure(a4)};
+	regexp::UnboundedRegExp alt5{regexp::UnboundedRegExpStructure(a5)};
+	regexp::UnboundedRegExp alt6{regexp::UnboundedRegExpStructure(a6)};
+	regexp::UnboundedRegExp alt7{regexp::UnboundedRegExpStructure(a7)};
+	regexp::UnboundedRegExp alt8{regexp::UnboundedRegExpStructure(a8)};
+	regexp::UnboundedRegExp alt9{regexp::UnboundedRegExpStructure(a9)};
+
+	regexp::UnboundedRegExp con1{regexp::UnboundedRegExpStructure(c1)};
+	regexp::UnboundedRegExp con2{regexp::UnboundedRegExpStructure(c2)};
+	regexp::UnboundedRegExp con3{regexp::UnboundedRegExpStructure(c3)};
+	regexp::UnboundedRegExp con4{regexp::UnboundedRegExpStructure(c4)};
+	regexp::UnboundedRegExp con5{regexp::UnboundedRegExpStructure(c5)};
+	regexp::UnboundedRegExp con6{regexp::UnboundedRegExpStructure(c6)};
+	regexp::UnboundedRegExp con7{regexp::UnboundedRegExpStructure(c7)};
+	regexp::UnboundedRegExp con8{regexp::UnboundedRegExpStructure(c8)};
+	regexp::UnboundedRegExp con9{regexp::UnboundedRegExpStructure(c9)};
+
+	regexp::UnboundedRegExp ite1{regexp::UnboundedRegExpStructure(i1)};
+	regexp::UnboundedRegExp ite2{regexp::UnboundedRegExpStructure(i2)};
+	regexp::UnboundedRegExp ite3{regexp::UnboundedRegExpStructure(i3)};
+
+	regexp::UnboundedRegExp emp1{regexp::UnboundedRegExpStructure(e1)};
+	regexp::UnboundedRegExp eps1{regexp::UnboundedRegExpStructure(e2)};
+
+	regexp::UnboundedRegExp sym1{regexp::UnboundedRegExpStructure(s1)};
+	regexp::UnboundedRegExp sym2{regexp::UnboundedRegExpStructure(s2)};
+	regexp::UnboundedRegExp sym3{regexp::UnboundedRegExpStructure(s3)};
 
 
 
diff --git a/alib2str/src/regexp/RegExpFromStringParser.cpp b/alib2str/src/regexp/RegExpFromStringParser.cpp
index 2ce442e4e79b0facd485f151900abc22991ca3bb..576182712b8bb4689e797167e62e6ab4dc33e537 100644
--- a/alib2str/src/regexp/RegExpFromStringParser.cpp
+++ b/alib2str/src/regexp/RegExpFromStringParser.cpp
@@ -23,7 +23,7 @@ RegExp RegExpFromStringParser::parseRegExp(std::istream& input) {
 
 RegExp RegExpFromStringParser::parseRegExp(std::istream& input, const std::set<FEATURES>& features) {
 	std::rvalue_ref < UnboundedRegExpElement > element = alternation(input);
-	UnboundedRegExp regexp(std::move(element));
+	UnboundedRegExp regexp(regexp::UnboundedRegExpStructure(std::move(element)));
 
 	if(features.count(FEATURES::UNBOUNDED)) return RegExp{regexp};
 
diff --git a/alib2str/src/regexp/RegExpToStringComposer.cpp b/alib2str/src/regexp/RegExpToStringComposer.cpp
index 2b8021a0b198cf4663f7d6e7943b787e048d356e..1d126ee7fb13d74bd600b9a265c8ffd528195615 100644
--- a/alib2str/src/regexp/RegExpToStringComposer.cpp
+++ b/alib2str/src/regexp/RegExpToStringComposer.cpp
@@ -19,7 +19,7 @@ void RegExpToStringComposer::compose(std::ostream& output, const UnboundedRegExp
 	Priority tmp = Priority::ALTERNATION;
 	std::tuple<Priority&, std::ostream&> out = std::tie(tmp, output);
 	RegExpToStringComposer composer;
-	regexp.getRegExp().Accept((void*) &out, composer);
+	regexp.getRegExp().getStructure().Accept((void*) &out, composer);
 }
 
 RegExpToStringComposer::RegistratorWrapper<void, UnboundedRegExp> RegExpToStringComposerUnboundedRegExp = RegExpToStringComposer::RegistratorWrapper<void, UnboundedRegExp>(RegExpToStringComposer::compose);
@@ -28,7 +28,7 @@ void RegExpToStringComposer::compose(std::ostream& output, const FormalRegExp& r
 	Priority tmp = Priority::ALTERNATION;
 	std::tuple<Priority&, std::ostream&> out = std::tie(tmp, output);
 	RegExpToStringComposer composer;
-	regexp.getRegExp().Accept((void*) &out, composer);
+	regexp.getRegExp().getStructure().Accept((void*) &out, composer);
 }
 
 RegExpToStringComposer::RegistratorWrapper<void, FormalRegExp> RegExpToStringComposerFormalRegExp = RegExpToStringComposer::RegistratorWrapper<void, FormalRegExp>(RegExpToStringComposer::compose);