         bitsLeftInWriteBuffer -= 1
     }
 
-    public func setNextBits(_ bitsToWrite : UInt8, from bits: UInt64) {
+    public func setNextBits(_ bitsToWrite: UInt8, from bits: UInt64) {
         if( bitsToWrite > 64 ) {
             return
         }
 
-        var shiftedBits = bits << (64-bitsToWrite.toU64)
+        var shiftedBits = bits << (64 - bitsToWrite.toU64)
         var bitsLeftToWrite = bitsToWrite
         while bitsLeftToWrite > 0 {
             let bit = shiftedBits >> 63

import Foundation
import Bitter

public class Bitstream : NSObject {

    private var data : Data

    private var bitsLeftInReadBuffer : Int = 0
    private var readByteIndex : Int = 0
    private var readBuffer : UInt8 = 0

    private var writeBuffer : UInt8 = 0
    private var bitsLeftInWriteBuffer : Int = 8

    public init(data: Data ) {
        self.data = data

        return combinedValue
    }

    public func setNextBit(_ bit: UInt8 ) {
        if( bitsLeftInWriteBuffer == 0 ) {
            data.append(writeBuffer)
            writeBuffer = 0
