 }
 
 public class DatePickerDialog: UIView {
-
     public typealias DatePickerCallback = (_ date: Date?) -> Void
 
-    /* Consts */
+    // MARK: - Constants
     private let kDatePickerDialogDefaultButtonHeight:       CGFloat = 50
     private let kDatePickerDialogDefaultButtonSpacerHeight: CGFloat = 1
     private let kDatePickerDialogCornerRadius:              CGFloat = 7
     private let kDatePickerDialogDoneButtonTag:             Int     = 1
 
-    /* Views */
+    // MARK: - Views
     private var dialogView:   UIView!
     private var titleLabel:   UILabel!
     public var datePicker:    UIDatePicker!
     private var cancelButton: UIButton!
     private var doneButton:   UIButton!
 
-    /* Vars */
+    // MARK: - Variables
     private var defaultDate:    Date?
     private var datePickerMode: UIDatePickerMode?
     private var callback:       DatePickerCallback?
 
-
-    /* Overrides */
-    public init() {
+    // MARK: - Dialog initialization
+    override init(frame: CGRect) {
         super.init(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: UIScreen.main.bounds.size.height))
-
         setupView()
     }
 

        self.addSubview(self.dialogView!)
    }

    /* Handle device orientation changes */
    func deviceOrientationDidChange(notification: NSNotification) {
        self.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: UIScreen.main.bounds.size.height)
        let screenSize = countScreenSize()

        self.datePicker.maximumDate = maximumDate
        self.datePicker.minimumDate = minimumDate

        /* Add dialog to main window */
        guard let appDelegate = UIApplication.shared.delegate else { fatalError() }
        guard let window = appDelegate.window else { fatalError() }
        window?.addSubview(self)
