     }
 
     func nextChange(time: Int64) -> Int64 {
-        recursiveCount = 0
-
         let currentSession = findCurrentSession(time: time)
         if currentSession != nil {
             let nearestException = findNearest(exceptions, nil, time)

                    if exceptions != nil && !exceptions!.isEmpty {
                        let future = time + dif
                        var exDif = Int64.max

                        for i in 0 ..< exceptions!.count {
                            recursiveCount += 1
                            let ex: Session = exceptions![i]
                            if isInSession(ex, future) {
                                exDif = min(nextChange(time: time + ex.remaining(time: future)) + dif, exDif)
                            }
                        }
                        dif = min(exDif, dif)
                    }
                } else {
                    debugPrint("TimeTable", "Negative time difference: ", dif)

            }

            if currentException != nil {
                var exRemaining = currentException!.remaining(time: time)
                for exception in exceptions! {
                    if isInSession(exception, time + exRemaining) {
                        exRemaining += exception.remaining(time: time + exRemaining)
                    }
                }
                if findCurrentSession(time: time + exRemaining) != nil {
                    return exRemaining
                }
            }
        }

        return findNearest(sessions, exceptions, time)
    }

    func findNearest(_ sessions: [Session]?, _ exceptions: [Session]?, _ time: Int64) -> Int64 {
        var nearestTime = Int64.max
