anchor.diff:              start_worker(Source, Workload, {Max, NewWorking, Rest})
       end.
   
  -%% actual worker functions
  +%% @doc initialize the worker.
   -spec init_worker(pid_groups:groupname(), job()) -> {ok, pid()}.
   init_worker(DHTNodeGroup, Workload) ->
       Pid = spawn_link(?MODULE, work, [DHTNodeGroup, Workload]),
       {ok, Pid}.
   
  -%% do the actual work
  +%% @doc do the actual work.
  +%%      executes Job and returns results to the local wpool. wpool associates
  +%%      the worker pid to the jobs client and knows where the results go.
   -spec work(pid_groups:groupname(), job()) -> ok.
   work(DHTNodeGroup, {_Round, map, {erlanon, FunBin}, Data}) ->
       %% ?TRACE("worker: should apply ~p to ~p~n", [FunBin, Data]),
  
positive.code: work(DHTNodeGroup, {_Round, map, {jsanon, FunBin}, Data}) ->
      %% ?TRACE("worker: should apply ~p to ~p~n", [FunBin, Data]),
      {ok, VM} = js_driver:new(),
      return(DHTNodeGroup, lists:flatten([apply_js(FunBin, X, VM) || X <- Data]));
  work(DHTNodeGroup, {_Round, reduce, {jsanon, FunBin}, Data}) ->
      {ok, VM} = js_driver:new(),
      return(DHTNodeGroup, apply_js(FunBin, Data, VM)).
  
  apply_erl(Fun, Data) ->
      Fun(Data).
  
  apply_js(FunBin, Data, VM) ->
      AutoJS = define_auto_js(FunBin, Data),
      {ok, Result} = js:eval(VM, AutoJS),
      Result.
  
  define_auto_js(FunBin, Args) ->
      EncodedArgs = encode_args(Args, []),
      iolist_to_binary([FunBin, "(", EncodedArgs, ")"]).
  
  encode_args([], Acc) ->
      lists:reverse(Acc);
  encode_args([H | []], Acc) ->
      encode_args([], [value_to_json(H) | Acc]);
  encode_args([H | T], Acc) ->
      encode_args(T, [[value_to_json(H), ","] | Acc]).
  
  value_to_json({Key, Value}) ->
      js_mochijson2:encode({struct, [{Key, value_to_json(Value)}]});
  value_to_json([{_, _} | _] = List) ->
      js_mochijson2:encode({struct, [{K, value_to_json(V)} || {K, V} <- List]});
  value_to_json(List) when is_list(List) ->
      js_mochijson2:encode(List);
  value_to_json(X) ->
      js_mochijson2:encode(X).
  
  %% send results back to wpool
  -spec return(pid_groups:groupname(), any()) -> ok.
  
negative.code:     ?TRACE("~200p~nwpool: unknown message~n", [Msg]),
      State.
  
  %% @doc start a worker
  %%     starts worker under the supervisor sup_wpool and also sets up a monitor. The
  %%     supvervisor does not restart the worker in case of failure. Its main purpose
  %%     is to shut workers down when scalaris is shuting down.
  %%     The monitor (between wpool and the worker) is used mainly for error
  %%     reporting. A link could also be used, but wpool would have to call
  %%     `process_flag(trap_exit, true)' for every link.
  -spec start_worker(comm:mypid(), job(), state()) -> state().
  start_worker(Source, Workload, State) ->
      Sup = pid_groups:get_my(sup_wpool),
  