             return
         }
         
-        var root = "~/Library/Application Support/Ergometer".stringByStandardizingPath
-        let errorLog = ErrorLog(root: root)
-        
         // create daily expire timer
         let calendar = NSCalendar.currentCalendar()
         let flags: NSCalendarUnit = .DayCalendarUnit | .MonthCalendarUnit | .YearCalendarUnit | .HourCalendarUnit
-        var date = NSDate()
-        let components = calendar.components(flags, fromDate: date)
+        let nowDate = NSDate()
+        let components = calendar.components(flags, fromDate: nowDate)
         let expireHour = 4
+        var expireDate = nowDate
         if components.hour >= expireHour {
-            date = calendar.dateByAddingUnit(.DayCalendarUnit, value: 1, toDate: date, options: NSCalendarOptions())!
-        }
-        date = calendar.dateBySettingHour(expireHour, minute: 0, second: 0, ofDate: date, options: NSCalendarOptions())!
-        
-        var expireOffset = date.timeIntervalSince1970
+            expireDate = calendar.dateByAddingUnit(.DayCalendarUnit, value: 1, toDate: expireDate, options: NSCalendarOptions())!
+        }
+        expireDate = calendar.dateBySettingHour(expireHour, minute: 0, second: 0, ofDate: expireDate, options: NSCalendarOptions())!
+        
+        let expireOffset = expireDate.timeIntervalSince1970 - nowDate.timeIntervalSince1970
+        errorLog?.info("expire in \(expireOffset)s")
         NSTimer.scheduledTimerWithTimeInterval(
             expireOffset, target: self, selector: "createExpireTimer", userInfo: nil, repeats: false)
         
-        app = App(clock: systemClock, makeFile: makeSystemFile, root: root, errorLog: errorLog)
+        app = App(clock: systemClock, makeFile: makeSystemFile, root: root!, errorLog: errorLog!)
         tick()
         let mask : NSEventMask =
             .KeyDownMask |

        let now = clock()
        let resting = isResting(now)
        let assumedLastActed = resting ? lastActed : now
        let errorStatusStrings = errorLog.count > 0 ? [red("\(errorLog.count)")] : []
        
        let restStatuses = map(meters) { $0.rest(assumedLastActed, now: now) }.filter { $0 > 0 }
        let ticking = !restStatuses.isEmpty
        let restStatusStrings = resting && ticking ? [redUnlessPositive(minElement(restStatuses))] : []
        
        let meterStatuses = map(meters) { $0.status(assumedLastActed) }
        let shouldStop = any(meterStatuses.map { $0 < 0 })
        let meterStatusStrings = meterStatuses.map(redUnlessPositive)
        
        let statusBuffer = NSMutableAttributedString()
        let statusStrings = errorStatusStrings + restStatusStrings + meterStatusStrings
        for (i, s) in enumerate(statusStrings) {
            if i > 0 {
                statusBuffer.appendAttributedString(NSAttributedString(string: "  "))
            }
            statusBuffer.appendAttributedString(s)
        }
        
        if shouldStop && !resting {

    let name: String
    let actionCost: Double
    let firstActed: Double?
    let timeCosts: [String:Double]
    
    init(name: String, actionCost: Double, firstActed: Double?, timeCosts: [String:Double]) {
        self.name = name
        self.actionCost = actionCost
        self.firstActed = firstActed
        self.timeCosts = timeCosts
    }
    
    func copyTo(m: Meter) {
        m.actionCost = actionCost
        m.firstActed = firstActed
        m.timeCosts = timeCosts
    }
}

func parseMeterState(j: JSON) -> MeterState? {
    if let n = j["name"].string {
        if let ac = j["actionCost"].double {
            if let tc = j["timeCosts"].dictionary {
                var timeCosts = [String:Double]()
                for (key: String, subJson: JSON) in tc {
                    timeCosts[key] = subJson.doubleValue
                }
                return MeterState(name: n, actionCost: ac, firstActed: j["firstActed"].double, timeCosts: timeCosts)
            }
        }
    }
    return nil
