anchor.diff:           FunAbs ++ Global,NextTupleVar,false);
   
   % order
  -flwor(Ctx, [{order_by,_Id,Exprs}|T], RetId, Return, Internal, 
  +flwor(Ctx, [{order_by,Id,_} = F|T], RetId, Return, Internal, 
         Global,TupleVar,_Inline) ->
      NextTupleVar = {var,?L,next_var_tuple_name()},
  -   VarTup = get_variable_tuple(Ctx),
  -   OFun = fun({order,Expr,{modifier,Dir,{_,Empty},{_,_Collation}}},Acc) ->
  -                E1 = expr_do(Ctx, Expr),
  -                ?P("[{fun(_@VarTup) -> xqerl_seq3:singleton_value(_@E1) end,
  -                      '@Dir@','@Empty@'}|_@Acc]")
  -          end,
  -   Funs = lists:foldr(OFun, {nil,?L}, alist(Exprs)),
  -   Flat = ?P("xqerl_seq3:flatten(_@TupleVar)"),
  -   Clause = ?P("xqerl_flwor:orderbyclause(_@Flat,_@Funs)"),
  -   Match = ?P("_@NextTupleVar = _@Clause"),
  -   NewInternal = Internal ++ [Match],
  -   NewCtx = set_variable_tuple_name(Ctx, NextTupleVar),
  -   flwor(NewCtx, T, RetId, Return, NewInternal, Global, NextTupleVar, false).
  +   CurrContext = {var,?L,get_context_variable_name(Ctx)},
  +   ThisFun = glob_fun_name({order_by,Id}),
  +   {NewCtx,FunAbs} = order_part(Ctx, F),
  +   Call2 = [?P("_@NextTupleVar = '@ThisFun@'(_@CurrContext,xqerl_seq3:flatten(_@TupleVar))")],
  +   NewInternal = Internal ++ Call2,
  +   NewCtx1 = set_variable_tuple_name(NewCtx, NextTupleVar),
  +   flwor(NewCtx1, T, RetId, Return, NewInternal, 
  +         FunAbs ++ Global,NextTupleVar,false).
   
   return_part(Ctx,{Id, Expr},IsList) ->
      FunctionName = glob_fun_name({return,Id}),
      OldVariableTupleMatch = get_variable_tuple(Ctx),
  -   LocCtx = set_context_variable_name(Ctx, 'Ctx'),
  +   LocCtx = set_context_variable_name(Ctx, '__Ctx'),
      %InLine = attribute(compile, {inline,{FunctionName,2}}),
      E1 = expr_do(LocCtx,Expr),
      %?dbg("Expr",Expr),
  
positive.code:                    body = _}, Map) ->
     _ = init_mod_scan(),
     ok = set_globals(Prolog, Map),
     DefElNs     = xqerl_static:pro_def_elem_ns(Prolog),
     %ContextItem = xqerl_static:pro_context_item(Prolog,main),
     Namespaces  = xqerl_static:pro_namespaces(Prolog,[],DefElNs),
  
negative.code:    E5 = if E0 == [undefined] -> {nil,?L};
             true ->
                expr_do(Ctx,E0)
          end,
     ?P(["#xqElementNode{name = _@E1, children = [], attributes = _@E2,",
         " inscope_ns = _@IsNs@, type = _@E3, base_uri = _@E4, expr = _@E5}"]).
  
  abs_attribute_node(Ctx, #xqAttributeNode{name = N, expr = E}) ->
     _ = add_used_record_type(xqAttributeNode),
     E1 = case N of
             #qname{namespace = _Ns, prefix = Px} ->
                if Px == <<>> ->
  