 	}
 
 	func viewControllerAtIndex(_ index: Int) -> UIViewController? {
-		if index >= self.tabCount || index < 0 {
-			return nil
+		guard
+			let dataSource = self.dataSource,
+			index < self.tabCount && index >= 0
+			else {
+				return nil
 		}
 
 		if (self.contents[index] as UIViewController?) == nil {
 			var viewController: UIViewController
 
-			if self.dataSource!.responds(to: #selector(PagerDataSource.controllerForTabAtIndex(_: pager:))) {
-				viewController = self.dataSource.controllerForTabAtIndex!(index, pager: self)
-			} else if self.dataSource!.responds(to: #selector(PagerDataSource.viewForTabAtIndex(_: pager:))) {
-
-				let view: UIView = self.dataSource.viewForTabAtIndex!(index, pager: self)
+			if dataSource.responds(to: #selector(PagerDataSource.controllerForTabAtIndex(_: pager:))) {
+				viewController = dataSource.controllerForTabAtIndex!(index, pager: self)
+			} else if dataSource.responds(to: #selector(PagerDataSource.viewForTabAtIndex(_: pager:))) {
+
+				let view: UIView = dataSource.viewForTabAtIndex!(index, pager: self)
 
 				// Adjust view's bounds to match the pageView's bounds
 				let pageView: UIView = self.view.viewWithTag(34)!



	func tabViewAtIndex(_ index: Int) -> TabView? {
		if index >= self.tabCount {
			return nil
		}

		if (self.tabs[index] as UIView?) == nil {

			var tabViewContent = UIView()
			if let tab = self.dataSource.tabViewForIndex?(index, pager: self) {
				tabViewContent = tab
			} else {
				tabViewContent = tabViews[index]

		self.underlineStroke.removeFromSuperview()

		// Get tabCount from dataSource
		
		if let dataSource = self.dataSource,
			let num = dataSource.numberOfTabs?(self) {
			self.tabCount = num
		} else {
			self.tabCount = tabControllers.count
