         for index in 0...(stackedViews.count - 1) {
             if let nLastView = lastView {
                 
-                stackedViews[index].addCustomConstraints(inView: self, toViews: [nLastView, self, self], selfAttributes: [NSLayoutAttribute.top] + hAttributes[index], relations: [NSLayoutRelation.equal] + hRelations[index], otherViewAttributes: [NSLayoutAttribute.bottom] + hAttributes[index], padding: [gapPadding] + hPadding[index])
+                let _ = stackedViews[index].addCustomConstraints(inView: self, toViews: [nLastView, self, self], selfAttributes: [NSLayoutAttribute.top] + hAttributes[index], relations: [NSLayoutRelation.equal] + hRelations[index], otherViewAttributes: [NSLayoutAttribute.bottom] + hAttributes[index], padding: [gapPadding] + hPadding[index])
                 
             } else {
-                stackedViews[index].addCustomConstraints(inView: self, toViews: topLayoutGuide == nil ? nil : [topLayoutGuide!, self, self], selfAttributes: [NSLayoutAttribute.top] + hAttributes[index], relations: [NSLayoutRelation.equal] + hRelations[index], otherViewAttributes: (topLayoutGuide == nil ?  [NSLayoutAttribute.top] : [NSLayoutAttribute.bottom]) + hAttributes[index], padding: [topPadding] + hPadding[index])
+                let _ = stackedViews[index].addCustomConstraints(inView: self, toViews: topLayoutGuide == nil ? nil : [topLayoutGuide!, self, self], selfAttributes: [NSLayoutAttribute.top] + hAttributes[index], relations: [NSLayoutRelation.equal] + hRelations[index], otherViewAttributes: (topLayoutGuide == nil ?  [NSLayoutAttribute.top] : [NSLayoutAttribute.bottom]) + hAttributes[index], padding: [topPadding] + hPadding[index])
             }
             lastView = stackedViews[index]
         }
         
         if let nLastView = lastView {
-            nLastView.addCustomConstraints(inView: self, selfAttributes: [.bottom], relations: [bottomRelation], otherViewAttributes: [.bottom], padding: [-bottomPadding])
-        }
-	}
+            let _ = nLastView.addCustomConstraints(inView: self, selfAttributes: [.bottom], relations: [bottomRelation], otherViewAttributes: [.bottom], padding: [-bottomPadding])
+        }
+    }
     
     public func stackHorizontallViews(
         _ stackedViews: [UIView],

//MARK: Initialisers

public extension UITextField {
	override class func withAutoLayout() -> UITextField {
		let field = UITextField()
		field.translatesAutoresizingMaskIntoConstraints = false
		return field
	}
}

public extension UIScrollView {
	override class func withAutoLayout() -> UIScrollView {
		let view = UIScrollView()
		view.translatesAutoresizingMaskIntoConstraints = false
		return view
	}
	
	
}

public extension UITableView {
	override class func withAutoLayout() -> UITableView {
		let view = UITableView()
		view.translatesAutoresizingMaskIntoConstraints = false
		return view
	}
	
	
}

public extension UILabel {
	override class func withAutoLayout() -> UILabel {
		let view = UILabel()
		view.translatesAutoresizingMaskIntoConstraints = false
		return view
	}
	
	public func multiLine() {
		self.numberOfLines = 0
		self.lineBreakMode = NSLineBreakMode.byWordWrapping
	}
	
	
}

public extension UIControl {
	override class func withAutoLayout() -> UIControl {
		let control = UIControl()
		control.translatesAutoresizingMaskIntoConstraints = false
		return control
	}
	
	
}


public extension UIButton {
	override class func withAutoLayout() -> UIButton {
		let control = UIButton(type: UIButtonType.custom)
		control.translatesAutoresizingMaskIntoConstraints = false
		return control
	}
}

public extension UIImageView {

    }
    
    //end vertical
    
    public func addCustomConstraints(
        inView superView: UIView,
        toViews views: [AnyObject]? = nil,
        selfAttributes: [NSLayoutAttribute],
        relations: [NSLayoutRelation]? = nil,
        otherViewAttributes: [NSLayoutAttribute]? = nil,
        multipliers: [CGFloat]? = nil,
        padding: [CGFloat]? = nil,
        priorities: [UILayoutPriority]? = nil
        )
        -> [NSLayoutConstraint]
    {
        let nRelations: [NSLayoutRelation] = self.getConstraintElements(forReferenceElement: selfAttributes, inputElements: relations, abortMessage: "The number of NSLayoutRelations provided must be the same as the number of NSLayoutAttributes for the item being constrained") { () -> [NSLayoutRelation] in
            return selfAttributes.map({_ in return NSLayoutRelation.equal})
        }
        let otherViews: [AnyObject] = self.getviews(forAttributes: selfAttributes, views: views, superView: superView)
        
        let nOtherViewAttributes: [NSLayoutAttribute] = self.getConstraintElements(forReferenceElement: selfAttributes, inputElements: otherViewAttributes, abortMessage: "The number of NSLayoutAttributes provided for the other views should be the same as for the attributes provided for the view being constrained") { () -> [NSLayoutAttribute] in
            return selfAttributes
        }
        
        let nMultipliers: [CGFloat] = self.getConstraintElements(forReferenceElement: selfAttributes, inputElements: multipliers, abortMessage: "The number of multipliers must mathc the number of attributes provided for the view being constrained") { () -> [CGFloat] in
            return selfAttributes.map({_ in 1.0})
        }
        
        let nPadding: [CGFloat] = self.getConstraintElements(forReferenceElement: selfAttributes, inputElements: padding, abortMessage: "The number of padding values provided should be the same as the ammount of attributes provided for the view being constrained") { () -> [CGFloat] in
            return selfAttributes.map({_ in return CGFloat(0.0)})
        }
        
        let nPriorities: [UILayoutPriority] = self.getConstraintElements(forReferenceElement: selfAttributes, inputElements: priorities, abortMessage: "The number of priorities should be the same as the amoutn of attributes provided for the view being constrained") { () -> [UILayoutPriority] in
            return selfAttributes.map({_ in return UILayoutPriorityRequired})
        }
        
        
        var constraints: [NSLayoutConstraint] = []
        
        for index in 0...(selfAttributes.count - 1) {
            constraints.append(NSLayoutConstraint(item: self, attribute: selfAttributes[index], relatedBy: nRelations[index], toItem: otherViews[index], attribute: nOtherViewAttributes[index], multiplier: nMultipliers[index], constant: nPadding[index], priority: nPriorities[index]))
            
            
        }
        
        superView.addConstraints(constraints)
        self.addedLayoutConstraints += constraints
        return constraints
    }
    
    func getviews(forAttributes attributes: [NSLayoutAttribute], views: [AnyObject]?, superView: UIView) -> [AnyObject]{
        if let nViews = views {
            let _ = self.validateViews(forAttributes: attributes, views: nViews)
            return nViews
        }
        else {
            return  attributes.map{_ in superView}
        }
    }
    
    func validateViews(forAttributes attributes: [NSLayoutAttribute], views: [AnyObject]) -> Bool {
        let isValid = attributes.count <= views.count
        
        for view in views {
            if !(view is UIView) && !(view is UILayoutSupport) {
                self.abortWithMessage("The items passed in must be UIViews or UILayoutSupports. The type ")
            }
        }
        if !isValid {
            self.abortWithMessage("The number of views to constrain to should equal the number of attributes provided. At the moment you have provided \(attributes.count) attributes and \(views.count) views")
        }
        return isValid
    }
    
    func getConstraintElements<T, U>(forReferenceElement referenceElements: [T], inputElements: [U]?, abortMessage: String, defaultElementsClosure: (() ->[U]) )-> [U] {
        if let inputEl = inputElements {
            let _ = self.validateElementst(referenceElements, inputElements: inputEl, abortMessage: abortMessage)
            return inputEl
        }
        else {
            return defaultElementsClosure()
        }
    }
    
    func validateElementst<T, U>(_ referenceElements: [T], inputElements: [U], abortMessage: String) -> Bool {
        let isValid: Bool = (referenceElements.count == inputElements.count)
        
        if !isValid {
            self.abortWithMessage(abortMessage)
        }
        return isValid
    }
    
    public func addDimensions(width: CGFloat? = nil, height: CGFloat? = nil, widthRelation: NSLayoutRelation = .equal, heightRelation: NSLayoutRelation = .equal) {
        if let w : CGFloat = width {
            let constraints: [NSLayoutConstraint] = [
                NSLayoutConstraint(item: self, attribute: NSLayoutAttribute.width, relatedBy: widthRelation, toItem: nil, attribute: NSLayoutAttribute.notAnAttribute, multiplier: 1.0, constant: w),
                ];
            
            self.addConstraints(constraints);
            self.addedDimensionConstraints.append(contentsOf: constraints)
        }
        if let h: CGFloat = height {
            let constraints: [NSLayoutConstraint] = [
                NSLayoutConstraint(item: self, attribute: NSLayoutAttribute.height, relatedBy: heightRelation, toItem: nil, attribute: NSLayoutAttribute.notAnAttribute, multiplier: 1.0, constant: h)
            ];
            
            self.addConstraints(constraints);
            self.addedDimensionConstraints.append(contentsOf: constraints)
        }
        
    }
    
    public func flushCurrentDimentionConstraints() {
        self.removeConstraints(self.addedDimensionConstraints)
    }
    
    func abortWithMessage(_ message: String) {
        assertionFailure(message)
    }
    
    //MARK: Helper methods
    
