@Override
 public void removeTask(LocalTask task) {
   if (task.isDefault()) return;
   if (myActiveTask.equals(task)) {
     activateTask(myTasks.get(LocalTaskImpl.DEFAULT_TASK_ID), true);
   }
   myTasks.remove(task.getId());
   myDispatcher.getMulticaster().taskRemoved(task);
   myContextManager.removeContext(task);
 }
 @Override
 public LocalTask put(String key, LocalTask task) {
   LocalTask result = super.put(key, task);
   if (size() > myConfig.taskHistoryLength) {
     ArrayList<LocalTask> list = new ArrayList<LocalTask>(values());
     Collections.sort(list, TASK_UPDATE_COMPARATOR);
     for (LocalTask oldest : list) {
       if (!oldest.isDefault()) {
         remove(oldest);
         break;
       }
     }
   }
   return result;
 }