                 })
             }
             else {
+                waterwheel.setIsLoggedIn(false)
                 completionHandler(success: false, response: response, json: nil, error: response.result.error)
             }
     }
 }
 
+
+
 /**
  Logout a user
- - parameter completionHandler: A completion handler that your delegate method should call if you want the response.
-
+
+ - parameter completionHandler: A completion handler that your delegate method should call if you want the response.
 
  */
 
 public func logout(completionHandler:stringcompletion) {
+    if waterwheelManager.sharedInstance.signRequestsBasic  {
+        waterwheelManager.sharedInstance.basicUsername = ""
+        waterwheelManager.sharedInstance.basicPassword = ""
+        waterwheelManager.sharedInstance.signRequestsBasic = false
+        return
+    }
     let urlString = waterwheelManager.sharedInstance.URL + "/user/logout"
     Alamofire.request(.GET, urlString)
         .validate(statusCode: 200..<300)
-        .responseJSON { response in
+        .responseString { response in
             if (response.result.error == nil) {
-                debugPrint("HTTP Response Body: \(response.data)")
+                waterwheelManager.sharedInstance.CSRFToken = ""
+                waterwheelManager.sharedInstance.signCSRFToken = false
+                completionHandler(success: true, response: response, json: nil, error: response.result.error)
             }
             else {
-                debugPrint("HTTP Request failed: \(response.result.error)")
-            }
-    }
-
-}
-
-
-public func getCSRFToken(completionHandler:stringcompletion) {
+                completionHandler(success: false, response: response, json: nil, error: response.result.error)
+            }
+    }
+
+}
+
+/**
+ 
+ Private function to get the CSRF Token
+ 
+ */
+private func getCSRFToken(completionHandler:stringcompletion) {
     let urlString = waterwheelManager.sharedInstance.URL + "/rest/session/token"
     Alamofire.request(.GET, urlString)
         .validate(statusCode: 200..<300)

public typealias stringcompletion = (success:Bool, response:Response<String, NSError>?, json:SwiftyJSON.JSON?, error:NSError!) -> Void
public typealias paramType = [String: AnyObject]?

/**
 Responsible for storing state and variables for waterwheel.
 */

    }
}

/**
 Sends a GET Entity request to Drupal

