 
 // TODO: This code is mostly experimental, use at your own risk - see TODO.markdown
 
-public extension CGContextRef {
+public extension CGContext {
 
-    class func bitmapContext(size:CGSize) -> CGContextRef! {
+    class func bitmapContext(size:CGSize) -> CGContext! {
         let colorspace = CGColorSpaceCreateDeviceRGB()    
         var bitmapInfo = CGBitmapInfo(CGImageAlphaInfo.PremultipliedFirst.toRaw())
         return CGBitmapContextCreate(nil, UInt(size.width), UInt(size.height), 8, UInt(size.width) * 4, colorspace, bitmapInfo)

#endif
}

public extension CGImageRef {
    var size : CGSize { get { return CGSize(width:CGFloat(CGImageGetWidth(self)), height:CGFloat(CGImageGetHeight(self))) } }
}

#if os(OSX)
public extension CGContextRef {

    var nsimage : NSImage {
        get { 
            let cgimage = CGBitmapContextCreateImage(self)

        block()
        CGContextRestoreGState(self)
    }
}

// MARK: Colors

public extension CGContext {
#if os(OSX)
    func withColor(color:NSColor, block:() -> Void) {
        with {
