     }
 
     private var skView: SKView!
-    var umbrellaView: UmbrellaView!
-    
-    var bgColor = UIColor(red: 85.0/255.0, green: 74.0/255.0, blue: 99.0/255.0, alpha: 1)
-    var scene: RainScene?
-    
-    public var delegate: RainyRefreshControlDelegate?
-    public var thresholdValue: CGFloat = 100.0
-    
+    private var umbrellaView: UmbrellaView!
+    private var scene: RainScene?
+    private let defaultBackgroundColor = UIColor(red: 85.0/255.0, green: 74.0/255.0, blue: 99.0/255.0, alpha: 1)
+
+    // MARK: - UIView methods
+
+    required init?(coder aDecoder: NSCoder) {
+        super.init(coder: aDecoder)
+        fatalError()
+    }
+
     override init(frame: CGRect) {
         super.init(frame: frame)
         autoresizingMask = .flexibleWidth
-        backgroundColor = bgColor
-        
-        skView = SKView(frame: CGRect(x: 0, y: 0, width: frame.width, height: frame.height))
-        skView.backgroundColor = bgColor
+        backgroundColor = defaultBackgroundColor
+        skView = configureSKView()
         addSubview(skView)
-        
-        let width = skView.frame.height*0.6
-        umbrellaView = UmbrellaView(frame: CGRect(x: 0, y: 0, width: width, height: width))
-        umbrellaView.strokeColor = UIColor.white
-        umbrellaView.lineWidth = 1
-        umbrellaView.backgroundColor = UIColor.clear
+        umbrellaView = configureUmbrellaView()
         skView.addSubview(umbrellaView)
+    }
 
-        state = .normal
-    }
-    
-    required init?(coder aDecoder: NSCoder) {
-        super.init(coder: aDecoder)
-    }
-    
     override func layoutSubviews() {
         super.layoutSubviews()
-        skView.showsFPS = false
-        skView.showsNodeCount = false
-        
-        /* Sprite Kit applies additional optimizations to improve rendering performance */
-        skView.ignoresSiblingOrder = true
-        
-        scene = RainScene(size: skView.bounds.size)
-        // Configure the view.
-        scene?.backgroundColor = bgColor
-        /* Set the scale mode to scale to fit the window */
-        scene?.scaleMode = .aspectFill
-        scene?.particles.particleBirthRate = 0
+        let scene = configureRainScene()
         skView.presentScene(scene)
-        let width = thresholdValue*0.36
-        umbrellaView.frame = CGRect(x: 0, y: 0, width: width, height: width)
-        umbrellaView.center = CGPoint(x: center.x, y: skView.frame.height-thresholdValue/2)
+        self.scene = scene
+        updateUmbrellaView()
     }
-    
-    // MARK: - ScrollView Methods
-    
+
+    // MARK: - Public ScrollView methods
+
     public func refreshScrollViewDidScroll(_ scrollView: UIScrollView) {
         if state == .loading {
             UIView.beginAnimations(nil, context: nil)

            offset = min(offset, thresholdValue)
            scrollView.contentInset = UIEdgeInsetsMake(offset, 0.0, 0.0, 0.0)
            UIView.commitAnimations()
            
        } else if scrollView.isDragging {
            let loading = false
            if state == .pulling && scrollView.contentOffset.y > -thresholdValue && scrollView.contentOffset.y < 0.0 && !loading {
                state = .normal
                
            } else if state == .normal && scrollView.contentOffset.y < -thresholdValue && !loading {
                state = .pulling
            }
        }

    }
    
    public func refreshScrollViewDidEndDragging(_ scrollView: UIScrollView) {
        let loading = false
        if scrollView.contentOffset.y <= -thresholdValue && !loading {

        
    }

    // MARK: - Private configuration methods

    private func configureSKView() -> SKView {
        let skView = SKView(frame: CGRect(x: 0, y: 0, width: frame.width, height: frame.height))
        skView.backgroundColor = defaultBackgroundColor
        skView.showsFPS = false
        skView.showsNodeCount = false
        // Sprite Kit applies additional optimizations to improve rendering performance
        skView.ignoresSiblingOrder = true
        return skView
    }

    private func configureRainScene() -> RainScene {
        let scene = RainScene(size: skView.bounds.size)
        scene.backgroundColor = defaultBackgroundColor
        // Set the scale mode to scale to fit the window
        scene.scaleMode = .aspectFill
        scene.particles.particleBirthRate = 0
        return scene
    }

    private func configureUmbrellaView() -> UmbrellaView {
        let width = skView.frame.height * 0.6
        let umrellaViewFrame = CGRect(x: 0, y: 0, width: width, height: width)
        let umbrellaView = UmbrellaView(frame: umrellaViewFrame)
        umbrellaView.strokeColor = UIColor.white
        umbrellaView.lineWidth = 1
        umbrellaView.backgroundColor = UIColor.clear
        return umbrellaView
    }

    private func updateUmbrellaView() {
        let width = thresholdValue * 0.36
        umbrellaView.frame = CGRect(x: 0, y: 0, width: width, height: width)
        umbrellaView.center = CGPoint(x: center.x, y: skView.frame.height - thresholdValue / 2)
    }

}
