     
     public func URLSession(session: NSURLSession, task: NSURLSessionTask, didCompleteWithError error: NSError?) {
         
-        if (error != nil) {
-           
+        guard error == nil else {
+            Swift.print(error?.localizedDescription)
             failureReset()
-        
-        }else{
+            return;
+        }
             
-        
+            
         didFailLoadingImage = false
         userDidCancel = false
-        if let data = imageDownloadData {
-            if let img: NSImage = NSImage(data: data) {
-                image = img
-                isLoadingImage = false
-                
-                spinningWheel?.stopAnimation(self)
-                spinningWheel?.removeFromSuperview()
-                imageDownloadData = nil
-                imageURLDownloadTask = nil
-                errorImage = nil
-                
-                
-            } else  {
-                Swift.print("Error forming image from data.")
-                failureReset()
-            }
-        } else {
+        guard let data = imageDownloadData else {
             Swift.print("Image data not downloaded correctly.")
             failureReset()
-        }
-      }
+            return;
+        }
+        guard let img: NSImage = NSImage(data: data) else {
+            Swift.print("Error forming image from data.")
+            failureReset()
+            return;
+        }
+        image = img
+        isLoadingImage = false
+        
+        spinningWheel?.stopAnimation(self)
+        spinningWheel?.removeFromSuperview()
+        imageDownloadData = nil
+        imageURLDownloadTask = nil
+        errorImage = nil
+
     }
     
     //MARK: Tooltips

        self.errorImage = errorImage
        imageDownloadData = NSMutableData()
        
        let URL = NSURL(string: url)
        
        if URL == nil {
            isLoadingImage = false
            NSLog("Error: malformed URL passed to downloadImageFromURL")
            return
        }
        
        networkSession = NSURLSession.init(configuration:NSURLSessionConfiguration.defaultSessionConfiguration(), delegate: self, delegateQueue: NSOperationQueue.mainQueue())
        imageURLDownloadTask = networkSession!.downloadTaskWithURL(URL!)
        
        imageURLDownloadTask?.resume()
        if usesSpinningWheel {

    private var toolTipWhenFinishedWithError: String?
    
    deinit {
        cancelDownload()
    }
    
