         messageId += 1
 
         // TODO: Add 2 (for messageId) if/when QOS > 0
-        let remainingLengthBytes = encodeVariableLength(UInt(2 + topic.utf8.count + message.count))
+        let remainingLengthBytes = encodeVariableLength(2 + topic.utf8.count + message.count)
 
         let publishBytes: [UInt8] = [
             0x30] +                             // FIXED BYTE 1   3 = PUBLISH, 0 = DUP QoS RETAIN

    
    // MARK: - Utils
    
    private func encodeVariableLength(_ length: UInt) -> [UInt8] {
        var remainingBytes: [UInt8] = []
        var workingLength = length
        
        while workingLength > 0 {
            var byte = UInt8(workingLength & 0x7F)

            remainingLength += (2 + password.utf8.count) // 2 byte password length + codepoints
        }

        let remainingLengthBytes = encodeVariableLength(remainingLength)

        let headerBytes: [UInt8] = [
            0x10] +                             // FIXED BYTE 1   1 = CONNECT, 0 = DUP QoS RETAIN, not used in CONNECT
