 			})
 	}
 
+    /**
+     Goes to the previous view controller respecting the presentingViewController first then the navigation stack
+     */
 	public func goBack() {
-		if let nav = self.navigationController {
+        if let vc = self.presentingViewController {
+            vc.dismissViewControllerAnimated(true, completion: nil)
+        } else if let nav = self.navigationController {
 			nav.popViewControllerAnimated(true)
-		} else if let vc = self.presentingViewController {
-			vc.dismissViewControllerAnimated(true, completion: nil)
 		}
 	}
 }
+
+//MARK: Foundation Extensions
+
+public extension String {
+    public func firstCharacterUpperCase() -> String {
+        let lowercaseString = self.lowercaseString
+
+        return lowercaseString.stringByReplacingCharactersInRange(lowercaseString.startIndex...lowercaseString.startIndex, withString: String(lowercaseString[lowercaseString.startIndex]).uppercaseString)
+    }
+}


import Foundation

public extension UIButton {
	override public func intrinsicContentSize() -> CGSize {
		let intrinsicContentSize = super.intrinsicContentSize()
		let adjustedWidth = intrinsicContentSize.width + titleEdgeInsets.left + titleEdgeInsets.right
		let adjustedHeight = intrinsicContentSize.height + titleEdgeInsets.top + titleEdgeInsets.bottom
		return CGSize(width: adjustedWidth, height: adjustedHeight)
	}
    
    public func setBackgroundColor(color: UIColor, forState: UIControlState) {
        UIGraphicsBeginImageContext(CGSize(width: 1, height: 1))
        CGContextSetFillColorWithColor(UIGraphicsGetCurrentContext(), color.CGColor)
        CGContextFillRect(UIGraphicsGetCurrentContext(), CGRect(x: 0, y: 0, width: 1, height: 1))

        
        self.setBackgroundImage(colorImage, forState: forState)
    }

}

public extension UIViewController {

	/**
     Displays an error alert to the user.

     - parameter message: The error message to display in the alert.
     */
	public func showError(message: String) {
		showAlert("Error", message: message)
	}

    /**
     Displays a success alert to the user.

     - parameter message: The success message to display in the alert.
     */
	public func showSuccess(message: String) {
		showAlert("Success", message: message)
	}

    /**
     Displays alert to user.

     - parameter title:   The title of the alert.
     - parameter message: The message to place in the alert.
     */
		let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert)
		alert.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: nil))
		self.presentViewController(alert, animated: true, completion: nil)
	}

    /**
     Handles a network response object and executes a callback on success

     - parameter response:          The unserialized response object
     - parameter error:             Pass in an error to be displayed in a UIAlert
     - parameter successCompletion: Called when response['success'] == true
     */
	public func handleResponse(response: AnyObject?, error: NSError?, successCompletion: AnyObject -> Void) {
		handleResponse(response, error: error, successCompletion: successCompletion, errorCompletion: nil)
	}

    /**
     Handles a network response object and executes a callback on success/error

     - parameter response:          The unserialized response object
     - parameter error:             Pass in an error to be displayed in a UIAlert
     - parameter successCompletion: Called when response['success'] == true
     - parameter errorCompletion:   Called when response['success'] is a String or error != nil
     */
	public func handleResponse(response: AnyObject?, error: NSError?, successCompletion: (AnyObject -> Void)? = nil, errorCompletion: (String -> Void)? = nil) {
		dispatch_async(dispatch_get_main_queue(), { () -> Void in
				if let error = error {
