     
     public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
 
-        if self.previousPage != self.currentPage {
+        if previousPage != currentPage {
 
             // If page index has changed - reset zoom scale for previous image.
-            let imageView = self.imageViews[self.previousPage]
+            let imageView = imageViews[previousPage]
             imageView.scrollView.zoomScale = imageView.scrollView.minimumZoomScale
             
             // Show Caption Label
-            self.updateCaption()
-
-        }
-        
-        self.scrollMode = .None
+            updateCaption()
+
+        }
+        
+        scrollMode = .None
 
     }
 }

        let offsetX = fabs(scrollView.contentOffset.x - self.scrollPreviewPoint.x)
        let offsetY = fabs(scrollView.contentOffset.y - self.scrollPreviewPoint.y)
        
        if self.scrollMode == .None {
            if (offsetY > offsetX) {
                self.scrollMode = .Vertical
            } else {
                self.scrollMode = .Horizontal
            }
        }
        


    public func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
        
        previousPage = currentPage
        scrollPreviewPoint = scrollView.contentOffset
        
    }

    public func scrollViewDidScroll(_ scrollView: UIScrollView) {

        if !scrollInitalized {
            generateCurrentPage()
            return
        }
        
        let imageView = imageViews[currentPage]
        if imageView.scrollView.zoomScale > 1.0 {
            generateCurrentPage()
            scrollView.isScrollEnabled = false
            return
        }
        
        if scrollMode == .Rotating {
            return
        }
        
