         if (NSJSONSerialization.writeJSONObject(data,
                                                 toStream : outputStream!,
                                                 options  : opts,
-                                                error    : &err) != 0) {
+                                                error    : &error) != 0) {
             result = true
         }
         
         
         #if DEBUG
-            if (err != nil) {
-                println("ERROR - \(__FILE__):\(__FUNCTION__) - WRITE FAILED -"
-                        + " \(err)")
+            if (error != nil) {
+                println("ERROR - \(__FILE__):\(__FUNCTION__) - WRITE FAILED - "
+                        + "\(error)")
             }
         #endif
         

        // TODO: Why does calling open() twice (without below) return success?
        if (conn != 0) {
            #if DEBUG
                println("WARNING - \(__FILE__):\(__FUNCTION__) - "
                        + "\(SMC.IOSERVICE_SMC) connection already open")
            #endif
            return kIOReturnStillOpen
        }
        
        
        let service = IOServiceGetMatchingService(kIOMasterPortDefault,
                      IOServiceMatching(SMC.IOSERVICE_SMC).takeUnretainedValue())
        
        if (service == 0) {
            #if DEBUG
                println("ERROR - \(__FILE__):\(__FUNCTION__) - \(SMC.IOSERVICE_SMC)"
                        + " service not found")
            #endif
            
            return kIOReturnError

        // error - MACH_SEND_INVALID_DEST
        let result = IOServiceClose(conn)
        conn = 0    // Reset this incase open() is called again
        
        #if DEBUG
            if (result != kIOReturnSuccess) {
                println("ERROR - \(__FILE__):\(__FUNCTION__) - Failed to close")
            }
        #endif
        
        return result
    }
    
