             return pointers
         }
 
-        func bwt(reverse data: Data, end: inout Int) -> Data {
-            var reversed = Data()
-            if data.count > 0 {
-                let T = bwt(transform: data)
-                for _ in 0..<data.count {
+        func bwt(reverse bytes: [UInt8], end: inout Int) -> [UInt8] {
+            var resultBytes: [UInt8] = []
+            if bytes.count > 0 {
+                let T = bwt(transform: bytes)
+                for _ in 0..<bytes.count {
                     end = T[end]
-                    reversed.append(data[end])
-                }
-            }
-            return reversed
+                    resultBytes.append(bytes[end])
+                }
+            }
+            return resultBytes
         }
 
         let nt = bwt(reverse: buffer, end: &pointer)

            }
        }

        func bwt(transform data: Data) -> [Int] {
            // TODO: Check performance with and without sorting.
            let bytes = data.toArray(type: UInt8.self)
            let sortedBytes = bytes.sorted()
            var base: [Int] = Array(repeating: -1, count: 256)
            for i in 0..<256 {
                base[i] = sortedBytes.index(of: UInt8(truncatingBitPattern: UInt(i))) ?? -1
            }

            var pointers: [Int] = Array(repeating: -1, count: data.count)
            for (i, char) in bytes.enumerated() {
                pointers[base[char.toInt()]] = i
                base[char.toInt()] += 1

                repeatPower <<= 1
                continue
            } else if repeat_ > 0 {
                buffer.append(contentsOf: Array(repeating: favourites[0], count: repeat_))
                repeat_ = 0
            }
            if symbol == symbolsInUse - 1 {
