anchor.diff:      pushy_node_state:rehab(NodeRef),
       State.
   
  -finish_all_nodes(#state{job = Job, job_nodes = JobNodes} = State) ->
  -    JobNodes2 = dict:map(fun(_, OldNodeState) ->
  -        JobStatus = Job#pushy_job.status,
  -        OldNodeStatus = OldNodeState#pushy_job_node.status,
  -        NewPushyJobNode = case {JobStatus, terminalize(OldNodeStatus)} of
  -            {_, new}         -> OldNodeState#pushy_job_node{status = unavailable};
  -            {voting, ready}  -> OldNodeState#pushy_job_node{status = was_ready};
  -            {running, ready} -> OldNodeState#pushy_job_node{status = aborted};
  -            {_, running}     -> OldNodeState#pushy_job_node{status = aborted};
  -            {_, terminal}    -> OldNodeState
  -        end,
  -        pushy_sql:update_job_node(NewPushyJobNode),
  -        pushy_node_state:rehab({NewPushyJobNode#pushy_job_node.org_id,
  -                                NewPushyJobNode#pushy_job_node.node_name}),
  -        NewPushyJobNode
  +send_matching_to_rehab(OldNodeState, NewNodeState, #state{job_nodes = JobNodes} = State) ->
  +    JobNodes2 = dict:map(fun(_, OldPushyJobNode) ->
  +        case OldPushyJobNode#pushy_job_node.status of
  +            OldNodeState ->
  +                NewPushyJobNode = OldPushyJobNode#pushy_job_node{status = NewNodeState},
  +                pushy_sql:update_job_node(NewPushyJobNode),
  +                pushy_node_state:rehab({NewPushyJobNode#pushy_job_node.org_id,
  +                                        NewPushyJobNode#pushy_job_node.node_name}),
  +                NewPushyJobNode;
  +           _ -> OldPushyJobNode
  +        end
       end, JobNodes),
       State#state{job_nodes = JobNodes2}.
   
  
positive.code: handle_info(running_timeout, running,
          #state{job = Job, running_timeout = RunningTimeout} = State) ->
      lager:info("Timeout occurred while running job ~p after ~p milliseconds", [Job#pushy_job.id, RunningTimeout]),
      finish_job(timed_out, State);
  handle_info(Info, StateName, State) ->
      lager:error("Unknown message handle_info(~p)", [Info]),
      {next_state, StateName, State}.
  
negative.code: 
  finish_job(Reason, #state{job = Job} = State) ->
      lager:info("Job ~p -> ~p", [Job#pushy_job.id, Reason]),
      Job2 = Job#pushy_job{status = Reason},
      State2 = State#state{job = Job2},
      pushy_object:update_object(update_job, Job2, Job2#pushy_job.id),
      {stop, {shutdown, Reason}, State2}.
  
  count_nodes_in_state(NodeStates, #state{job_nodes = JobNodes}) ->
      dict:fold(
  