             fatalError("Unexpected call to decodeMessage()")
         }
 
-        if unknownFieldsStack.count > ProtoReader.recursionLimit {
+        if messageStackDepth > ProtoReader.recursionLimit {
             throw ProtoDecoder.Error.recursionLimitExceeded
         }
 

    init(buffer: ReadBuffer) {
        self.buffer = buffer
        self.state = .lengthDelimited(length: buffer.count)
        self.unknownFieldsStack.append(nil)
    }

    // MARK: - Public Methods - Iterating Tags


        let expectedEndPointer = buffer.pointer.advanced(by: length)

        messageStackDepth += 1
        try decode(length)

        let unknownFieldsData = unknownFieldsByMessageDepth?.removeValue(forKey: messageStackDepth)
        messageStackDepth -= 1

        if buffer.pointer != expectedEndPointer {
            throw ProtoDecoder.Error.invalidStructure(
