     
     public init?(data: Data) {
         
-        guard let bitmask = BitMaskOptionSet<Category>(bitmaskArray: data)
-            else { return nil }
-        
-        self.categories = bitmask
+        guard let bitmask = Category.RawValue(bitmaskArray: data)
+            else { return nil }
+        
+        self.categories = BitMaskOptionSet<Category>(rawValue: bitmask)
     }
     
     public var data: Data {
         
-        return categories.bitmaskArray
+        return categories.rawValue.bitmaskArray
     }
 }
 

    /// The value of the characteristic is a bit mask implemented as an array of unsigned 8 bit integers.
    var bitmaskArray: Data {
        
        if rawValue <= numericCast(UInt8.max) {
            
            return Data([UInt8(rawValue)])
            
        } else if rawValue <= numericCast(UInt16.max) {
            
            let bytes = UInt16(rawValue).littleEndian.bytes
            
            return Data([bytes.0, bytes.1])
            
        } else if rawValue <= numericCast(UInt32.max) {
            
            let bytes = UInt32(rawValue).littleEndian.bytes
            
            return Data([bytes.0, bytes.1, bytes.2, bytes.3])
            
        } else if rawValue <= numericCast(UInt64.max) {
            
            let bytes = UInt64(rawValue).littleEndian.bytes
            
            return Data([bytes.0, bytes.1, bytes.2, bytes.3, bytes.4, bytes.5, bytes.6, bytes.7])
            
        } else {
            
            fatalError("\(rawValue) is to big to encode into byte array")
        }
    }
}

    
    public init?(data: Data) {
        
        guard let bitmask = Category.RawValue(bitmaskArray: data)
            else { return nil }
        
        self.categories = BitMaskOptionSet<Category>(rawValue: bitmask)
    }
    
    public var data: Data {
        
        return categories.rawValue.bitmaskArray
    }
    
    public var characteristic: GATT.Characteristic {
