                                 default:
                                     viewControllers.append(newViewController) // Create the view controller and append it to the navigation view controller stack
                                 }
+                            }
                         }
                     }
                 }
-            }
-            navController.viewControllers = viewControllers // Apply the updated list of view controller to the current navigation controller.
+                navController.viewControllers = viewControllers // Apply the updated list of view controller to the current navigation controller.
+            }
         }
     }
     

            }
        }
    }

    #if DEBUG
    // MARK: Remote Notifications
    
//    func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
//        println(">>> Entering \(__FUNCTION__) <<<")
//        println("userInfo: \(userInfo)")
//    }
//    
//    func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
//        println(">>> Entering \(__FUNCTION__) <<<")
//        println("userInfo: \(userInfo)")
//        completionHandler(.NewData)
//    }
//    
//    func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
//        println(">>> Entering \(__FUNCTION__) <<<")
//        println("deviceToken: \(deviceToken)")
//    }
//    
//    func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
//        println(">>> Entering \(__FUNCTION__) <<<")
//        println("\(error), \(error.localizedDescription)")
//    }
    #endif
    
    // MARK: Custom Methods
    func deepLinkToURL(url: NSURL) {
        // Maybe this can be expanded to handle icomming messages from remote or local notifications.

        // FIXME: This needs to be an optional.
        let pathComponents = url.pathComponents!
        let q = NSURLComponents(URL: url, resolvingAgainstBaseURL: false)
        
        println("queryItems: \(q?.queryItems)") // Not handling queries at that moment, but might want to.
    
        if let navController = self.window?.rootViewController as? UINavigationController { // Get the root view controller's navigation controller.
            navController.popToRootViewControllerAnimated(false) // Return to root viewcontroller without animation.
            let storyboard = self.window?.rootViewController?.storyboard // Grab the storyboard from the rootview.
            var viewControllers = navController.viewControllers as! [UIViewController] // Grab all the current view controllers in the stack.
            for storyboardID in pathComponents { // iterate through all the path components. Currently the app only has one level of deep linking.
                if let stringID = storyboardID as? String { // Cast the AnyObject into a string.
                    if let stor = UIStoryboard.StoryboardViewControllerIdentifier(rawValue: stringID) { // Attempt to create a storyboard identifier out of the string.
                        let allowed = contains(UIStoryboard.StoryboardViewControllerIdentifier.deepLinkableStoryboards, stor) // Check to see if this is an allowed viewcontroller.
                            if allowed {

                                let newViewController = storyboard!.instantiateViewControllerWithIdentifier(stringID) as! UIViewController
                                
                                switch (stor) {

        }
        
        // Always return NewData.
        // TODO: Refactor this so we can actually say with some accuracy that we did infact update with NewData or failed. It needs to take into account all the sites... one might fail but other might get new data... should return newdata at that point. If all fail (bad connection) then it should report .Fiailed.
        
        completionHandler(.NewData)
    }
    
    func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool {
        println(">>> Entering \(__FUNCTION__) <<<")
        println("Recieved URL: \(url) from sourceApplication: \(sourceApplication) annotation: \(annotation))")
        
        var schemes = AppDataManager.sharedInstance.supportedSchemes!
        if (!contains(schemes, url.scheme!)) { // If the incoming scheme is not contained within the array of supported schemes return false.
            return false
        }
        
        // We now have an acceptable scheme. Pass the URL to the deep linking handler.
        deepLinkToURL(url)
        
        return true
    }
