long lastActualSeen = startTime;
long earliestLegalStart = startTime;
  private Task translateLevel2Task(Task level2Task,                                   Collection relevantL6Tasks) {    Task doneLevel2Task = null;    long endTime = getTaskUtils().getEndTime(level2Task);    long startTime = getTaskUtils().getStartTime(level2Task);    long lastActualSeen = startTime;    Long custLastActual = (Long) endTimeMap.get(getTaskUtils().getCustomer(level2Task));    if (custLastActual != null) {      lastActualSeen = custLastActual.longValue();    }    boolean alreadyDisposed = false;    double expL2BaseRate = 0;    PlanElement pe = level2Task.getPlanElement();    if (pe != null) {      if (pe instanceof Expansion) {        Expansion exp = (Expansion) pe;        Enumeration subtasks = exp.getWorkflow().getTasks();        while (subtasks.hasMoreElements()) {          Task subtask = (Task) subtasks.nextElement();          expL2BaseRate += getBaseUnitPerSecond(getTaskUtils().getRate(subtask));        }      } else if (pe instanceof Disposition) {        alreadyDisposed = true;      }    }    if (lastActualSeen >= endTime) {      doneLevel2Task = level2Task;    } else {      long countedStartTime = Math.max(startTime, lastActualSeen);      double totalL6BaseQty = deriveTotalQty(countedStartTime, endTime, relevantL6Tasks);      Rate origL2Rate = getTaskUtils().getRate(level2Task);      double origL2BaseQty = deriveTotalQty(countedStartTime, endTime, level2Task);//      double toleranceFactor = 0.10;  // for ammo within 200 lbs      if ((origL2BaseQty - totalL6BaseQty) < toleranceFactor) {        if(((totalL6BaseQty - origL2BaseQty) > 2.0) &&	   logger.isDebugEnabled()){          logger.debug("level2Task " + level2Task + " has a total qty of " + origL2BaseQty +                      " which is exceeded by the level 6 tasks with a summed total qty of " + totalL6BaseQty);        }	//If already disposed we still want to redispose in case there has been a qty change        doneLevel2Task = level2Task;      } else {        double durationMillis = (endTime - countedStartTime);        double durationSecs = (durationMillis / 1000);        double newL2BaseRate = ((origL2BaseQty - totalL6BaseQty) / durationSecs);        if (newL2BaseRate != expL2BaseRate) {          double origL2BaseRate = getBaseUnitPerSecond(origL2Rate);          if (logger.isDebugEnabled()) {            logger.debug("Level2Expander:Original Rate per day:" + (origL2BaseRate * TimeUtils.SEC_PER_DAY) +                         ".  Changing expanded rate from " + (expL2BaseRate * TimeUtils.SEC_PER_DAY) +                         " to " + (newL2BaseRate * TimeUtils.SEC_PER_DAY));            logger.debug("     and L2 Start time is " + new Date(startTime) + " and end time is " + new Date(endTime) + ", but last actual seen is " + new Date(lastActualSeen));            logger.debug("  and also origL2BaseQty:" + origL2BaseQty + " totalL6BaseQty:" + totalL6BaseQty);          }          Rate newL2Rate = newRateFromUnitPerSecond(origL2Rate, newL2BaseRate);          expandLevel2Task(level2Task, newL2Rate, lastActualSeen);        }      }    }    return doneLevel2Task;  }