     transformRowData: (id, keytype, transform) ->
       @setRowData id, keytype, (transform (@getRowData id, keytype))
 
-    DEFAULT_LOGGING = true
-    DEFAULT_DISPLAY = true
     isLogging: () ->
-      (@api.getData "isLogging") ? DEFAULT_LOGGING
-
-    shouldDisplayTime: () ->
-      (@api.getData "display") ? DEFAULT_DISPLAY
+      @api.getData "isLogging", true
 
     toggleLogging: () ->
-      @logger.info "Turning logging #{if (do @isLogging) then "off" else "on"}"
-      if do @isLogging
+      isLogging = do @isLogging
+      @logger.info "Turning logging #{if isLogging then "off" else "on"}"
+      if isLogging
         @onRowChange @api.cursor.row, null # Final close
       else
         @onRowChange null, @api.cursor.row # Initial setup
-      @api.setData "isLogging", not (do @isLogging)
+      @api.setData "isLogging", (not isLogging)
       do @api.view.render
 
+    shouldDisplayTime: () ->
+      @api.getData "display", true
+
     toggleDisplay: () ->
-      @logger.info "Turning display #{if (do @shouldDisplayTime) then "off" else "on"}"
-      @api.setData "display", not (do @shouldDisplayTime)
+      shouldDisplay = do @shouldDisplayTime
+      @logger.info "Turning display #{if shouldDisplay then "off" else "on"}"
+      @api.setData "display", (not shouldDisplay)
       do @api.view.render
-
-    _date: (timestamp) ->
-      "#{timestamp.getFullYear()}-#{timestamp.getMonth()}-#{timestamp.getDate()}"
-
-    dateOf: (timestamp) ->
-      day = new Date(timestamp)
-      day.setHours 0
-      day.setMinutes 0
-      day.setSeconds 0
-      day.setMilliseconds 0
-      day
-
-    # Return one timestamp on each day between the two timetamps, inclusive
-    daysBetween: (start, stop) ->
-      cur = @dateOf start
-      days = []
-      while cur < stop
-        days.push (new Date cur)
-        cur.setDay (cur.getDay() + 1)
-      days
 
     onRowChange: (from, to) ->
       @logger.debug "Switching from row #{from?.id} to row #{to?.id}"

        for ancestor_id in @api.view.data.allAncestors event.id, { inclusive: false }
          @_rebuildTreeTimes ancestor_id

    rowTime: (row, range) ->
      if range?
        times = @getRowData row.id, "treeDailyTime"
        time = 0
        for date in @daysBetween range.start, range.stop
          time += times[@_date date] ? 0
        time
      else
        @getRowData row.id, "treeTotalTime"

    printTime: (ms) ->
      seconds = Math.floor (ms /     1000 % 60)


    onRowPeriod: (period) ->
      period.time ?= period.stop - period.start
      @_addTimeToRow period.row, period.time, period.stop
      @_addTimeToAncestors period.row, period.time, period.stop

