these three lines could be replaced with stageToTime.getOrElseUpdate(sid, 0L)