     }
     
     func session(session: MCSession, didReceiveData data: NSData, fromPeer peerID: MCPeerID) {
-        // Decode the incoming data to a UTF8 encoded string
-        let receivedMessage = NSString(data: data, encoding: NSUTF8StringEncoding)
-        
-        NSLog("didReceiveData %@ from %@", receivedMessage!, peerID.displayName)
+        NSLog("%@ from [%@]", __FUNCTION__, peerID.displayName)
     }
     
     func session(session: MCSession, didStartReceivingResourceWithName resourceName: String, fromPeer peerID: MCPeerID, withProgress progress: NSProgress) {
-        NSLog("didStartReceivingResourceWithName [%@] from %@ with progress [%@]", resourceName, peerID.displayName, progress)
+        NSLog("%@ [%@] from %@ with progress [%@]", __FUNCTION__, resourceName, peerID.displayName, progress)
     }
     
     func session(session: MCSession, didFinishReceivingResourceWithName resourceName: String, fromPeer peerID: MCPeerID, atURL localURL: NSURL, withError error: NSError?) {
-        NSLog("didFinishReceivingResourceWithName [%@] from %@", resourceName, peerID.displayName)
-        
         // If error is not nil something went wrong
         if (error != nil) {
-            NSLog("Error [%@] receiving resource from %@ ", error!, peerID.displayName)
+            NSLog("%@ Error %@ from [%@]", __FUNCTION__, error!, peerID.displayName)
         }
         else {
-            // No error so this is a completed transfer. The resources is located in a temporary location and should be copied to a permenant location immediately.
-            // Write to documents directory
-            let paths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
-            let copyPath = NSString(format: "%@/%@", paths.first!, resourceName)
-            
-            do {
-                try NSFileManager.defaultManager().copyItemAtPath(localURL.path!, toPath: copyPath as String)
-                // Get a URL for the path we just copied the resource to
-                let url = NSURL(fileURLWithPath: copyPath as String)
-                NSLog("url=%@", url)
-            }
-            catch _ {
-                print(error?.localizedDescription)
-            }
+            NSLog("%@ %@ from [%@]", __FUNCTION__, resourceName, peerID.displayName)
         }
     }
 
     // Streaming API not utilized in this sample code
     func session(session: MCSession, didReceiveStream stream: NSInputStream, withName streamName: String, fromPeer peerID: MCPeerID) {
-        NSLog("didReceiveStream %@ from %@", streamName, peerID.displayName)
+        NSLog("%@ %@ from [%@]", __FUNCTION__, streamName, peerID.displayName)
     }
 
     // MARK: MCNearbyServiceBrowserDelegate protocol conformance

    func browser(browser: MCNearbyServiceBrowser, foundPeer peerID: MCPeerID, withDiscoveryInfo info: [String : String]?) {
        let remotePeerName = peerID.displayName
        
        NSLog("Browser found %@", remotePeerName)
        
        if let myPeerID = session?.myPeerID {
        
            let shouldInvite = (myPeerID.displayName.compare(remotePeerName) == .OrderedDescending)
            
            if (shouldInvite) {
                NSLog("Inviting %@", remotePeerName)
                browser.invitePeer(peerID, toSession: session!, withContext: nil, timeout: 30.0)
            }
            else {
                NSLog("Not inviting %@", remotePeerName)
            }
        }
        
        delegate?.sessionDidChangeState()
    }
    
    func browser(browser: MCNearbyServiceBrowser, lostPeer peerID: MCPeerID) {
        NSLog("lostPeer %@", peerID.displayName)
        
        connectingPeersOrderedSet.removeObject(peerID)
        disconnectedPeersOrderedSet.addObject(peerID)
        
        delegate?.sessionDidChangeState()
    }

    func browser(browser: MCNearbyServiceBrowser, didNotStartBrowsingForPeers error: NSError) {
        NSLog("didNotStartBrowsingForPeers: %@", error)
    }

    // MARK: MCNearbyServiceAdvertiserDelegate protocol conformance

    func advertiser(advertiser: MCNearbyServiceAdvertiser, didReceiveInvitationFromPeer peerID: MCPeerID, withContext context: NSData?, invitationHandler: (Bool, MCSession) -> Void) {
        NSLog("didReceiveInvitationFromPeer %@", peerID.displayName)
        
        invitationHandler(true, session!)
        
        connectingPeersOrderedSet.addObject(peerID)
        disconnectedPeersOrderedSet.removeObject(peerID)
        
        delegate?.sessionDidChangeState()
    }

    func advertiser(advertiser: MCNearbyServiceAdvertiser, didNotStartAdvertisingPeer error: NSError) {
        NSLog("didNotStartAdvertisingForPeers: %@", error)
    }

}

    }

    // MARK: MCSessionDelegate protocol conformance

    func session(session: MCSession, peer peerID: MCPeerID, didChangeState state: MCSessionState) {
        NSLog("%@ [%@] %@", __FUNCTION__, peerID.displayName, MCSession.stringForPeerConnectionState(state))

        switch state {
        case .Connecting:
            connectingPeersOrderedSet.addObject(peerID)
