anchor.diff:  						 true ->
   						     {true, []};
   						 _ -> 
  -						     false
  +						     false   %% macro names are not replaceable by variables.
   					     end;
  -					 _ -> {true, []}  %%??
  +					 _ -> {true, [{Expr1, Expr2}]}  
   				     end;
   				 operator -> case refac_syntax:operator_name(Expr1) == refac_syntax:operator_name(Expr2) of 
   						 true -> {true, []};
  
positive.code:     ExprSize = no_of_nodes(Expr1),
      case Res of 
  	{true, Subst} -> 
  	    Score = 1 -(no_of_nodes(Subst)/ExprSize),
  	    case Score>=?SimiScore of 
  		true ->
  		    [{get_start_end_loc(Expr2), no_of_nodes(Subst), Subst}];
  		_ -> []
  	    end;
  	_ -> []
  
negative.code: 		 end;
  	     _ -> case refac_syntax:type(Exp) of 
  		      match_expr -> false;
  		      _ -> case refac_util:is_pattern(Exp) of 
  			       true -> false;
  			       _ -> true
  			   end				    
  		  end
  	 end,
     %% Exp_Free_Vars = refac_util:get_free_vars(Exp),
      Exp_Export_Vars =refac_util:get_var_exports(Exp),
      Res1 andalso (Exp_Export_Vars ==[]). %%andalso (Exp_Free_Vars==[]).  %% here, we don't generalise over expressions containing free vars; or should we?
  
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  generalise_expr(Exprs, SearchRes) when is_list(Exprs)->
      generalise_expr_1(refac_syntax:block_expr(Exprs), SearchRes, refac_util:get_free_vars(Exprs));
  generalise_expr(Expr, SearchRes) ->
      generalise_expr_1(Expr, SearchRes, refac_util:get_free_vars(Expr)).
      
  generalise_expr_1(Expr, SearchRes, ExprFreeVars) ->
      Subst = lists:flatmap(fun({_, Es, _Expr2}) ->Es end, SearchRes),
      GroupedSubst = group_by_expr(Subst),
      case GroupedSubst of 
  	[] -> Expr;
  	_ ->
  	    start_counter_process(),
  	    {Expr1, _}= refac_util:stop_tdTP(fun do_replace_expr_with_var_1/2, Expr, {GroupedSubst, ExprFreeVars}),
  	    stop_counter_process(),
  	    Expr1
      end.
  
  
  do_replace_expr_with_var_1(Tree, {GroupedSubSt, ExprFreeVars}) ->
      case lists:keysearch(Tree, 1, GroupedSubSt) of 
  	{value, {Tree, Exprs}}  ->
  	    case refac_syntax:type(Tree) of 
  		variable ->
  		    case refac_util:get_free_vars(Tree) of 
  			[] -> {Tree, false};   %% This is a binding occurrance;
  			FVs -> 
  			    case FVs -- ExprFreeVars of 
  				[] ->  
  				    BVs = find_correspond_bound_vars(Exprs, GroupedSubSt),
  				    case BVs of 
  					[] -> {Tree, false};
  					_ ->
  					    Args = lists:usort(find_correspond_bound_vars(Exprs, GroupedSubSt)),
  					    Args1 =lists:map(fun(V) -> refac_syntax:variable(V) end, Args),
  					    NewVar = gen_new_var_name(),
  					    {refac_syntax:application(refac_syntax:variable(NewVar), Args1), true}
  				    end;
  				_ ->  
  				    Args = lists:usort([refac_syntax:variable_name(Tree)|find_correspond_bound_vars(Exprs, GroupedSubSt)]),
  				    Args1 = lists:map(fun(V) -> refac_syntax:variable(V) end, Args),
  				    NewVar = gen_new_var_name(),
  				    {refac_syntax:application(refac_syntax:variable(NewVar), Args1), true}
  			    end
  		    end;
  		_ -> BVs = find_correspond_bound_vars(Exprs, GroupedSubSt), 
  		     {FreeBVs, _} = lists:unzip(refac_util:get_free_vars(Tree)-- ExprFreeVars),
  		     case BVs ++ FreeBVs of 
  			 [] -> {refac_syntax:variable(gen_new_var_name()), true};
  			 _ -> Args = lists:map(fun(V)->refac_syntax:variable(V) end, lists:usort(BVs++FreeBVs)),
  			      NewVar = gen_new_var_name(),
  			      {refac_syntax:application(refac_syntax:variable(NewVar), Args), true}
  		     end
  	    end;
  	_ -> {Tree, false}
      end.
  
  
  find_correspond_bound_vars(Exprs, Subst) ->
      BVsInExprs =lists:usort(lists:flatmap(fun({E, FVsInSimExpr}) ->
  						  refac_util:get_free_vars(E)--FVsInSimExpr
  					  end, Exprs)),
      lists:flatmap(fun({E1, Es}) ->
  		      case refac_syntax:type(E1) of 
  			  variable -> case refac_util:is_pattern(E1) of 
  					  true -> 
  					      {Es1,_} = lists:unzip(Es),
  					      Bds=lists:flatmap(fun(E) ->
  								  refac_util:get_bound_vars(E) end, Es1),
  					      case BVsInExprs -- Bds =/= BVsInExprs of 
  						  true -> [refac_syntax:variable_name(E1)];
  						  _ -> []
  					      end;					      
  					  _  -> []
  				      end;					  
  			  _ -> []
  		      end
  		  end, Subst).
  
  		      
  		      
  		 
  
  gen_new_var_name() -> 
      counter ! {self(), next},
      receive
  	{counter, V} ->
  	     V
      end.
  
  
  start_counter_process() ->               
      Pid = spawn_link(fun() -> counter_loop(1) end),
      register(counter, Pid).          
  
  stop_counter_process() ->
      counter!stop.
  
  counter_loop(SuffixNum) ->
      receive
  	{From, next} ->
  	    From ! {counter, "NewVar_"++integer_to_list(SuffixNum)},
  	    counter_loop(SuffixNum+1);
  	stop ->
  	    ok
      end.
  
  group_by_expr(Subst) ->
      SortedSubst=lists:sort(fun({Expr1,_}, {Expr2,_}) ->
  				   {S1, E1} = get_start_end_loc(Expr1),
  				   {S2, E2} = get_start_end_loc(Expr2),
  				   (S1 < S2) orelse ((S1==S2) andalso (E2=<E1))
  			   end, Subst),
      group_by_expr_1(SortedSubst).
  group_by_expr_1([]) ->
       [];
  group_by_expr_1(SubstList=[E|Es]) ->
      Expr = element(1,E),
      {SLoc, ELoc} = get_start_end_loc(Expr),
      case {SLoc, ELoc} of 
  	{{0,0},{0,0}} ->
  	    [E|group_by_expr_1(Es)];
  	_ ->
  	    {SubstList1, SubstList2} = lists:splitwith(fun(S) ->
  							       {SLoc1, ELoc1} = get_start_end_loc(element(1, S)),
  							       (SLoc =< SLoc1) andalso (ELoc1=<ELoc)
  						       end, SubstList),
  	    {_, Exprs} = lists:unzip(SubstList1),
  	    [{Expr, Exprs}| group_by_expr_1(SubstList2)]
      end.    
       
  format_exprs(Exprs) when is_list(Exprs) andalso (length(Exprs) >1) ->
      refac_prettypr:format(refac_syntax:block_expr(Exprs));
  format_exprs(Exprs) when is_list(Exprs) ->
  