anchor.diff:                    end
             end, dict:new(), AllRawTasks),
   
  -    PreRebalanceTasks0 = dict:fold(fun ({xdcr, _}, _, Acc) -> Acc;
  -                                       (Signature, Value, Acc) ->
  -                                           Value1 = task_operation(finalize, Signature, Value),
  -                                           FinalValue = task_maybe_add_cancel_uri(Signature, Value1, PoolId),
  -                                           [FinalValue | Acc]
  -                                   end, [], TasksDict),
  +    CompactionAndIndexingTasks =
  +        dict:fold(fun ({xdcr, _}, _, Acc) -> Acc;
  +                      (Signature, Value, Acc) ->
  +                          Value1 = task_operation(finalize, Signature, Value),
  +                          FinalValue = task_maybe_add_cancel_uri(Signature, Value1, PoolId),
  +                          [FinalValue | Acc]
  +                  end, [], TasksDict),
   
       XDCRTasks = build_xdcr_tasks(TasksDict, AllRepDocs),
       SampleBucketTasks = build_sample_buckets_tasks(AllRawTasks),
       WarmupTasks = build_warmup_tasks(AllRawTasks),
  -    MaybeCollectTask = pick_latest_cluster_collect_task(AllNodeTasks),
  -
  -    PreRebalanceTasks1 = SampleBucketTasks ++ WarmupTasks ++ XDCRTasks ++ PreRebalanceTasks0 ++ MaybeCollectTask,
  -
  -    PreRebalanceTasks2 =
  +    CollectTask = pick_latest_cluster_collect_task(AllNodeTasks),
  +    RebalanceTask = build_rebalance_task(RebStatusTimeout),
  +    RecoveryTask = build_recovery_task(PoolId),
  +
  +    Tasks0 = lists:append([CompactionAndIndexingTasks, XDCRTasks,
  +                           SampleBucketTasks, WarmupTasks, CollectTask,
  +                           RebalanceTask, RecoveryTask]),
  +
  +    Tasks1 =
           lists:sort(
             fun (A, B) ->
                     TypeA = task_type(A),
  
positive.code:     {type, Type} = lists:keyfind(type, 1, Task),
      Type.
  
  task_priority(xdcr) ->
      0;
  task_priority(indexer) ->
      1;
  task_priority(bucket_compaction) ->
      2;
  task_priority(view_compaction) ->
      3;
  task_priority(_) ->
      4.
  
  task_name(Task, xdcr) ->
      proplists:get_value(id, Task);
  
negative.code:     [[{status, running} | KV] || KV <- WarmupTasks0].
  
  build_rebalance_task(Timeout) ->
      Task = do_build_rebalance_task(Timeout),
      [Task].
  
  do_build_rebalance_task(Timeout) ->
      case (catch ns_orchestrator:rebalance_progress_full(Timeout)) of
          {running, PerNode} ->
              DetailedProgress = get_detailed_progress(),
  