anchor.diff:      end.
   
   wait_for_msg(Handler, Mote, Msg) ->
  -    wait_for_msg(Handler, Mote, 1000, Msg).
  +    wait_for_msg(Handler, Mote, handler_timeout(Handler), Msg).
   
   wait_for_msg(_, _, T, _) when T=<0 -> throw(timeout);
   wait_for_msg(Handler, Mote, T, Msg) ->
  +    StepSize = handler_step_size(Handler),
       case state() of
   	{running, _} ->
   	    case mote_read(Handler, Mote) of
   		"" ->
  -		    ok = simulation_step(Handler, ?STEP_SIZE),
  -		    wait_for_msg(Handler, Mote, T-?STEP_SIZE, Msg);
  +		    ok = simulation_step(Handler, StepSize),
  +		    wait_for_msg(Handler, Mote, T-StepSize, Msg);
   		S ->
   		    case re:run(S, "DEBUG[^\n]*\n") of
   			{match, [{_,_}]} ->
  -			    ok = simulation_step(Handler, ?STEP_SIZE),
  +			    ok = simulation_step(Handler, StepSize),
   			    %% io:format("<<~p>>~n", [S]),
  -			    wait_for_msg(Handler, Mote, T-?STEP_SIZE, Msg);
  +			    wait_for_msg(Handler, Mote, T-StepSize, Msg);
   			_ ->
   			    case re:run(S, Msg) of
   				{match, _} ->
   				    true;
   				nomatch ->
  -				    ok = simulation_step(Handler, ?STEP_SIZE),
  -				    wait_for_msg(Handler, Mote, T-?STEP_SIZE, Msg)
  +				    ok = simulation_step(Handler, StepSize),
  +				    wait_for_msg(Handler, Mote, T-StepSize, Msg)
   			    end
   		    end
   	    end;
  
positive.code:     end.
  
  wait_for_result(Handler, Mote) ->
      wait_for_result(Handler, Mote, 1000).
  
  wait_for_result(_,_,T) when T=<0 -> throw(timeout);
  wait_for_result(Handler, Mote, T) ->
      case state() of
  	{running, _} ->
  	    case mote_read(Handler, Mote) of
  		"" ->
  		    ok = simulation_step(Handler, ?STEP_SIZE),
  		    wait_for_result(Handler, Mote, T-?STEP_SIZE);
  		S ->
  		    case re:run(S, "DEBUG[^\n]*\n") of
  			{match, [{_,_}]} ->
  			    ok = simulation_step(Handler, ?STEP_SIZE),
  			    %% io:format("<<~p>>~n", [S]),
  			    wait_for_result(Handler, Mote, T-?STEP_SIZE);
  			_ ->
  			    S
  		    end
  
negative.code: %% Commands
  
  receive_answer(Handler) ->
      receive_answer(Handler, 3600000).
  
  receive_answer(_, T) when T=<0 -> 
      R = exit(),
  