diff --git a/alib2algo/src/stringology/indexing/PositionHeapNaive.h b/alib2algo/src/stringology/indexing/PositionHeapNaive.h
index 2b98cd6cc4ac4f62d6e7a998a53ec11e6a0558f4..e9fb751ce4e9982b7ebf218ebcb30eeb8da12c9f 100644
--- a/alib2algo/src/stringology/indexing/PositionHeapNaive.h
+++ b/alib2algo/src/stringology/indexing/PositionHeapNaive.h
@@ -53,7 +53,7 @@ indexes::stringology::PositionHeap < SymbolType > PositionHeapNaive::construct (
 		n = & n->getChildren ( ).insert ( std::make_pair ( w.getContent ( )[k], ext::trie < SymbolType, unsigned > ( node ) ) ).first->second;
 	}
 
-	return indexes::stringology::PositionHeap < SymbolType > ( w.getAlphabet ( ), std::move ( trie ), w.getContent ( ) );
+	return indexes::stringology::PositionHeap < SymbolType > ( std::move ( trie ), string::LinearString < SymbolType > ( w ) );
 }
 
 } /* namespace indexing */
diff --git a/alib2algo/src/stringology/query/PositionHeapFactors.h b/alib2algo/src/stringology/query/PositionHeapFactors.h
index f266b8b1d190f2b83fd4e02909965cf23bba497a..0967d8d9c6fc827ae0d2354e3356b7b3d852614e 100644
--- a/alib2algo/src/stringology/query/PositionHeapFactors.h
+++ b/alib2algo/src/stringology/query/PositionHeapFactors.h
@@ -64,14 +64,14 @@ ext::set < unsigned > PositionHeapFactors::query ( const indexes::stringology::P
 
 	const ext::trie < SymbolType, unsigned > * node = & positionHeap.getRoot ( );
 	unsigned depth = 0;
-	unsigned indexedStringSize = positionHeap.getString ( ).size ( );
+	unsigned indexedStringSize = positionHeap.getString ( ).getContent ( ).size ( );
 
 	for ( const SymbolType & symbol : string.getContent ( ) ) {
 
 		if(common::GlobalData::verbose)
 			common::Streams::log << "on path possible occ (raw, string index): (" << node->getData ( ) << ", " << indexedStringSize - node->getData ( ) << ")" << std::endl;
 
-		if ( checkOcc ( string, depth, positionHeap.getString ( ), indexedStringSize - node->getData ( ) ) )
+		if ( checkOcc ( string, depth, positionHeap.getString ( ).getContent ( ), indexedStringSize - node->getData ( ) ) )
 			res.insert ( indexedStringSize - node->getData ( ) );
 
 		auto iter = node->getChildren ( ).find ( symbol );
diff --git a/alib2data/src/indexes/stringology/PositionHeap.h b/alib2data/src/indexes/stringology/PositionHeap.h
index eb9a8a07253d80df482ed69b14bd84387a5a5434..6615761bbd4a6611233c03f350368e5430e2bcd6 100644
--- a/alib2data/src/indexes/stringology/PositionHeap.h
+++ b/alib2data/src/indexes/stringology/PositionHeap.h
@@ -1,6 +1,22 @@
 /*
  * PositionHeap.h
  *
+ * This file is part of Algorithms library toolkit.
+ * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
+
+ * Algorithms library toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * Algorithms library toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with Algorithms library toolkit.  If not, see <http://www.gnu.org/licenses/>.
+ *
  *  Created on: Nov 23, 2013
  *      Author: Jan Travnicek
  */
@@ -27,18 +43,15 @@
 #include <sax/FromXMLParserHelper.h>
 #include <core/xmlApi.hpp>
 
-#include <container/ObjectsSet.h>
 #include <container/ObjectsTrie.h>
-#include <container/ObjectsVector.h>
-
-#include <container/xml/ObjectsSet.h>
 #include <container/xml/ObjectsTrie.h>
-#include <container/xml/ObjectsVector.h>
 
 #include <primitive/Unsigned.h>
 #include <primitive/xml/Unsigned.h>
 
-#include <alphabet/common/SymbolNormalize.h>
+#include <string/LinearString.h>
+#include <string/xml/LinearString.h>
+
 #include <indexes/common/IndexesNormalize.h>
 
 namespace indexes {
@@ -48,82 +61,144 @@ namespace stringology {
 class GeneralAlphabet;
 
 /**
- * Represents regular expression parsed from the XML. Regular expression is stored
- * as a tree of RegExpElement.
+ * \brief Position heap string index. Tree like representation of all suffixes. The suffixes are themselves represented by their prefixes. The prefix of each suffix needs to be unique from all representants (prefixes again) of shorter suffixes. Nodes of the trie contain index of the suffix. The parent child relationship of nodes is represented by single symbol. The class does not checks whether the trie structure actually is position heap.
+ *
+ * Also the size of the structure is exactly linear.
+ *
+ * \tparam SymbolType type of symbols of indexed string
  */
 template < class SymbolType = DefaultSymbolType >
-class PositionHeap final : public object::ObjectBase, public core::Components < PositionHeap < SymbolType >, ext::set < SymbolType >, component::Set, GeneralAlphabet > {
-protected:
+class PositionHeap final : public object::ObjectBase {
+	/**
+	 * Representation of the position heap.
+	 */
 	ext::trie < SymbolType, unsigned > m_trie;
-	ext::vector < SymbolType > m_string;
 
-public:
 	/**
-	 * @copydoc PositionHeap::clone ( ) const &
+	 * The copy of indexed string.
 	 */
-	virtual ObjectBase * clone ( ) const &;
+	string::LinearString < SymbolType > m_string;
+
+	/**
+	 * \brief Checks edges of the raw position heap, whether they are over the specified alphabet.
+	 *
+	 * \throws exception::CommonException if there is a symbol on position heap edges not present in the alphabet.
+	 */
+	void checkTrie ( const ext::trie < SymbolType, unsigned > & trie );
 
+public:
 	/**
-	 * @copydoc PositionHeap::clone ( ) const &
+	 * @copydoc ObjectBase::clone ( ) const &
 	 */
-	virtual ObjectBase * clone ( ) &&;
+	virtual ObjectBase * clone ( ) const & override;
 
-	explicit PositionHeap ( ext::set < SymbolType > edgeAlphabet, ext::trie < SymbolType, unsigned > trie, ext::vector < SymbolType > string );
-	explicit PositionHeap ( ext::trie < SymbolType, unsigned > trie, ext::vector < SymbolType > string );
+	/**
+	 * @copydoc ObjectBase::clone ( ) &&
+	 */
+	virtual ObjectBase * clone ( ) && override;
 
-	void checkTrie ( const ext::trie < SymbolType, unsigned > & trie );
+	/**
+	 * Creates a new instance of the index based on constructed position heap and original indexed string.
+	 *
+	 * \param trie the raw data of the index - the position heap
+	 * \param string the indexed string
+	 */
+	explicit PositionHeap ( ext::trie < SymbolType, unsigned > trie, string::LinearString < SymbolType > string );
 
 	/**
-	 * @return Root node of the trie
+	 * Getter of the raw position heap.
+	 *
+	 * \return root node of the position heap
 	 */
 	const ext::trie < SymbolType, unsigned > & getRoot ( ) const &;
 
+	/**
+	 * Getter of the raw position heap.
+	 *
+	 * \return root node of the position heap
+	 */
 	ext::trie < SymbolType, unsigned > && getRoot ( ) &&;
 
-	const ext::vector < SymbolType > & getString ( ) const &;
+	/**
+	 * Getter of the indexed string.
+	 *
+	 * @return the indexed string
+	 */
+	const string::LinearString < SymbolType > & getString ( ) const &;
 
-	ext::vector < SymbolType > && getString ( ) &&;
+	/**
+	 * Getter of the indexed string.
+	 *
+	 * @return the indexed string
+	 */
+	string::LinearString < SymbolType > && getString ( ) &&;
 
+	/**
+	 * Getter of the alphabet of the indexed string.
+	 *
+	 * \returns the alphabet of the indexed string
+	 */
 	const ext::set < SymbolType > & getAlphabet ( ) const & {
-		return this->template accessComponent < GeneralAlphabet > ( ).get ( );
+		return m_string.getAlphabet ( );
 	}
 
+	/**
+	 * Getter of the alphabet of the indexed string.
+	 *
+	 * \returns the alphabet of the indexed string
+	 */
 	ext::set < SymbolType > && getAlphabet ( ) && {
-		return this->template accessComponent < GeneralAlphabet > ( ).get ( );
+		return std::move ( m_string ).getAlphabet ( );
 	}
 
 	/**
-	 * Sets the root node of the regular expression tree
-	 * @param tree root node to set
+	 * Sets the root node of the suffix trie
+	 *
+	 * \param tree root node to set
 	 */
 	void setTree ( ext::trie < SymbolType, unsigned > tree );
 
 	/**
-	 * Removes symbol from the alphabet of symbol available in the regular expression
-	 * @param symbol removed symbol from the alphabet
+	 * Remover of a symbol from the alphabet.
+	 *
+	 * \param symbol a symbol to remove.
 	 */
 	bool removeSymbolFromEdgeAlphabet ( const SymbolType & symbol ) {
-		return this->template accessComponent < GeneralAlphabet > ( ).remove ( symbol );
+		return m_string.removeSymbol ( symbol );
 	}
 
 	/**
-	 * Prints XML representation of the tree to the output stream.
-	 * @param out output stream to which print the tree
-	 * @param tree tree to print
+	 * @copydoc alib::CommonBase<ObjectBase>::compare ( const ObjectBase & )
 	 */
-	virtual void operator >>( std::ostream & out ) const;
-
-	virtual int compare ( const ObjectBase & other ) const {
+	virtual int compare ( const ObjectBase & other ) const override {
 		if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other );
 
 		return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) );
 	}
 
-	virtual int compare ( const PositionHeap & other ) const;
+	/**
+	 * The actual compare method
+	 *
+	 * \param other the other instance
+	 *
+	 * \returns the actual relation between two by type same index instances
+	 */
+	int compare ( const PositionHeap & other ) const;
 
-	virtual explicit operator std::string ( ) const;
+	/**
+	 * @copydoc alib::CommonBase<ObjectBase>::operator >> ( std::ostream & )
+	 */
+	virtual void operator >>( std::ostream & out ) const override;
 
-	virtual object::ObjectBase * inc ( ) &&;
+	/**
+	 * @copydoc alib::CommonBase<ObjectBase>::operator std::string ( )
+	 */
+	virtual explicit operator std::string ( ) const override;
+
+	/**
+	 * @copydoc alib::ObjectBase::inc()
+	 */
+	virtual object::ObjectBase * inc ( ) && override;
 };
 
 } /* namespace stringology */
@@ -135,13 +210,8 @@ namespace indexes {
 namespace stringology {
 
 template < class SymbolType >
-PositionHeap < SymbolType >::PositionHeap ( ext::set < SymbolType > edgeAlphabet, ext::trie < SymbolType, unsigned > trie, ext::vector < SymbolType > string ) : core::Components < PositionHeap, ext::set < SymbolType >, component::Set, GeneralAlphabet > ( std::move ( edgeAlphabet ) ), m_trie ( std::move ( trie ) ), m_string ( std::move ( string ) ) {
+PositionHeap < SymbolType >::PositionHeap ( ext::trie < SymbolType, unsigned > trie, string::LinearString < SymbolType > string ) : m_trie ( std::move ( trie ) ), m_string ( std::move ( string ) ) {
 	checkTrie ( this->m_trie );
-	// TODO check validity of the string like in LinearString
-}
-
-template < class SymbolType >
-PositionHeap < SymbolType >::PositionHeap ( ext::trie < SymbolType, unsigned > trie, ext::vector < SymbolType > string ) : PositionHeap ( computeMinimalEdgeAlphabet ( trie ), trie, std::move ( string ) ) {
 }
 
 template < class SymbolType >
@@ -174,12 +244,12 @@ ext::trie < SymbolType, unsigned > && PositionHeap < SymbolType >::getRoot ( ) &
 }
 
 template < class SymbolType >
-const ext::vector < SymbolType > & PositionHeap < SymbolType >::getString ( ) const & {
+const string::LinearString < SymbolType > & PositionHeap < SymbolType >::getString ( ) const & {
 	return m_string;
 }
 
 template < class SymbolType >
-ext::vector < SymbolType > && PositionHeap < SymbolType >::getString ( ) && {
+string::LinearString < SymbolType > && PositionHeap < SymbolType >::getString ( ) && {
 	return std::move ( m_string );
 }
 
@@ -196,7 +266,7 @@ void PositionHeap < SymbolType >::operator >>( std::ostream & out ) const {
 
 template < class SymbolType >
 int PositionHeap < SymbolType >::compare ( const PositionHeap & other ) const {
-	auto first = ext::tie ( getRoot ( ), getAlphabet ( ) );
+	auto first = ext::tie ( getRoot ( ), getAlphabet ( ) ); // indexed string does not need to be compared.
 	auto second = ext::tie ( other.getRoot ( ), other.getAlphabet ( ) );
 
 	static ext::compare < decltype ( first ) > comp;
@@ -222,50 +292,35 @@ object::ObjectBase* PositionHeap < SymbolType >::inc() && {
 
 namespace core {
 
-template < class SymbolType >
-class SetConstraint < indexes::stringology::PositionHeap < SymbolType >, SymbolType, indexes::stringology::GeneralAlphabet > {
-
-	static bool used ( const ext::trie < SymbolType, unsigned > & trie, const SymbolType & symbol ) {
-		for ( const std::pair < const SymbolType, ext::trie < SymbolType, unsigned > > & child : trie.getChildren ( ) ) {
-			if ( symbol == child.first || checkTrie ( trie, child.second ) )
-				return true;
-		}
-		return false;
-	}
-
-public:
-	static bool used ( const indexes::stringology::PositionHeap < SymbolType > & index, const SymbolType & symbol ) {
-		const ext::vector < SymbolType > & content = index.getString ( );
-		return std::find ( content.begin(), content.end(), symbol ) != content.end() || used ( index.getRoot ( ), symbol );
-	}
+template < class SymbolType, class RankType >
+struct normalize < indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > > {
+	static indexes::stringology::PositionHeap < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > evalRanked ( indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > && value ) {
+		ext::trie < common::ranked_symbol < DefaultSymbolType, DefaultRankType >, unsigned > trie = indexes::IndexesNormalize::normalizeRankedTrie ( std::move ( value ).getRoot ( ) );
+		string::LinearString < common::ranked_symbol < DefaultSymbolType > > string = normalize < string::LinearString < common::ranked_symbol < SymbolType, RankType > > >::eval ( std::move ( value ).getString ( ) );
 
-	static bool available ( const indexes::stringology::PositionHeap < SymbolType > &, const SymbolType & ) {
-		return true;
+		return indexes::stringology::PositionHeap < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > ( std::move ( trie ), std::move ( string ) );
 	}
 
-	static void valid ( const indexes::stringology::PositionHeap < SymbolType > &, const SymbolType & ) {
-	}
-};
-
-template < class SymbolType, class RankType >
-struct normalize < indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > > {
-	static indexes::stringology::PositionHeap < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > eval ( indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > && source ) {
-		ext::set < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > alphabet = alphabet::SymbolNormalize::normalizeRankedAlphabet ( std::move ( source ).getAlphabet ( ) );
-		ext::trie < common::ranked_symbol < DefaultSymbolType, DefaultRankType >, unsigned > trie = indexes::IndexesNormalize::normalizeRankedTrie ( std::move ( source ).getRoot ( ) );
-		ext::vector < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > string = alphabet::SymbolNormalize::normalizeRankedSymbols ( std::move ( source ).getString ( ) );
+	static indexes::stringology::PositionHeap < > eval ( indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > && value ) {
+		ext::trie < DefaultSymbolType, unsigned > trie = indexes::IndexesNormalize::normalizeTrie ( std::move ( value ).getRoot ( ) );
+		string::LinearString < DefaultSymbolType > string = normalize < string::LinearString < SymbolType > >::eval ( std::move ( value ).getString ( ) );
 
-		return indexes::stringology::PositionHeap < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > ( std::move ( alphabet ), std::move ( trie ), std::move ( string ) );
+		return indexes::stringology::PositionHeap < > ( std::move ( trie ), std::move ( string ) );
 	}
 };
 
+/**
+ * Helper for normalisation of types specified by templates used as internal datatypes of symbols.
+ *
+ * \returns new instance of the index with default template parameters or unmodified instance if the template parameters were already the default ones
+ */
 template < class SymbolType >
 struct normalize < indexes::stringology::PositionHeap < SymbolType > > {
 	static indexes::stringology::PositionHeap < > eval ( indexes::stringology::PositionHeap < SymbolType > && value ) {
-		ext::set < DefaultSymbolType > alphabet = alphabet::SymbolNormalize::normalizeAlphabet ( std::move ( value ).getAlphabet ( ) );
 		ext::trie < DefaultSymbolType, unsigned > trie = indexes::IndexesNormalize::normalizeTrie ( std::move ( value ).getRoot ( ) );
-		ext::vector < DefaultSymbolType > string = alphabet::SymbolNormalize::normalizeSymbols ( std::move ( value ).getString ( ) );
+		string::LinearString < DefaultSymbolType > string = normalize < string::LinearString < SymbolType > >::eval ( std::move ( value ).getString ( ) );
 
-		return indexes::stringology::PositionHeap < > ( std::move ( alphabet ), std::move ( trie ), std::move ( string ) );
+		return indexes::stringology::PositionHeap < > ( std::move ( trie ), std::move ( string ) );
 	}
 };
 
@@ -280,10 +335,9 @@ struct xmlApi < indexes::stringology::PositionHeap < SymbolType > > {
 template < class SymbolType >
 indexes::stringology::PositionHeap < SymbolType > xmlApi < indexes::stringology::PositionHeap < SymbolType > >::parse ( ext::deque < sax::Token >::iterator & input ) {
 	sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, xmlTagName ( ) );
-	ext::set < SymbolType > edgeAlphabet = core::xmlApi < ext::set < SymbolType > >::parse ( input );
 	ext::trie < SymbolType, unsigned > root = core::xmlApi < ext::trie < SymbolType, unsigned > >::parse ( input );
-	ext::vector < SymbolType > string = core::xmlApi < ext::vector < SymbolType > >::parse ( input );
-	indexes::stringology::PositionHeap < SymbolType > res ( std::move ( edgeAlphabet ), std::move ( root ), std::move ( string ) );
+	string::LinearString < SymbolType > string = core::xmlApi < string::LinearString < SymbolType > >::parse ( input );
+	indexes::stringology::PositionHeap < SymbolType > res ( std::move ( root ), std::move ( string ) );
 
 	sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, xmlTagName ( ) );
 	return res;
@@ -304,9 +358,8 @@ const std::string & xmlApi < indexes::stringology::PositionHeap < SymbolType > >
 template < class SymbolType >
 void xmlApi < indexes::stringology::PositionHeap < SymbolType > >::compose ( ext::deque < sax::Token > & output, const indexes::stringology::PositionHeap < SymbolType > & index ) {
 	output.emplace_back ( xmlTagName ( ), sax::Token::TokenType::START_ELEMENT );
-	core::xmlApi < ext::set < SymbolType > >::compose ( output, index.getAlphabet ( ) );
 	core::xmlApi < ext::trie < SymbolType, unsigned > >::compose ( output, index.getRoot ( ) );
-	core::xmlApi < ext::vector < SymbolType > >::compose ( output, index.getString ( ) );
+	core::xmlApi < string::LinearString < SymbolType > >::compose ( output, index.getString ( ) );
 	output.emplace_back ( xmlTagName ( ), sax::Token::TokenType::END_ELEMENT );
 }
 
diff --git a/alib2data/src/string/LinearString.h b/alib2data/src/string/LinearString.h
index 6e38d9c5a3ffe74a163ade78f56dc02cfba5ac5b..018013de51bdf9145eefad2dc24d7580abeb2300 100644
--- a/alib2data/src/string/LinearString.h
+++ b/alib2data/src/string/LinearString.h
@@ -385,6 +385,22 @@ struct normalize < string::LinearString < SymbolType > > {
 	}
 };
 
+template < class SymbolType, class RankType >
+struct normalize < string::LinearString < common::ranked_symbol < SymbolType, RankType > > > {
+	static string::LinearString < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > evalRanked ( string::LinearString < common::ranked_symbol < SymbolType, RankType > > && value ) {
+		ext::set < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > alphabet = alphabet::SymbolNormalize::normalizeRankedAlphabet ( std::move ( value ).getAlphabet ( ) );
+		ext::vector < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > content = alphabet::SymbolNormalize::normalizeRankedSymbols ( std::move ( value ).getContent ( ) );
+
+		return string::LinearString < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > ( std::move ( alphabet ), std::move ( content ) );
+	}
+
+	static string::LinearString < > eval ( string::LinearString < common::ranked_symbol < SymbolType, RankType > > && value ) {
+		ext::set < DefaultSymbolType > alphabet = alphabet::SymbolNormalize::normalizeAlphabet ( std::move ( value ).getAlphabet ( ) );
+		ext::vector < DefaultSymbolType > content = alphabet::SymbolNormalize::normalizeSymbols ( std::move ( value ).getContent ( ) );
+		return string::LinearString < > ( std::move ( alphabet ), std::move ( content ) );
+	}
+};
+
 } /* namespace core */
 
 #endif /* LINEAR_STRING_H_ */