diff --git a/src/lv6MainArgs.ml b/src/lv6MainArgs.ml
index 89badcc64308e58421d6fbcb49b0048997101762..bee48879131a5cd8ff8384204268774770e03ac8 100644
--- a/src/lv6MainArgs.ml
+++ b/src/lv6MainArgs.ml
@@ -1,4 +1,4 @@
-(* Time-stamp: <modified the 09/02/2015 (at 16:10) by Erwan Jahier> *)
+(* Time-stamp: <modified the 12/02/2015 (at 10:35) by Erwan Jahier> *)
 (*
 Le manager d'argument adapté de celui de lutin, plus joli
 N.B. solution un peu batarde : les options sont stockées, comme avant, dans Global,
diff --git a/src/lv6util.ml b/src/lv6util.ml
index 00615b381638623049c5972cfb66401f4cfec48c..22fb2f249f42ab562e211b8f6e069103a8239d0c 100644
--- a/src/lv6util.ml
+++ b/src/lv6util.ml
@@ -42,3 +42,10 @@ let rec pos_in_list i x l =
     | [] -> assert false (* should not occur *)
 
 let my_int_of_string = LocalGenlex.local_int_of_string
+
+let string_ends str1 str2 =
+  let l1,l2 = String.length str1, String.length str2 in
+  l1>=l2 &&
+    str2 = String.sub str1 (l1 - l2 ) l2
+
+let _ = assert (string_ends "int []" "[]")
diff --git a/src/soc.ml b/src/soc.ml
index ade7eea1c4955864e5e07062182f4c99a17f0e2b..d8156f548775fab5c1e0a8aac2f4a2dbe14957d0 100644
--- a/src/soc.ml
+++ b/src/soc.ml
@@ -1,4 +1,4 @@
-(* Time-stamp: <modified the 28/01/2015 (at 15:22) by Erwan Jahier> *)
+(* Time-stamp: <modified the 11/02/2015 (at 16:59) by Erwan Jahier> *)
 
 (** Synchronous Object Component *)
 
diff --git a/src/soc2c.ml b/src/soc2c.ml
index 973fe52ceabce94b3394026889a2971f816b37c6..df6dd3e5d81d8c8548c76d0a0aa6088ff8aef70b 100644
--- a/src/soc2c.ml
+++ b/src/soc2c.ml
@@ -1,4 +1,4 @@
-(* Time-stamp: <modified the 09/02/2015 (at 15:08) by Erwan Jahier> *)
+(* Time-stamp: <modified the 12/02/2015 (at 10:28) by Erwan Jahier> *)
 
 
 (* let put (os: out_channel) (fmt:('a, unit, string, unit) format4) : 'a = *)
@@ -69,7 +69,7 @@ let (gao2c : Soc.tbl -> 'a soc_pp -> Soc.gao -> unit) =
                else Soc2cUtil.M_IO)
             else Soc2cUtil.Local 
           in
-          let str = Soc2cUtil.gen_c_switch  (Soc2cDep.ctx_var ctx_opt id) cases in
+          let str = Soc2cUtil.gen_c_switch (Soc2cDep.ctx_var ctx_opt sp.soc id) cases in
           str
         )
         | Call(vel_out, Assign, vel_in) -> (
@@ -352,16 +352,16 @@ let io_transmit_mode () = Lv6MainArgs.global_opt.Lv6MainArgs.io_transmit_mode
 let (gen_loop_file : Soc.t -> out_channel -> Soc.tbl -> unit) =
   fun soc oc stbl -> 
     let base = (string_of_soc_key soc.key) in
-    let putc s =  output_string oc s in
+    let putc s = output_string oc s in
     let ctx = get_ctx_name soc.key in
     let step = Soc2cDep.step_name soc.key "step" in
     let (n,_,_) = soc.key in
     let n = id2s n in
     let inputs,outputs = soc.profile in
-    let inputs_io = SocVar.expand_profile true false inputs in
-    let outputs_io = SocVar.expand_profile true false  outputs in
-    let inputs = SocVar.expand_profile true true inputs in
-    let outputs = SocVar.expand_profile true true  outputs in
+    let inputs_io  =  SocVar.expand_profile true false inputs  in
+    let outputs_io =  SocVar.expand_profile true false outputs in
+    let inputs_exp = SocVar.expand_profile true true  inputs  in
+    let outputs_exp= SocVar.expand_profile true true  outputs in
     Lv6util.entete oc "/*" "*/";
     putc  ("
 #include <stdlib.h>
@@ -471,13 +471,13 @@ int main(){
   int s = 0;" ^ (
       match io_transmit_mode () with
         | Lv6MainArgs.Stack ->
-          let to_c_decl (n,t) = ((Soc2cUtil.type_to_string t "")^ " " ^n^";\n  ") in
-          let inputs_t  = List.map to_c_decl inputs_io in
-          let outputs_t = List.map to_c_decl outputs_io in
+          let to_c_decl (n,t) = ((Soc2cUtil.data_type_to_c t n)^ ";\n  ") in
+          let inputs_t  = List.map to_c_decl inputs in
+          let outputs_t = List.map to_c_decl outputs in
           let inputs_decl = Printf.sprintf "\n  %s" (String.concat "" inputs_t) in
           let outputs_decl = Printf.sprintf "%s" (String.concat "" outputs_t) in
           let ctx_decl = if SocUtils.is_memory_less soc then "" else 
-              ctx^"_type* ctx ;\n  "^ ctx^"_reset(ctx);"
+              ctx^"_type* ctx = "^ ctx^"_new_ctx(NULL);\n"
           in
           inputs_decl ^ outputs_decl ^ ctx_decl
         | Lv6MainArgs.Heap -> ("
@@ -518,35 +518,34 @@ int main(){
       in
       putc str
     ) 
-      inputs;
-    let inputs_fmt  = List.map (fun (_,t) -> type_to_format_string t) inputs in
-    let outputs_fmt = List.map (fun (_,t) -> type_to_format_string t) outputs in
+      inputs_exp;
+    let inputs_fmt  = List.map (fun (_,t) -> type_to_format_string t) inputs_io in
+    let outputs_fmt = List.map (fun (_,t) -> type_to_format_string t) outputs_io in
     if io_transmit_mode () = Lv6MainArgs.Stack 
     then
-      let i =  fst (List.split inputs_io) in
-      let o =  fst (List.split outputs_io) in
-      let o =  List.map (fun s -> "&"^s) o in      
+      let i =  fst (List.split inputs) in
+      let o = List.map (fun (n,t) -> match t with Data.Array(_,_) -> n | _ ->"&"^n) outputs in
       let io = String.concat "," (i@o) in
       let io = if SocUtils.is_memory_less soc then io else if io = "" then "ctx" else io^",ctx" in
       putc ("    " ^ step^"("^io^");
     // printf(\"" ^ (String.concat " " inputs_fmt)^ " #outs " ^ 
                (String.concat " " outputs_fmt)^ "\\n\"," ^
-               (String.concat "," (List.map (fun (id,_) -> ""^id ) (inputs@outputs)))^ 
+               (String.concat "," (List.map (fun (id,_) -> ""^id ) (inputs_exp@outputs_exp)))^ 
                ");
     printf(\"" ^ 
                (String.concat " " outputs_fmt)^ "\\n\"," ^
-               (String.concat "," (List.map (fun (id,_) -> ""^id ) (outputs)))^ 
+               (String.concat "," (List.map (fun (id,_) -> ""^id ) (outputs_exp)))^ 
                ");
   }"
     ) else (
       putc ("    " ^ step^"(ctx);
     // printf(\"" ^ (String.concat " " inputs_fmt)^ " #outs " ^ 
                (String.concat " " outputs_fmt)^ "\\n\"," ^
-               (String.concat "," (List.map (fun (id,_) -> "ctx->"^id ) (inputs@outputs)))^ 
+               (String.concat "," (List.map (fun (id,_) -> "ctx->"^id ) (inputs_exp@outputs_exp)))^ 
                ");
     printf(\"" ^ 
                (String.concat " " outputs_fmt)^ "\\n\"," ^
-             (String.concat "," (List.map (fun (id,_) -> "ctx->"^id ) (outputs)))^ 
+             (String.concat "," (List.map (fun (id,_) -> "ctx->"^id ) (outputs_exp)))^ 
              ");
   }"));
     putc "\n  return 1;
diff --git a/src/soc2cDep.mli b/src/soc2cDep.mli
index d1350f6e9b41ba0769569cdd52ea0801fa8bf915..1174af789e1e9633ad2da338f24fefd19a2b98a3 100644
--- a/src/soc2cDep.mli
+++ b/src/soc2cDep.mli
@@ -1,4 +1,4 @@
-(* Time-stamp: <modified the 06/02/2015 (at 11:07) by Erwan Jahier> *)
+(* Time-stamp: <modified the 09/02/2015 (at 16:47) by Erwan Jahier> *)
 
 
 (** Choose between the various C code generators (heap-based, Stack
@@ -27,7 +27,7 @@ val string_of_var_expr: Soc.t -> Soc.var_expr -> string
 
 
 (* [ctx_var vk id] *)
-val ctx_var : Soc2cUtil.var_kind -> Ident.t -> string
+val ctx_var : Soc2cUtil.var_kind -> Soc.t -> Ident.t -> string
   
 (*  [gen_step_call soc called_soc vel_out vel_in ctx sname step_arg]
  Generates the C code that performs the call to a step method of
diff --git a/src/soc2cHeap.ml b/src/soc2cHeap.ml
index 6c9d2224a6edc929a8c73acc24168a290068d7de..73d5287fc7a58c57e528218a8d6db92d6c8d956c 100644
--- a/src/soc2cHeap.ml
+++ b/src/soc2cHeap.ml
@@ -1,4 +1,4 @@
-(* Time-stamp: <modified the 06/02/2015 (at 16:08) by Erwan Jahier> *)
+(* Time-stamp: <modified the 11/02/2015 (at 16:19) by Erwan Jahier> *)
 
 open Soc2cUtil
 open Soc2cIdent
@@ -60,8 +60,8 @@ let (step_name : Soc.key -> string -> string) =
     let str = Printf.sprintf "%s_%s" (Soc2cIdent.get_soc_name sk) sm in
     id2s str
 
-let (ctx_var : var_kind -> Ident.t -> string) =
-  fun opt id -> 
+let (ctx_var : var_kind -> Soc.t -> Ident.t -> string) =
+  fun opt soc id -> 
     match opt with
       | ML_IO sk -> Printf.sprintf "%s_ctx.%s" (Soc2cIdent.get_soc_name sk) (id2s id)
       | M_IO  ->  Printf.sprintf "ctx->%s" (id2s id)
@@ -169,7 +169,7 @@ let (typedef_of_soc : Soc.t -> string) =
       (match soc.memory with
         | No_mem -> ""
         | Mem t -> 
-          Printf.sprintf "   /*Memory cell*/\n   %s ;\n" (id2s (Soc2cUtil.type_to_string t "_memory"))
+          Printf.sprintf "   /*Memory cell*/\n   %s ;\n" (id2s (Soc2cUtil.data_type_to_c t "_memory"))
         | Mem_hidden -> ""
       )
     in
diff --git a/src/soc2cHeap.mli b/src/soc2cHeap.mli
index bffcc930dd9f138a157f0721862def84c1188df7..19f424a78024e09a63a70d6afccbeefabeddb5e1 100644
--- a/src/soc2cHeap.mli
+++ b/src/soc2cHeap.mli
@@ -1,4 +1,4 @@
-(* Time-stamp: <modified the 06/02/2015 (at 11:07) by Erwan Jahier> *)
+(* Time-stamp: <modified the 09/02/2015 (at 16:44) by Erwan Jahier> *)
 
 (** Gathers all entities (functions, types) that implement the
     heap-based C generator.  *)
@@ -19,7 +19,7 @@ val string_of_var_expr: Soc.t -> Soc.var_expr -> string
 
 
 (* [ctx_var vk id] *)
-val ctx_var : Soc2cUtil.var_kind -> Ident.t -> string
+val ctx_var : Soc2cUtil.var_kind -> Soc.t -> Ident.t -> string
   
 (*  [gen_step_call soc called_soc vel_out vel_in ctx sname step_arg]
  Generates the C code that performs the call to a step method of
diff --git a/src/soc2cStack.ml b/src/soc2cStack.ml
index ebb2a2de58c31b9e591919a30489ec4511e31d89..a153b6c7a9fe9352fb2ca491bfd64c2db7529f5f 100644
--- a/src/soc2cStack.ml
+++ b/src/soc2cStack.ml
@@ -1,14 +1,15 @@
-(* Time-stamp: <modified the 06/02/2015 (at 15:15) by Erwan Jahier> *)
+(* Time-stamp: <modified the 12/02/2015 (at 10:01) by Erwan Jahier> *)
 
 open Soc2cUtil
 open Soc2cIdent
 open Soc
 
 
-let (mem_interface : Soc.t -> string -> bool) =
+
+let (mem_interface_out : Soc.t -> string -> bool) =
   fun soc id -> 
-    let ins,outs = soc.profile in
-    List.mem_assoc id ins || List.mem_assoc id outs
+    let _,outs = soc.profile in
+    List.mem_assoc id outs
 
 let rec (string_of_var_expr: Soc.t -> Soc.var_expr -> string) = 
   fun soc -> function
@@ -38,11 +39,16 @@ let rec (gen_assign : Data.t  -> string -> string -> string -> string) =
       | Data.Extern (id) -> 
         Printf.sprintf "  _assign_%s(&%s, &%s, sizeof(%s));\n" (id2s id) vi vo vo
 
-let (is_soc_output : Soc.var_expr -> Soc.t -> bool) =
+let rec (is_soc_output : Soc.var_expr -> Soc.t -> bool) =
   fun v soc -> 
     match v with
-      | Var(v) ->  List.mem v (snd soc.profile)
-      | _ -> false
+      | Var(v) -> List.mem v (snd soc.profile)
+      | Const(_) -> false
+      | Index(ve,_,_) 
+      | Field(ve,_,_)
+      | Slice(ve,_,_,_,_,_) -> is_soc_output ve soc
+          
+      
 
 let (gen_assign_var_expr : Soc.t -> Soc.var_expr -> Soc.var_expr -> string) =
 fun soc vi vo -> 
@@ -60,9 +66,12 @@ let (step_name : Soc.key -> string -> string) =
     let str = Printf.sprintf "%s_%s" (Soc2cIdent.get_soc_name sk) sm in
     id2s str
 
-let (ctx_var : var_kind -> Ident.t -> string) =
-  fun opt id -> 
-    Printf.sprintf "%s" (id2s id)
+let (ctx_var : var_kind -> Soc.t -> Ident.t -> string) =
+  fun opt soc id -> 
+    if mem_interface_out soc id then 
+      Printf.sprintf "*%s" (id2s id)
+    else 
+      Printf.sprintf "%s" (id2s id)
 
 let (list_split : 'a list -> int -> 'a list * 'a list) =
   fun l s ->
@@ -100,7 +109,11 @@ let (inline_soc :  Soc.t -> Soc.t -> Soc.var_expr list -> Soc.var_expr list -> s
             Lv6MainArgs.global_opt.Lv6MainArgs.gen_c_inline_predef 
             && Soc2cPredef.is_call_supported called_soc_name soc 
           then
-            let vel_in = List.map (string_of_var_expr soc) vel_in in
+            let vel_in_str = List.map (string_of_var_expr soc) vel_in in
+            let vel_in = List.map2
+              (fun v s -> if is_soc_output v soc then "*"^s else s) vel_in vel_in_str
+            in
+
             let vel_out_str = List.map (string_of_var_expr soc) vel_out in
             let vel_out = List.map2
               (fun v s -> if is_soc_output v soc then "*"^s else s) vel_out vel_out_str
@@ -114,20 +127,23 @@ let (inline_soc :  Soc.t -> Soc.t -> Soc.var_expr list -> Soc.var_expr list -> s
 (* exported *) 
 let (inlined_soc : Soc.t -> bool) =
   fun soc ->
-    let soc_name,_,_ = soc.key in 
-    soc_name = "Lustre::if" || Soc2cPredef.is_call_supported soc_name soc 
+    let soc_name,_,_ = soc.key in
+    soc_name = "Lustre::if" || Soc2cPredef.is_call_supported soc_name soc
 
 
-(* exported *) 
-let (gen_step_call : Soc.t -> Soc.t -> Soc.var_expr list -> Soc.var_expr list -> 
+(* exported *)
+let (gen_step_call : Soc.t -> Soc.t -> Soc.var_expr list -> Soc.var_expr list ->
      string -> string -> string -> string) =
-  fun soc called_soc vel_out vel_in ctx sname step_arg -> 
+  fun soc called_soc vel_out vel_in ctx sname step_arg ->
     match inline_soc soc called_soc vel_out vel_in with
       | Some str -> str
       | None ->
-        let vel_in = List.map (string_of_var_expr soc) vel_in in
+        let vel_in_str = List.map (string_of_var_expr soc) vel_in in
+        let vel_in =
+          List.map2 (fun v s -> if is_soc_output v soc then "*"^s else s) vel_in vel_in_str
+        in
         let vel_out_str = List.map (string_of_var_expr soc) vel_out in
-        let vel_out = 
+        let vel_out =
           List.map2 (fun v s -> if is_soc_output v soc then s else "&"^s) vel_out vel_out_str
         in
         let step_arg = if step_arg = "" then [] else [step_arg] in
@@ -147,7 +163,7 @@ let (typedef_of_soc : Soc.t -> string) =
       (match soc.memory with
         | No_mem -> ""
         | Mem t ->  Printf.sprintf "   /*Memory cell*/\n   %s ;\n" 
-          (id2s (Soc2cUtil.type_to_string t "_memory"))
+          (id2s (Soc2cUtil.data_type_to_c t "_memory"))
         | Mem_hidden -> ""
       )
     in
@@ -172,16 +188,22 @@ let (get_step_prototype : Soc.step_method -> Soc.t -> string * string) =
     let inputs, outputs = soc.Soc.profile in
     let inputs  = SocUtils.filter_step_params sm.Soc.idx_ins  inputs in
     let outputs = SocUtils.filter_step_params sm.Soc.idx_outs outputs in
-    let to_param (id,dt) = Soc2cUtil.type_to_string dt "",id in
-    let in_params = List.map to_param inputs in
-    let out_params = List.map to_param outputs in
-    let out_params = List.map (fun (t,id) -> t^"*",id) out_params in
-
-    let in_params_decl  = List.map fst in_params  in
-    let out_params_decl = List.map fst out_params in
-    let in_params  = List.map (fun (t,id) -> t^" "^id) in_params  in
-    let out_params = List.map (fun (t,id) -> t^" "^id) out_params in
-   
+    let to_param_decl is_an_output (id,dt) = 
+      match is_an_output, dt with
+        | true, Data.Array(_,_) (* arrays are already pointers... *)
+        | false, _ -> Soc2cUtil.data_type_to_c dt ""
+        | true,  _ -> Soc2cUtil.data_type_to_c dt "*"
+    in
+    let to_param out (id,dt) = 
+      match out, dt with
+        | true, Data.Array(_,_) 
+        | false, _ -> Soc2cUtil.data_type_to_c dt id
+        | true,  _ -> Soc2cUtil.data_type_to_c dt ("*"^id)
+    in
+    let in_params = List.map (to_param false) inputs in
+    let out_params = List.map (to_param true) outputs in
+    let in_params_decl = List.map (to_param_decl false) inputs in
+    let out_params_decl = List.map (to_param_decl true) outputs in
     let params = String.concat "," (in_params@out_params) in
     let params_decl = String.concat "," (in_params_decl@out_params_decl) in
     if SocUtils.is_memory_less soc then
diff --git a/src/soc2cStack.mli b/src/soc2cStack.mli
index 32896afa7683b97873e6f8bae0f22b55ffecdd68..f463499580b5ff7a8bb78df3d59fd0af9f544df2 100644
--- a/src/soc2cStack.mli
+++ b/src/soc2cStack.mli
@@ -1,4 +1,4 @@
-(* Time-stamp: <modified the 06/02/2015 (at 11:06) by Erwan Jahier> *)
+(* Time-stamp: <modified the 09/02/2015 (at 16:44) by Erwan Jahier> *)
 
 (** Gathers all entities (functions, types) that implement the
     heap-based C generator.  *)
@@ -22,7 +22,7 @@ val string_of_var_expr: Soc.t -> Soc.var_expr -> string
 
 
 (* [ctx_var vk id] *)
-val ctx_var : Soc2cUtil.var_kind -> Ident.t -> string
+val ctx_var : Soc2cUtil.var_kind -> Soc.t -> Ident.t -> string
   
 (**  [gen_step_call soc called_soc vel_out vel_in ctx sname step_arg]
  Generates the C code that performs the call to a step method of
diff --git a/src/soc2cUtil.ml b/src/soc2cUtil.ml
index 3ea2b5bd6769dbb911ff6aded19f42be42f6f956..4abd10c339cca9d256a9a62fda59a86e85f3287c 100644
--- a/src/soc2cUtil.ml
+++ b/src/soc2cUtil.ml
@@ -1,4 +1,4 @@
-(* Time-stamp: <modified the 06/02/2015 (at 16:07) by Erwan Jahier> *)
+(* Time-stamp: <modified the 12/02/2015 (at 10:45) by Erwan Jahier> *)
 
 open Soc2cIdent
 open Data
@@ -38,12 +38,33 @@ let string_of_flow_decl (id, t) =
   Printf.sprintf "   %s;\n" (type_to_string t (id2s id)) 
 
 
+let rec (data_type_to_c: Data.t  -> string -> string) =
+  fun v n -> 
+    let rec finish acc str =
+      match acc with
+        |[] -> str
+        | s::ts -> Printf.sprintf "%s[%d]" (finish ts str) s
+    in 
+    let rec aux acc v n =
+      match v with
+        | Bool -> finish acc ("_boolean "^n)
+        | Int -> finish acc ("_integer "^n)
+        | Real-> finish acc ("_real "^n)
+        | Extern s -> finish acc ((id2s s)^" "^n)
+        | Enum  (s, sl) -> finish acc (id2s s ^" "^n)
+        | Struct (sid,_) -> finish acc ((id2s sid)^" "^n)
+        | Array (ty, sz) -> aux (sz::acc) ty n
+        | Alpha nb -> finish acc ("alpha_"^(string_of_int nb)^" "^n) 
+        | Alias(a,_) -> finish acc (a^" "^n)
+    in
+    aux [] v n
+
 let rec (lic_type_to_c: Lic.type_  -> string -> string) =
   fun t n -> 
     match t with
       | Lic.Struct_type_eff (name, fl) ->
         let field_to_c (id,(tf,_opt)) = 
-          Printf.sprintf "\n   %s;" (type_to_string (Lic2soc.lic_to_data_type tf) (id2s id)) 
+          Printf.sprintf "\n   %s;" (data_type_to_c (Lic2soc.lic_to_data_type tf) (id2s id)) 
         in
         ((Printf.sprintf "struct { %s\n  }" 
             (String.concat "" (List.map field_to_c fl)))^ " " ^ n) 
diff --git a/src/soc2cUtil.mli b/src/soc2cUtil.mli
index 0e9283f6e592409353f4262baa2e89530e810775..1ec11a55ece38c94083016ba84a6cb984c8a30b7 100644
--- a/src/soc2cUtil.mli
+++ b/src/soc2cUtil.mli
@@ -1,9 +1,10 @@
-(* Time-stamp: <modified the 04/02/2015 (at 14:23) by Erwan Jahier> *)
+(* Time-stamp: <modified the 11/02/2015 (at 14:02) by Erwan Jahier> *)
 
 (** *)
 
 
 val type_to_string : Data.t -> string -> string
+val data_type_to_c:  Data.t -> string -> string
 val lic_type_to_c: Lic.type_  -> string -> string
 
 val string_of_flow_decl : string * Data.t -> string
diff --git a/src/socPredef2cStack.ml b/src/socPredef2cStack.ml
index b352e04782b1fee3717ab0ddba57f04aa73e7624..3a4c219eb42ab2950f7b8f15a0ae0e173e247cfd 100644
--- a/src/socPredef2cStack.ml
+++ b/src/socPredef2cStack.ml
@@ -1,5 +1,5 @@
 
-(* Time-stamp: <modified the 05/02/2015 (at 11:26) by Erwan Jahier> *)
+(* Time-stamp: <modified the 11/02/2015 (at 17:53) by Erwan Jahier> *)
 
 open Data
 open Soc
@@ -23,7 +23,7 @@ let (lustre_ite : Soc.key -> string) =
   fun sk -> 
     let t = match sk with  (_,_::t::_,_) -> t | _ ->  assert false in
 (*     Printf.sprintf"  %s.z = (%s.c)? %s.xt : %s.xe;\n" ctx ctx ctx ctx *)
-    Soc2cHeap.gen_assign t (Printf.sprintf "*z")
+    Soc2cStack.gen_assign t (Printf.sprintf "*z")
        (Printf.sprintf "(c)? xt : xe")
        (Printf.sprintf "sizeof(*z)")
 
@@ -39,7 +39,7 @@ let (lustre_arrow : Soc.key -> string) =
     let t = match sk with  (_,_::t::_,_) -> t | _ ->  assert false in
     let vo = Printf.sprintf"((ctx->_memory)? %s : %s)" x y in
     let size = Printf.sprintf "sizeof(%s)" x in
-    (Soc2cHeap.gen_assign t z vo size) ^ 
+    (Soc2cStack.gen_assign t z vo size) ^ 
       ("  ctx->_memory = _false;\n")
       
 let (lustre_hat : Soc.key -> string) =
@@ -50,7 +50,7 @@ let (lustre_hat : Soc.key -> string) =
     in
     let buff = ref "" in
     for j=0 to i-1 do
-      buff := !buff^(Soc2cHeap.gen_assign t (Printf.sprintf "z[%d]" j)
+      buff := !buff^(Soc2cStack.gen_assign t (Printf.sprintf "z[%d]" j)
                        (Printf.sprintf "x") (Printf.sprintf "sizeof(x)")); 
     done;
     !buff
@@ -63,7 +63,7 @@ let (lustre_array: Soc.key -> string) =
     in
     let buff = ref "" in
     for j=0 to i-1 do
-      buff := !buff^(Soc2cHeap.gen_assign t (Printf.sprintf "z[%d]" j)
+      buff := !buff^(Soc2cStack.gen_assign t (Printf.sprintf "z[%d]" j)
                        (Printf.sprintf "x%d" (j+1)) 
                        (Printf.sprintf "sizeof(x%d)" (j+1))); 
     done;
@@ -83,11 +83,11 @@ let (lustre_concat: Soc.key -> string) =
 (* Both seems to work *)
 (*      let buff = ref "" in  *)
 (*      for j=0 to s1-1 do  *)
-(*        buff := !buff^(Soc2cHeap.gen_assign t (Printf.sprintf "%s.z[%d]" ctx j)  *)
+(*        buff := !buff^(Soc2cStack.gen_assign t (Printf.sprintf "%s.z[%d]" ctx j)  *)
 (*                         (Printf.sprintf "%s.x[%d]" ctx j));   *)
 (*      done;  *)
 (*      for j=s1 to s1+s2-1 do  *)
-(*        buff := !buff^(Soc2cHeap.gen_assign t (Printf.sprintf "%s.z[%d]" ctx j)  *)
+(*        buff := !buff^(Soc2cStack.gen_assign t (Printf.sprintf "%s.z[%d]" ctx j)  *)
 (*                         (Printf.sprintf "%s.y[%d]" ctx (j-s1)));   *)
 (*      done;  *)
 (*      !buff  *)
@@ -104,7 +104,7 @@ let (lustre_slice: Soc.key -> string) =
         let j=ref 0 in
         for i = b to e do
           if (i-b) mod step = 0 then (
-            buff := !buff^(Soc2cHeap.gen_assign t (Printf.sprintf "z[%d]" !j)  
+            buff := !buff^(Soc2cStack.gen_assign t (Printf.sprintf "z[%d]" !j)  
                              (Printf.sprintf "x[%d]" i)
                              (Printf.sprintf "sizeof(x[%d])" i)
             );   
@@ -199,20 +199,23 @@ let (get_iterator : Soc.t -> string -> Soc.t -> int -> string) =
     let step_args, ctx, array_index = 
       match soc.instances with
         | [] -> (
-          let (array_index : int -> var -> Soc.var_expr) =
-            fun i (vn,vt) -> Var(Printf.sprintf "%s[%d]" vn i, type_elt_of_array vt)
+          let (array_index : int -> Soc.var -> Soc.var_expr) =
+            fun i (vn,vt) -> (* Var(Printf.sprintf "%s[%d]" vn i, type_elt_of_array vt) *)
+              Index(Var (vn,Data.Array(vt,i)),i,vt) 
           in          
           Array.make n "", 
           Array.make n (get_ctx_name it_soc.key),
           array_index
         )
         | _  -> 
-          let inst_names = List.map fst soc.instances in 
+          let inst_names = List.map fst soc.instances in
           let inst_names = List.rev inst_names in
           let step_args = List.map (fun sn  -> ("&ctx->"^(id2s sn))) inst_names in
-          let ctx = List.map (fun sn  -> ("ctx->"^(id2s sn))) inst_names in
+          let ctx = List.map (fun sn -> ("ctx->"^(id2s sn))) inst_names in
           let (array_index : int -> var -> Soc.var_expr) =
-            fun i (vn,vt) -> Var(Printf.sprintf "ctx->%s[%d]" vn i,vt) 
+            fun i (vn,vt) ->  
+              Index(Var (Printf.sprintf "%s" vn, Data.Array(vt,i)),i,vt)
+           (* Var(Printf.sprintf "%s[%d]" vn i,vt)   *)
           in
           Array.of_list step_args,
           Array.of_list ctx,
@@ -234,7 +237,7 @@ let (get_iterator : Soc.t -> string -> Soc.t -> int -> string) =
           | _ -> assert false (* should not occur *)
       in
       buff := !buff^(
-        Soc2cHeap.gen_step_call
+        Soc2cStack.gen_step_call
           soc it_soc vel_out vel_in ctx.(i) node_step step_args.(i))
     done;
 
@@ -242,7 +245,7 @@ let (get_iterator : Soc.t -> string -> Soc.t -> int -> string) =
       let type_in = (snd (List.hd iter_inputs)) in
       let a_in  =  (fst (List.hd iter_inputs)) in
       let a_out = "*" ^ (fst (List.hd iter_outputs)) in
-      buff := !buff^(Soc2cHeap.gen_assign type_in a_out a_in
+      buff := !buff^(Soc2cStack.gen_assign type_in a_out a_in
                        (Printf.sprintf "sizeof(%s)" a_in))  (* a_out=a_n *)
     );
     !buff
@@ -278,8 +281,8 @@ let (get_condact : Soc.t -> Soc.t -> var_expr list -> string ) =
     add "    ctx->_memory = _false;";
     add "   } else if (ctx->_memory == _true) {";
     List.iter2 (fun var ve -> 
-      add (Printf.sprintf "    %s = %s;" (Soc2cHeap.string_of_var_expr soc var)
-             (Soc2cHeap.string_of_var_expr soc ve) )
+      add (Printf.sprintf "    %s = %s;" (Soc2cStack.string_of_var_expr soc var)
+             (Soc2cStack.string_of_var_expr soc ve) )
     ) vel_out el ;
     add "    ctx->_memory = _false;";
     add "  }";
diff --git a/test/lus2lic.sum b/test/lus2lic.sum
index c6548949543b88525c8e53f32eb7070e8757cc02..ece0a148a03d1239e5b00abd067ed58fe3b126c5 100644
--- a/test/lus2lic.sum
+++ b/test/lus2lic.sum
@@ -1,5 +1,5 @@
 ==> lus2lic0.sum <==
-Test Run By jahier on Mon Feb  9 15:44:03 
+Test Run By jahier on Thu Feb 12 10:46:28 
 Native configuration is x86_64-unknown-linux-gnu
 
 		=== lus2lic0 tests ===
@@ -63,7 +63,7 @@ XFAIL: Test bad programs (assert): test_lus2lic_no_node should_fail/assert/lecte
 XFAIL: Test bad programs (assert): test_lus2lic_no_node should_fail/assert/s.lus
 
 ==> lus2lic1.sum <==
-Test Run By jahier on Mon Feb  9 15:44:08 
+Test Run By jahier on Thu Feb 12 10:46:30 
 Native configuration is x86_64-unknown-linux-gnu
 
 		=== lus2lic1 tests ===
@@ -397,7 +397,7 @@ PASS: gcc -o multipar.exec multipar_multipar.c multipar_multipar_loop.c
 PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c multipar.lus  {}
 
 ==> lus2lic2.sum <==
-Test Run By jahier on Mon Feb  9 15:44:45 
+Test Run By jahier on Thu Feb 12 10:46:32 
 Native configuration is x86_64-unknown-linux-gnu
 
 		=== lus2lic2 tests ===
@@ -727,7 +727,7 @@ PASS: gcc -o zzz2.exec zzz2_zzz2.c zzz2_zzz2_loop.c
 PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c zzz2.lus  {}
 
 ==> lus2lic3.sum <==
-Test Run By jahier on Mon Feb  9 15:45:48 
+Test Run By jahier on Thu Feb 12 10:46:34 
 Native configuration is x86_64-unknown-linux-gnu
 
 		=== lus2lic3 tests ===
@@ -1230,7 +1230,7 @@ PASS: ./myec2c {-o multipar.c multipar.ec}
 PASS: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node multipar.lus {}
 
 ==> lus2lic4.sum <==
-Test Run By jahier on Mon Feb  9 15:46:24 
+Test Run By jahier on Thu Feb 12 10:46:37 
 Native configuration is x86_64-unknown-linux-gnu
 
 		=== lus2lic4 tests ===
@@ -1726,14 +1726,12 @@ PASS: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node zzz2.lus {}
 # of unexpected failures	3
 ===============================
 # Total number of failures: 14
-lus2lic0.log:testcase ./lus2lic.tests/test0.exp completed in 4 seconds
-lus2lic1.log:testcase ./lus2lic.tests/test1.exp completed in 36 seconds
-lus2lic2.log:testcase ./lus2lic.tests/test2.exp completed in 62 seconds
-lus2lic3.log:testcase ./lus2lic.tests/test3.exp completed in 36 seconds
-lus2lic4.log:testcase ./lus2lic.tests/test4.exp completed in 75 seconds
+lus2lic0.log:testcase ./lus2lic.tests/test0.exp completed in 6 seconds
+lus2lic1.log:testcase ./lus2lic.tests/test1.exp completed in 47 seconds
+lus2lic2.log:testcase ./lus2lic.tests/test2.exp completed in 74 seconds
+lus2lic3.log:testcase ./lus2lic.tests/test3.exp completed in 45 seconds
+lus2lic4.log:testcase ./lus2lic.tests/test4.exp completed in 77 seconds
 * Ref time: 
-0.04user 0.05system 3:36.73elapsed 0%CPU (0avgtext+0avgdata 5080maxresident)k
-160inputs+0outputs (0major+5488minor)pagefaults 0swaps
 * Quick time (-j 4):
-0.04user 0.02system 1:26.50elapsed 0%CPU (0avgtext+0avgdata 5072maxresident)k
-160inputs+0outputs (0major+5567minor)pagefaults 0swaps
+0.04user 0.02system 1:25.96elapsed 0%CPU (0avgtext+0avgdata 5100maxresident)k
+160inputs+0outputs (0major+5549minor)pagefaults 0swaps
diff --git a/test/lus2lic.time b/test/lus2lic.time
index df8db41a300c09d606066b2d62e242e4799bcfa2..34882fa3e5d98dbd004e2b40a2b8a559bb6b058d 100644
--- a/test/lus2lic.time
+++ b/test/lus2lic.time
@@ -1,11 +1,9 @@
-lus2lic0.log:testcase ./lus2lic.tests/test0.exp completed in 4 seconds
-lus2lic1.log:testcase ./lus2lic.tests/test1.exp completed in 36 seconds
-lus2lic2.log:testcase ./lus2lic.tests/test2.exp completed in 62 seconds
-lus2lic3.log:testcase ./lus2lic.tests/test3.exp completed in 36 seconds
-lus2lic4.log:testcase ./lus2lic.tests/test4.exp completed in 75 seconds
+lus2lic0.log:testcase ./lus2lic.tests/test0.exp completed in 6 seconds
+lus2lic1.log:testcase ./lus2lic.tests/test1.exp completed in 47 seconds
+lus2lic2.log:testcase ./lus2lic.tests/test2.exp completed in 74 seconds
+lus2lic3.log:testcase ./lus2lic.tests/test3.exp completed in 45 seconds
+lus2lic4.log:testcase ./lus2lic.tests/test4.exp completed in 77 seconds
 * Ref time: 
-0.04user 0.05system 3:36.73elapsed 0%CPU (0avgtext+0avgdata 5080maxresident)k
-160inputs+0outputs (0major+5488minor)pagefaults 0swaps
 * Quick time (-j 4):
-0.04user 0.02system 1:26.50elapsed 0%CPU (0avgtext+0avgdata 5072maxresident)k
-160inputs+0outputs (0major+5567minor)pagefaults 0swaps
+0.04user 0.02system 1:25.96elapsed 0%CPU (0avgtext+0avgdata 5100maxresident)k
+160inputs+0outputs (0major+5549minor)pagefaults 0swaps
diff --git a/test/should_work/call07.lus b/test/should_work/call07.lus
index 3c1fe408a72b74c73306ed70742a4b881de0bf05..ab454b6dbfe7dcfb4c9142c4104a93e45396ea1b 100644
--- a/test/should_work/call07.lus
+++ b/test/should_work/call07.lus
@@ -1,5 +1,5 @@
 
-node call07(x,y,z : bool) returns (t : bool);
+function call07(x,y,z : bool) returns (t : bool);
 let
 	t = #(x,y,z);
 tel