 //    }
     
     deinit {
+        print("Coulomb deinit")
         stopAdvertisingHost()
         stopSearchingForHosts()
         session.disconnect()
     }
     
+    func setUpSession() {
+        session = MCSession(peer: self.myPeerId, securityIdentity: nil, encryptionPreference: .Required)
+        session.delegate = self
+    }
     // MARK: Methods for host
     public func startAdvertisingHost() {
+        stopSearchingForHosts()
         self.host = myPeerId
-        if serviceAdvertiser == nil {
+        if self.serviceAdvertiser == nil {
             serviceAdvertiser = MCNearbyServiceAdvertiser(peer: myPeerId,
                                                           discoveryInfo: ["peerType": "host"], serviceType: serviceType)
-            serviceAdvertiser?.delegate = self
-        }
-        serviceAdvertiser?.startAdvertisingPeer()
+            self.serviceAdvertiser?.delegate = self
+        }
+        self.serviceAdvertiser?.startAdvertisingPeer()
     }
     
     public func stopAdvertisingHost() {
         serviceAdvertiser?.stopAdvertisingPeer()
+        serviceAdvertiser = nil
     }
     
     // MARK: Methods for guest
     public func startSearchingForHosts() {
+        stopAdvertisingHost()
         self.host = nil
         if serviceBrowser == nil {
             serviceBrowser = MCNearbyServiceBrowser(peer: myPeerId, serviceType: serviceType)

        session.delegate = self
        return session
    }()
    
    private let myPeerId: MCPeerID
    private var host: MCPeerID?
    private let serviceType: String
    
    public init(serviceType: String, myPeerId: MCPeerID) {
        self.serviceType = serviceType
        self.myPeerId = myPeerId
    }
    
//    public convenience init(serviceType: String) {

    
    public func stopSearchingForHosts() {
        serviceBrowser?.stopBrowsingForPeers()
        serviceBrowser = nil
    }
    
    public func connectToHost(host: MCPeerID, context: NSData? = nil, timeout: NSTimeInterval = defaultTimeout) {
