     func isFinished(_ time: Int64) -> Bool {
         var e: Int64!
         if cycle == 0 && end == 0 {
-            e = start + duration
+            e = start!.int64Value + duration!.int64Value
         } else if end == 0 {
             e = Int64.max
         } else {
-            e = end
+            e = end as! Int64
         }
 
         return time >= e

    func isInPeriod(_ time: Int64) -> Bool {
        return time >= start!.int64Value && !isFinished(time)
    }
}

                var t: Int64!

                if session.cycle!.int64Value <= 0 {
                    s = session.start!.int64Value
                    t = time
                } else {
                    s = session.start!.int64Value % session.cycle!.int64Value
                    t = time % session.cycle!.int64Value
                }

