     /// Is used to select exact variable from 'IsRep', 'IsRepG0', 'IsRepG1' and 'IsRepG2' arrays.
     private var state: Int = 0
 
+    /// An array for storing output data
+    var out: [UInt8] = []
+    // This array will also serve as dictionary and out window.
+    private var dictStart = 0
+    private var dictEnd = 0
+
+
     init(_ pointerData: inout DataWithPointer, _ lc: UInt8, _ pb: UInt8, _ lp: UInt8,
          _ dictionarySize: Int) throws {
         self.pointerData = pointerData

            throw LZMA2Error.WrongReset
        }
        var uncompressedSize = unpackSize
        out = try decodeLZMA(&uncompressedSize)
        guard unpackSize == out.count && pointerData.index - dataStartIndex == compressedSize
            else { throw LZMA2Error.WrongSizes }
        return out
    }

    func decodeLZMA(_ uncompressedSize: inout Int) throws -> [UInt8] {
        // First, we need to initialize Rande Decoder.
        guard let rD = LZMARangeDecoder(&self.pointerData) else {
            throw LZMAError.RangeDecoderInitError
        }
        self.rangeDecoder = rD

        /// An array for storing output data
        var out: [UInt8] = []

        // Main decoding cycle.
        while true {

                    symbol = (symbol << 1) | rangeDecoder.decode(bitWithProb: &literalProbs[litState][symbol])
                }
                let byte = (symbol - 0x100).toUInt8()

                out.append(byte)
                uncompressedSize -= 1
                dictEnd += 1
                if dictEnd - dictStart == dictionarySize {
                    dictStart += 1
                }
                // END.

                // Finally, we need to update `state`.
