                         dist += bitTreeReverseDecode(probs: &posDecoders, startIndex: dist - posSlot,
                                                      bits: numDirectBits, rangeDecoder: &rangeDecoder, pointerData: &pointerData)
                     } else {
-                        dist += rangeDecoder.decode(directBits: (numDirectBits - Constants.numAlignBits) << Constants.numAlignBits,
-                                                    pointerData: &pointerData)
+                        dist += rangeDecoder.decode(directBits: (numDirectBits - Constants.numAlignBits),
+                                                    pointerData: &pointerData) << Constants.numAlignBits
                         dist += alignDecoder.reverseDecode(with: &rangeDecoder, pointerData: &pointerData)
                     }
                     rep0 = dist

        }

        func normalize(pointerData: inout DataWithPointer) {
            if self.range < Constants.topValue {
                self.range <<= 8
                self.code = (self.code << 8) | pointerData.alignedByte().toInt()
            }
        }

        func decode(directBits: Int, pointerData: inout DataWithPointer) -> Int {
            var res = 0
            var count = directBits
            repeat {
                self.range >>= 1
                self.code -= self.range
                let t = 0 - (self.code >> 31)
                self.code += self.range & t

                if self.code == self.range {
                    self.isCorrupted = true

            self.choice = Constants.probInitValue
            self.choice2 = Constants.probInitValue
            self.highCoder = BitTreeDecoder(numBits: 8)
            self.lowCoder = []
            self.midCoder = []
            for _ in 0..<(1 << Constants.numPosBitsMax) {
                self.lowCoder.append(BitTreeDecoder(numBits: 3))
                self.midCoder.append(BitTreeDecoder(numBits: 3))
            }
        }

        func decode(with rangeDecoder: inout RangeDecoder, posState: Int, pointerData: inout DataWithPointer) -> Int {
