@Override
	protected BitSet processHeader(BitSet bits){
		int offset = 0;
		symbolCount = 0;
		int freqSize = fromBitSetLen(bits, offset, 6);
		offset += 6;
		int simbolSize = fromBitSetLen(bits, offset, 5);
		offset += 5;
		symbSize = (byte) simbolSize;
		Integer freq = -1;
		BitSet symb = new BitSet();
		symbols.clear();
		while(freq != 0){
			symb = new BitSet(); 
			freq = fromBitSetLen(bits, offset, freqSize);
			symbolCount += freq;
			offset += freqSize;
			if (freq == 0){
				while ((offset % 8) != 0){
					offset++;
				}
				break;
			} 
			for (int i = 0; i < symbSize; i++){
				symb.set(i, bits.get(i + offset));  
			}
			offset += symbSize;
			symbols.put(symb, freq);
		}  
		bits = bits.get(offset, bitsNumber);
		bitsNumber -= offset;
		if (algorithm){
			treeCreator = new Fan();
		}
		else{
			treeCreator = new Huffman();
		}
		createTree(treeCreator.tree); 
		header = false;
		setLenght(symbolCount);
		return bits;
	}