diff --git a/aconversions/src/re2fa/Brzozowski.cpp b/aconversions/src/re2fa/Brzozowski.cpp
index 1f941f750f7c526faa58df01ebd0eb28be8320db..6736176ac6e520584cd76c2e85f77f18c316ef1c 100644
--- a/aconversions/src/re2fa/Brzozowski.cpp
+++ b/aconversions/src/re2fa/Brzozowski.cpp
@@ -42,7 +42,7 @@ FSM Brzozowski::convert( void )
             for( const auto & symbol : alphabet )
             {
                 RegExpElement* dSymbol = new RegExpSymbol( symbol.getSymbol( ) );
-                RegExp derived = deriv.derivation( vector<RegExpElement*>( 1, dSymbol ) );
+                RegExp derived = deriv.derivation( list<RegExpElement*>( 1, dSymbol ) );
                 derived = opt.optimize( derived );
 
                 if( ! isInSet( derived, Q ) ) // if this state has already been found, do not add
diff --git a/aconvert.regexp/src/RegExpParser.cpp b/aconvert.regexp/src/RegExpParser.cpp
index 8ba459c5c18f3495c0a7085cd113c55d4c8a4f07..cf070c07a50f0e5645f7efbc6b84c1a737d58efe 100644
--- a/aconvert.regexp/src/RegExpParser.cpp
+++ b/aconvert.regexp/src/RegExpParser.cpp
@@ -19,23 +19,25 @@ regexp::RegExpElement* RegExpParser::AlternationCont(regexp::RegExpElement* left
   RegExpLexer::Token token = m_Lexer.token();
   if(token.type == RegExpLexer::PLUS) {
     m_Lexer.next();
-    regexp::Alternation* res = new regexp::Alternation();
-    res->getElements().push_back(left);
-    this->AlternationContCont(res, this->Concatenation());
+    regexp::Alternation* res = this->AlternationContCont(this->Concatenation());
+    res->getElements().push_front(left);
     return res;
   } else {
     return left;
   }
 }
 
-void RegExpParser::AlternationContCont(regexp::Alternation* res, regexp::RegExpElement* left) {
+regexp::Alternation* RegExpParser::AlternationContCont(regexp::RegExpElement* left) {
   RegExpLexer::Token token = m_Lexer.token();
   if(token.type == RegExpLexer::PLUS) {
     m_Lexer.next();
-    res->getElements().push_back(left);
-    this->AlternationContCont(res, this->Concatenation());
+    regexp::Alternation* res = this->AlternationContCont(this->Concatenation());
+    res->getElements().push_front(left);
+    return res;
   } else {
-    res->getElements().push_back(left);
+    regexp::Alternation* res = new regexp::Alternation();
+    res->getElements().push_front(left);
+    return res;
   }
 }
 
@@ -48,24 +50,25 @@ regexp::RegExpElement* RegExpParser::ConcatenationCont(regexp::RegExpElement* le
   RegExpLexer::Token token = m_Lexer.token();
   if(token.type == RegExpLexer::SYMBOL || token.type == RegExpLexer::LPAR || token.type == RegExpLexer::EPS || token.type == RegExpLexer::EMPTY) {
     
-    regexp::Concatenation* res = new regexp::Concatenation();
-    res->getElements().push_back(left);
-    this->ConcatenationContCont(res, this->Factor());
+    regexp::Concatenation* res = this->ConcatenationContCont(this->Factor());
+    res->getElements().push_front(left);
     return res;
   } else {
     return left;
   }
 }
 
-void RegExpParser::ConcatenationContCont(regexp::Concatenation* res, regexp::RegExpElement* left) {
+regexp::Concatenation* RegExpParser::ConcatenationContCont(regexp::RegExpElement* left) {
   RegExpLexer::Token token = m_Lexer.token();
   if(token.type == RegExpLexer::SYMBOL || token.type == RegExpLexer::LPAR || token.type == RegExpLexer::EPS || token.type == RegExpLexer::EMPTY) {
     
-    res->getElements().push_back(left);
-    this->ConcatenationContCont(res, this->Factor());
+    regexp::Concatenation* res = this->ConcatenationContCont(this->Factor());
+    res->getElements().push_front(left);
+    return res;
   } else {
-    
-    res->getElements().push_back(left);
+    regexp::Concatenation* res = new regexp::Concatenation();
+    res->getElements().push_front(left);
+    return res;
   }
 }
 
diff --git a/aconvert.regexp/src/RegExpParser.h b/aconvert.regexp/src/RegExpParser.h
index 0177ccaaaa24b95d9a00c0972ccd4d25b5a617f9..37e161181ed622b7a7e70e797c04ebab9f15f2b1 100644
--- a/aconvert.regexp/src/RegExpParser.h
+++ b/aconvert.regexp/src/RegExpParser.h
@@ -26,11 +26,11 @@ public:
 private:
   regexp::RegExpElement* Alternation();
   regexp::RegExpElement* AlternationCont(regexp::RegExpElement* left);
-  void AlternationContCont(regexp::Alternation* res, regexp::RegExpElement* left);
+  regexp::Alternation* AlternationContCont(regexp::RegExpElement* left);
   
   regexp::RegExpElement* Concatenation();
   regexp::RegExpElement* ConcatenationCont(regexp::RegExpElement* left);
-  void ConcatenationContCont(regexp::Concatenation* res, regexp::RegExpElement* left);
+  regexp::Concatenation* ConcatenationContCont(regexp::RegExpElement* left);
   
   regexp::RegExpElement* Factor();
   regexp::RegExpElement* Star(regexp::RegExpElement* elem);
diff --git a/aderivation/src/aderivation.cpp b/aderivation/src/aderivation.cpp
index 972a1f702fb301b51facea885ba7552ab28bc1bb..018c8da65445f6ffb7d1225e9806f4eab389df4a 100644
--- a/aderivation/src/aderivation.cpp
+++ b/aderivation/src/aderivation.cpp
@@ -27,7 +27,7 @@ int main(int argc, char** argv)
         SaxInterface::parseMemory(input, tokens);
         RegExp re = RegExpParser::parse(tokens);
 
-        vector<RegExpElement*> dString;
+        list<RegExpElement*> dString;
         for( int i = 1; i < argc ; i++ )
         {
             string symbol( argv[ i ] );
diff --git a/aintegral/src/aintegral.cpp b/aintegral/src/aintegral.cpp
index d460ab967e8e3ce50f1addfe3fa90d6b05fd5987..c5599a0a94ccc2b3516a7f77d0f50360d1dcc061 100644
--- a/aintegral/src/aintegral.cpp
+++ b/aintegral/src/aintegral.cpp
@@ -27,7 +27,7 @@ int main(int argc, char** argv)
         SaxInterface::parseMemory(input, tokens);
         RegExp re = RegExpParser::parse(tokens);
 
-        vector<RegExpElement*> dString;
+        list<RegExpElement*> dString;
         for( int i = 1; i < argc ; i++ )
         {
             string symbol( argv[ i ] );
diff --git a/alib/src/RegExpFactory.h b/alib/src/RegExpFactory.h
index de6d8f64306ce91aa74774f5a0b73fc262baa183..510ddddc1d867800f3824fc8c9cf52ae5a28ef34 100644
--- a/alib/src/RegExpFactory.h
+++ b/alib/src/RegExpFactory.h
@@ -8,8 +8,6 @@
 #ifndef REGEXPFACTORY_H_
 #define REGEXPFACTORY_H_
 
-#include <list>
-
 #include "sax/Token.h"
 #include "regexp/RegExp.h"
 
diff --git a/alib/src/regexp/Alternation.cpp b/alib/src/regexp/Alternation.cpp
index 2bd801d82e6de887b1930000524de75c4f6372e8..1c557224ef201ca8c1e2ab5ee399b75924b13457 100644
--- a/alib/src/regexp/Alternation.cpp
+++ b/alib/src/regexp/Alternation.cpp
@@ -42,11 +42,11 @@ Alternation::~Alternation() {
 	elements.clear();
 }
 
-vector<RegExpElement*>& Alternation::getElements() {
+list<RegExpElement*>& Alternation::getElements() {
 	return elements;
 }
 
-const vector<RegExpElement*>& Alternation::getElements() const {
+const list<RegExpElement*>& Alternation::getElements() const {
 	return elements;
 }
 
diff --git a/alib/src/regexp/Alternation.h b/alib/src/regexp/Alternation.h
index 3ce18a9049fc30331c39f91ab91f558754a1883b..52b8f8c184f0c2255d188bf0c8246e247d36ffb8 100644
--- a/alib/src/regexp/Alternation.h
+++ b/alib/src/regexp/Alternation.h
@@ -8,7 +8,7 @@
 #ifndef ALTERNATION_H_
 #define ALTERNATION_H_
 
-#include <vector>
+#include <list>
 #include "RegExpElement.h"
 
 namespace regexp {
@@ -21,7 +21,7 @@ using namespace std;
  */
 class Alternation: public RegExpElement {
 private:
-	vector<RegExpElement*> elements;
+	list<RegExpElement*> elements;
 public:
 	Alternation();
 	Alternation(const Alternation& other);
@@ -31,12 +31,12 @@ public:
 	/**
 	 * @return list of operands
 	 */
-	vector<RegExpElement*>& getElements();
+	list<RegExpElement*>& getElements();
 
 	/**
 	 * @return list of operands
 	 */
-	const vector<RegExpElement*>& getElements() const;
+	const list<RegExpElement*>& getElements() const;
 
 	/**
 	 * @copydoc RegExpElement::clone() const
diff --git a/alib/src/regexp/Concatenation.cpp b/alib/src/regexp/Concatenation.cpp
index 0387d454fb5e21f7d06d347e48a40f753a6aceeb..c43e767dfd52427ce0667880013b4cab96d6cf7b 100644
--- a/alib/src/regexp/Concatenation.cpp
+++ b/alib/src/regexp/Concatenation.cpp
@@ -42,11 +42,11 @@ Concatenation::~Concatenation() {
 	elements.clear();
 }
 
-vector<RegExpElement*>& Concatenation::getElements() {
+list<RegExpElement*>& Concatenation::getElements() {
 	return elements;
 }
 
-const vector<RegExpElement*>& Concatenation::getElements() const {
+const list<RegExpElement*>& Concatenation::getElements() const {
 	return elements;
 }
 
diff --git a/alib/src/regexp/Concatenation.h b/alib/src/regexp/Concatenation.h
index 2e4713875fad7ac0aaef1d4a61fd03a4ac0c7583..9fead277d3acba1db41b8d4352fd87f643af69dd 100644
--- a/alib/src/regexp/Concatenation.h
+++ b/alib/src/regexp/Concatenation.h
@@ -8,7 +8,7 @@
 #ifndef CONCATENATION_H_
 #define CONCATENATION_H_
 
-#include <vector>
+#include <list>
 #include "RegExpElement.h"
 
 namespace regexp {
@@ -21,7 +21,7 @@ using namespace std;
  */
 class Concatenation: public RegExpElement {
 private:
-	vector<RegExpElement*> elements;
+	list<RegExpElement*> elements;
 public:
 	Concatenation();
 	Concatenation(const Concatenation& other);
@@ -31,12 +31,12 @@ public:
 	/**
 	 * @return list of operands
 	 */
-	vector<RegExpElement*>& getElements();
+	list<RegExpElement*>& getElements();
 
 	/**
 	 * @return list of operands
 	 */
-	const vector<RegExpElement*>& getElements() const;
+	const list<RegExpElement*>& getElements() const;
 
 	/**
 	 * @copydoc RegExpElement::clone() const
diff --git a/alib/src/regexp/Iteration.h b/alib/src/regexp/Iteration.h
index 4bca308eabb4bfdb40e6fca360debc9976648c3d..7466b2aedc4d440e2cd69eb8eb0ae3c939eb014c 100644
--- a/alib/src/regexp/Iteration.h
+++ b/alib/src/regexp/Iteration.h
@@ -8,6 +8,7 @@
 #ifndef ITERATION_H_
 #define ITERATION_H_
 
+#include <list>
 #include "RegExpElement.h"
 
 namespace regexp {
diff --git a/alib/src/regexp/RegExp.cpp b/alib/src/regexp/RegExp.cpp
index 27afc0cb913744b2fcd94073b5ea2d4c9d66aa89..621b00415264f179667d187fc98a9a04465a82b1 100644
--- a/alib/src/regexp/RegExp.cpp
+++ b/alib/src/regexp/RegExp.cpp
@@ -8,6 +8,8 @@
 #include "RegExp.h"
 #include "RegExpPrinter.h"
 
+#include <iostream>
+
 namespace regexp {
 
 RegExp::RegExp() {
diff --git a/alib/src/regexp/RegExp.h b/alib/src/regexp/RegExp.h
index ef21bad4b54a3c9391d41dcc2e373d191ab2fbcc..f16133cc5fa38305e2701f569705de2b5fca3317 100644
--- a/alib/src/regexp/RegExp.h
+++ b/alib/src/regexp/RegExp.h
@@ -8,8 +8,9 @@
 #ifndef REGEXP_H_
 #define REGEXP_H_
 
-#include <iostream>
-
+#include <vector>
+#include <list>
+#include <string>
 #include "RegExpElement.h"
 #include "RegExpEmpty.h"
 
diff --git a/alib/src/regexp/RegExpParser.cpp b/alib/src/regexp/RegExpParser.cpp
index 81d52a3987b38bda1033935bb9c6ba57775d381a..5bcad371450a35c23584ebbfc6d5e26ca3c80e05 100644
--- a/alib/src/regexp/RegExpParser.cpp
+++ b/alib/src/regexp/RegExpParser.cpp
@@ -68,7 +68,7 @@ Iteration* RegExpParser::parseIteration(list<Token>& input) {
 	return iteration;
 }
 
-void RegExpParser::parseContent(list<Token>& input, vector<RegExpElement*>& elements) {
+void RegExpParser::parseContent(list<Token>& input, list<RegExpElement*>& elements) {
 	while (true) {
 		RegExpElement* element = parseElement(input);
 		if(!element) return;
diff --git a/alib/src/regexp/RegExpParser.h b/alib/src/regexp/RegExpParser.h
index 808ad17d244a16d3bd70bae78e7b0487ac55a4d0..126f20ee5dc165c00e31a5f4424550d391ed9948 100644
--- a/alib/src/regexp/RegExpParser.h
+++ b/alib/src/regexp/RegExpParser.h
@@ -8,8 +8,6 @@
 #ifndef REGEXPPARSER_H_
 #define REGEXPPARSER_H_
 
-#include <list>
-
 #include "RegExp.h"
 #include "../sax/Token.h"
 #include "RegExpSymbol.h"
@@ -29,7 +27,7 @@ using namespace sax;
  */
 class RegExpParser {
 protected:
-	static void parseContent(list<Token>& input, vector<RegExpElement*>& elements);
+	static void parseContent(list<Token>& input, list<RegExpElement*>& elements);
 	static RegExpElement* parseElement(list<Token>& input);
 
 	static RegExpEpsilon* parseEpsilon(list<Token>& input);
diff --git a/alib/src/regexp/RegExpPrinter.cpp b/alib/src/regexp/RegExpPrinter.cpp
index f3757b302588ddd87ce45dbb45ed6fa7eafdb3b6..223ab546911f2e457c2a9f3558d7cc2da972c8b3 100644
--- a/alib/src/regexp/RegExpPrinter.cpp
+++ b/alib/src/regexp/RegExpPrinter.cpp
@@ -56,7 +56,7 @@ void RegExpPrinter::printElement(RegExpElement* element, ostream& out, string pr
 
 }
 
-void RegExpPrinter::printContent(vector<RegExpElement*>& content, ostream& out, string prefix) {
+void RegExpPrinter::printContent(list<RegExpElement*>& content, ostream& out, string prefix) {
 	for (auto element : content) {
 		printElement(element, out, prefix);
 	}
diff --git a/alib/src/regexp/RegExpPrinter.h b/alib/src/regexp/RegExpPrinter.h
index 33c21f8da4fd61a5b620af34a8ba2cf91a7d1ee6..49ba46d027298d068fde7355c487f239a57fc75e 100644
--- a/alib/src/regexp/RegExpPrinter.h
+++ b/alib/src/regexp/RegExpPrinter.h
@@ -28,7 +28,7 @@ class RegExpPrinter {
 protected:
 	static const string INDENTATION;
 	static void printElement(RegExpElement* element, ostream& out, string prefix);
-	static void printContent(vector<RegExpElement*>& content, ostream& out, string prefix);
+	static void printContent(list<RegExpElement*>& content, ostream& out, string prefix);
 	static void printAlternation(Alternation* alternation, ostream& out, string prefix);
 	static void printConcatenation(Concatenation* concatenation, ostream& out, string prefix);
 
diff --git a/libaderivation/src/RegExpDerivation.cpp b/libaderivation/src/RegExpDerivation.cpp
index 2e3aca7c21b99b5441ade90ca260def3f66603ef..54d5b04c6083e1d3c2b4bef03e80a74141560692 100644
--- a/libaderivation/src/RegExpDerivation.cpp
+++ b/libaderivation/src/RegExpDerivation.cpp
@@ -16,7 +16,7 @@ RegExpDerivation::RegExpDerivation( const RegExp & re ) : m_re( re )
 
 }
 
-RegExp RegExpDerivation::derivation ( const vector<RegExpElement*> & dString ) const
+RegExp RegExpDerivation::derivation ( const list<RegExpElement*> & dString ) const
 {
     const RegExpElement * oldRegExp = m_re.getRegExp( )->clone( ), * derivedRegExp;
 
diff --git a/libaderivation/src/RegExpDerivation.h b/libaderivation/src/RegExpDerivation.h
index d733773cb2730713364e78cc04ea9719e0af08f1..e840bfd4e26fceaebfdc2d532454b6f6e3dd2399 100644
--- a/libaderivation/src/RegExpDerivation.h
+++ b/libaderivation/src/RegExpDerivation.h
@@ -33,7 +33,7 @@ class RegExpDerivation
 {
 public:
     RegExpDerivation( const regexp::RegExp & re );
-    regexp::RegExp derivation( const std::vector<regexp::RegExpElement*> & dString ) const;
+    regexp::RegExp derivation( const std::list<regexp::RegExpElement*> & dString ) const;
 
 private:
     regexp::RegExpElement * derivation( const regexp::RegExpElement * element, const regexp::RegExpSymbol & dSymbol ) const;
diff --git a/libaderivation/src/RegExpIntegral.cpp b/libaderivation/src/RegExpIntegral.cpp
index 25b8ce5b79481ad166a9eb98da9bfb1f7ec6ec51..edbd68cfbffa7c9fb6c4815e3dfeee0e831631e7 100644
--- a/libaderivation/src/RegExpIntegral.cpp
+++ b/libaderivation/src/RegExpIntegral.cpp
@@ -15,7 +15,7 @@ RegExpIntegral::RegExpIntegral( const RegExp & re ) : m_re( re )
 
 }
 
-RegExp RegExpIntegral::integral( const vector<RegExpElement*> & dString ) const
+RegExp RegExpIntegral::integral( const list<RegExpElement*> & dString ) const
 {
     const RegExpElement * oldRegExp = m_re.getRegExp( )->clone( ), * integralRegExp;
 
diff --git a/libaderivation/src/RegExpIntegral.h b/libaderivation/src/RegExpIntegral.h
index cbc3a01084546d3f79bb7a48447fb2124ea9dfff..4e0b2b549d63bd503d5e4b9fd5fa4d8cfdebedf2 100644
--- a/libaderivation/src/RegExpIntegral.h
+++ b/libaderivation/src/RegExpIntegral.h
@@ -22,7 +22,7 @@ class RegExpIntegral
 {
 public:
     RegExpIntegral( const regexp::RegExp & re );
-    regexp::RegExp integral( const std::vector<regexp::RegExpElement*> & dString ) const;
+    regexp::RegExp integral( const std::list<regexp::RegExpElement*> & dString ) const;
 
 private:
     regexp::RegExpElement * integral( const regexp::RegExpElement * node, const regexp::RegExpSymbol & dSymbol ) const;
diff --git a/libaregexptree/src/RegExpOptimize.cpp b/libaregexptree/src/RegExpOptimize.cpp
index 8755564551bde8887abc7a13397e5d50d08903ec..36ea5c56ea36ececaa7b1bc8b276a303e299eb40 100644
--- a/libaregexptree/src/RegExpOptimize.cpp
+++ b/libaregexptree/src/RegExpOptimize.cpp
@@ -6,7 +6,6 @@
  */
 
 #include "RegExpOptimize.h"
-#include <algorithm>
 
 using namespace alib;
 using namespace regexp;
@@ -74,8 +73,7 @@ RegExpElement * RegExpOptimize::optimize( const Alternation * node )
     }
 
     // A2: x + y = y + x
-
-    std::sort (alt->getElements( ).begin( ), alt->getElements( ).end( ), [](RegExpElement const * const & a, RegExpElement const * const & b) -> bool {
+    alt->getElements().sort([](RegExpElement const * const & a, RegExpElement const * const & b) -> bool {
       return *a < *b;
     });