     }
 
     private func addSubviews() {
-        view.addSubview(background)
-        view.addSubview(backgroundEffect)
-        view.addSubview(preview)
-        preview.outline.addSubview(scrollView)
+        view.addSubview(backgroundView)
+        view.addSubview(backgroundEffectView)
+        view.addSubview(previewView)
+        previewView.outline.addSubview(scrollView)
         scrollView.addSubview(imageView)
     }
 
     private func configureViews() {
         view.clipsToBounds = true
-        background.contentMode = .scaleAspectFill
+        backgroundView.contentMode = .scaleAspectFill
         imageView.contentMode = .center
-        preview.outline.clipsToBounds = true
-        scrollView.delegate = self
-        scrollView.maximumZoomScale = 2
-        scrollView.showsVerticalScrollIndicator = false
-        scrollView.showsHorizontalScrollIndicator = false
-        scrollView.isScrollEnabled = true
-        scrollView.contentSize = imageView.intrinsicContentSize
+        previewView.outline.clipsToBounds = true
         let rotate = CGAffineTransform(rotationAngle: CGFloat.pi / 2)
-        preview.captureButton.transform = rotate
-        preview.closeButton.transform = rotate
+        previewView.captureButton.transform = rotate
+        previewView.closeButton.transform = rotate
     }
 
     fileprivate func configureConstraints() {
         var constraints: [NSLayoutConstraint] = []
-        constraints += NSLayoutConstraint.filledInSuperview(preview)
+        constraints += NSLayoutConstraint.filledInSuperview(previewView)
         constraints += NSLayoutConstraint.filledInSuperview(scrollView)
-        constraints += NSLayoutConstraint.filledInSuperview(background)
-        constraints += NSLayoutConstraint.filledInSuperview(backgroundEffect)
+        constraints += NSLayoutConstraint.filledInSuperview(backgroundView)
+        constraints += NSLayoutConstraint.filledInSuperview(backgroundEffectView)
         NSLayoutConstraint.activate(constraints)
+        previewView.layoutIfNeeded()
     }
 
     override func viewDidLayoutSubviews() {
         super.viewDidLayoutSubviews()
+        let w: CGFloat = previewView.outline.frame.width / CGFloat(imageView.image!.cgImage!.width)
+        let h: CGFloat = previewView.outline.frame.height / CGFloat(imageView.image!.cgImage!.height)
+        let scale = max(w, h)
         imageView.sizeToFit()
-        let w = preview.outline.frame.width / imageView.frame.width
-        let h = preview.outline.frame.height / imageView.frame.height
-        let scale = max(w, h)
+        scrollView.contentSize = imageView.bounds.size
+        scrollView.contentOffset = CGPoint(x: imageView.bounds.width/2, y: imageView.bounds.height/2)
         scrollView.minimumZoomScale = scale
         scrollView.zoomScale = scrollView.minimumZoomScale
-        let o = (scrollView.contentSize.width*scale-scrollView.frame.width)/2
-        scrollView.contentInset = UIEdgeInsets(top: 0, left: -o, bottom: 0, right: o)
     }
 
     func process() -> UIImage? {

    // MARK: Lifecycle
    override func viewDidLoad() {
        super.viewDidLoad()
        preview.closeButton.tapped = { [unowned self] in
            self.dismiss()
        }
        preview.captureButton.tapped = { [unowned self] in
            self.process().flatMap {
                self.delegate?.cropViewController(self, didCropPhoto: $0, for: self.side)
            }

    func viewForZooming(in scrollView: UIScrollView) -> UIView? {
        return imageView
    }
}
