 		}
 	}
 	
-	private var seperatedFlags : Set<PhysicsBodyCategory> {
+}
+
+// MARK: - SpriteKit Integration
+internal extension PhysicsBodyCategory {
+	
+	var categoryBitMask : UInt32 {
+		return rawValue
+	}
+
+	var collisionBitMask : UInt32 {
+		var mask = PhysicsBodyCategory.none
+		
+		for flag in self.seperatedFlags {
+			PhysicsBodyCategory.collisions[flag]?.forEach {
+				mask.insert($0)
+			}
+		}
+		
+		return mask.rawValue
+	}
+	
+	var contactTestBitMask : UInt32 {
+		var mask = PhysicsBodyCategory.none
+		
+		for flag in self.seperatedFlags {
+			PhysicsBodyCategory.contacts[flag]?.forEach {
+				mask.insert($0)
+			}
+		}
+		
+		return mask.rawValue
+	}
+	
+}
+
+// MARK: - Decomposing Flags
+fileprivate extension PhysicsBodyCategory {
+	
+	fileprivate var seperatedFlags : Set<PhysicsBodyCategory> {
 		var flags = Set<PhysicsBodyCategory>()
 		
-		for i : UInt32 in 0..<31 {
+		for i : UInt32 in 0..<32 {
 			let mask = PhysicsBodyCategory(rawValue: 1 << i)
 			if self.contains(mask) {
 				flags.insert(mask)

	}
	
}

internal extension PhysicsBodyCategory {
	
	var categoryBitMask : UInt32 {
		return rawValue
	}
//
//	var contactTestBitMask : UInt32 {
//		
//	}
//	
//	var collisionBitMask : UInt32 {
//		
//	}
	
}

public extension PhysicsBodyCategory {
	
	public static let none			= PhysicsBodyCategory(rawValue: UInt32.allZeros)
	public static let all 			= PhysicsBodyCategory(rawValue: ~UInt32.allZeros)
	
	public static let `static` 		= PhysicsBodyCategory(rawValue: 1 << 31)
	public static let enviroment	= PhysicsBodyCategory(rawValue: 1 << 30)
	public static let effect 		= PhysicsBodyCategory(rawValue: 1 << 29)
	
}

		combineSeperatedFlags(compositeA: a, compositeB: b) { (x, y) in
			let previous = PhysicsBodyCategory.contacts[x] ?? Set<PhysicsBodyCategory>()
			let updated = previous.union([y])
			PhysicsBodyCategory.contacts[x] = updated
		}
	}
	
