diff --git a/automata/automaton_F.jl b/automata/automaton_F.jl
index 58ee7d8ff1e81d970a5de1beaf1788c1ad97e8e0..1cf7ed68a0833d36d0c5002cb45c4c0ea81cce40 100644
--- a/automata/automaton_F.jl
+++ b/automata/automaton_F.jl
@@ -4,7 +4,7 @@ function create_automaton_F(m::ContinuousTimeModel, x1::Float64, x2::Float64, t1
     @assert sym_obs in m.g "$(sym_obs) is not observed."
     @assert (x1 <= x2) "x1 > x2 impossible for F automaton."
     @assert (t1 <= t2) "t1 > t2 impossible for F automaton."
-    
+
     # Locations
     locations = [:l0, :l1, :l2, :l3]
 
@@ -12,7 +12,7 @@ function create_automaton_F(m::ContinuousTimeModel, x1::Float64, x2::Float64, t1
     @everywhere true_inv_predicate(x::Vector{Int}) = true 
     Λ_F = Dict(:l0 => getfield(Main, :true_inv_predicate), :l1 => getfield(Main, :true_inv_predicate),
                :l2 => getfield(Main, :true_inv_predicate), :l3 => getfield(Main, :true_inv_predicate))
-    
+
     ## Init and final loc
     locations_init = [:l0]
     locations_final = [:l2]
@@ -34,7 +34,7 @@ function create_automaton_F(m::ContinuousTimeModel, x1::Float64, x2::Float64, t1
     for loc in locations 
         map_edges[loc] = Dict{Location, Vector{Edge}}()
     end
-    
+
     idx_obs_var = getfield(m, :map_var_idx)[sym_obs]
     idx_var_n = map_var_automaton_idx[:n] 
     idx_var_d = map_var_automaton_idx[:d] 
@@ -54,78 +54,72 @@ function create_automaton_F(m::ContinuousTimeModel, x1::Float64, x2::Float64, t1
         # "cc" as check_constraints and "us" as update_state
         # l0 => l1
         @everywhere $(func_name(:cc, :l0, :l1, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = true
-        @everywhere $(func_name(:us, :l0, :l1, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = :l1; 
-         S_values[$(idx_var_n)] = x[$(idx_obs_var)];
+        @everywhere $(func_name(:us, :l0, :l1, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (S_values[$(idx_var_n)] = x[$(idx_obs_var)];
          setindex!(S_values, Inf, $(idx_var_d)); 
-         setindex!(S_values, getfield(Main, $(Meta.quot(sym_isabs_func)))(p, x), $(idx_var_isabs)))
-
+         setindex!(S_values, getfield(Main, $(Meta.quot(sym_isabs_func)))(p, x), $(idx_var_isabs));
+         :l1)
         # l1 loc
         # l1 => l2
         #=
         @everywhere $(func_name(:cc, :l1, :l2, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         S_time >= $t1 &&
         ($x1 <= S_values[$(idx_var_n)] <= $x2)
-        @everywhere $(func_name(:us, :l1, :l2, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = :l2;
-         setindex!(S_values, 0, $(idx_var_d)))
-        =#
+        @everywhere $(func_name(:us, :l1, :l2, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, 0, $(idx_var_d));
+        :l2)        =#
         #=
         @everywhere $(func_name(:cc, :l1, :l2, 3))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         istrue(S_values[$(idx_var_isabs)]) && S_time <= $t2
-        @everywhere $(func_name(:us, :l1, :l2, 3))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = :l2)
+        @everywhere $(func_name(:us, :l1, :l2, 3))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (:l2)
         =#
         @everywhere $(func_name(:cc, :l1, :l2, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         S_time >= $t1 &&
         S_values[$(idx_var_d)] == 0 
-        @everywhere $(func_name(:us, :l1, :l2, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = :l2)
+        @everywhere $(func_name(:us, :l1, :l2, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (:l2)
 
         @everywhere $(func_name(:cc, :l1, :l2, 2))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         (S_time >= $t2) && 
         (S_values[$(idx_var_n)] < $x1 || S_values[$(idx_var_n)] > $x2)
-        @everywhere $(func_name(:us, :l1, :l2, 2))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = :l2;)
+        @everywhere $(func_name(:us, :l1, :l2, 2))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (:l2;)
         #setindex!(S_values, min(abs(S_values[$(idx_var_n)] - $x1), abs(S_values[$(idx_var_n)] - $x2)), $(idx_var_d)))
 
         # l1 => l3
         @everywhere $(func_name(:cc, :l1, :l3, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         (S_time <= $t1) &&
         (S_values[$(idx_var_n)] < $x1 || S_values[$(idx_var_n)] > $x2)
-        @everywhere $(func_name(:us, :l1, :l3, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = :l3;
-         setindex!(S_values, min(sqrt((S_time - $t1)^2 + (S_values[$(idx_var_n)] - $x2)^2), 
-                                             sqrt((S_time - $t1)^2 + (S_values[$(idx_var_n)] - $x1)^2)), $(idx_var_d)))
-        
+        @everywhere $(func_name(:us, :l1, :l3, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, min(sqrt((S_time - $t1)^2 + (S_values[$(idx_var_n)] - $x2)^2), 
+                                 sqrt((S_time - $t1)^2 + (S_values[$(idx_var_n)] - $x1)^2)), $(idx_var_d));
+        :l3)        
         @everywhere $(func_name(:cc, :l1, :l3, 2))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         ($x1 <= S_values[$(idx_var_n)] <= $x2)
-        @everywhere $(func_name(:us, :l1, :l3, 2))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = :l3;
-         setindex!(S_values, 0, $(idx_var_d)))
-
+        @everywhere $(func_name(:us, :l1, :l3, 2))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, 0, $(idx_var_d));
+         :l3)
         @everywhere $(func_name(:cc, :l1, :l3, 3))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         (S_time >= $t1) &&
         (S_values[$(idx_var_n)] < $x1 || S_values[$(idx_var_n)] > $x2)
-        @everywhere $(func_name(:us, :l1, :l3, 3))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = :l3;
-         val_min = min(S_values[$(idx_var_d)], 
+        @everywhere $(func_name(:us, :l1, :l3, 3))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (val_min = min(S_values[$(idx_var_d)], 
                        min(abs(S_values[$(idx_var_n)] - $x1), abs(S_values[$(idx_var_n)] - $x2)));
-         setindex!(S_values, val_min, $(idx_var_d)))
-
+         setindex!(S_values, val_min, $(idx_var_d));
+        :l3)
         # l3 loc
         # l3 => l1
         @everywhere $(func_name(:cc, :l3, :l1, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = true
-        @everywhere $(func_name(:us, :l3, :l1, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = :l1;
-         S_values[$(idx_var_n)] = x[$(idx_obs_var)];
-         setindex!(S_values, getfield(Main, $(Meta.quot(sym_isabs_func)))(p, x), $(idx_var_isabs)))
-
+        @everywhere $(func_name(:us, :l3, :l1, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (S_values[$(idx_var_n)] = x[$(idx_obs_var)];
+         setindex!(S_values, getfield(Main, $(Meta.quot(sym_isabs_func)))(p, x), $(idx_var_isabs));
+         :l1)
         # l3 => l2
         @everywhere $(func_name(:cc, :l3, :l2, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         (S_time >= $t2 || istrue(S_values[$(idx_var_isabs)]))
-        @everywhere $(func_name(:us, :l3, :l2, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = :l2)
+        @everywhere $(func_name(:us, :l3, :l2, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (:l2)
     end
     eval(meta_elementary_functions)
 
@@ -148,12 +142,12 @@ function create_automaton_F(m::ContinuousTimeModel, x1::Float64, x2::Float64, t1
     edge2 = Edge(nothing, getfield(Main, func_name(:cc, :l1, :l3, 2)), getfield(Main, func_name(:us, :l1, :l3, 2)))
     edge3 = Edge(nothing, getfield(Main, func_name(:cc, :l1, :l3, 3)), getfield(Main, func_name(:us, :l1, :l3, 3)))
     map_edges[:l1][:l3] = [edge1, edge2, edge3]
-  
+
     # l3 loc
     # l3 => l1
     edge1 = Edge([:ALL], getfield(Main, func_name(:cc, :l3, :l1, 1)), getfield(Main, func_name(:us, :l3, :l1, 1)))
     map_edges[:l3][:l1] = [edge1]
-    
+
     # l3 => l2
     edge1 = Edge(nothing, getfield(Main, func_name(:cc, :l3, :l2, 1)), getfield(Main, func_name(:us, :l3, :l2, 1)))
     map_edges[:l3][:l2] = [edge1]
diff --git a/automata/automaton_G.jl b/automata/automaton_G.jl
index 67847b4a6f3e95bdeb819dddb7dbd779f939f2ac..99973783268b77605c0609c00708e821743ab612 100644
--- a/automata/automaton_G.jl
+++ b/automata/automaton_G.jl
@@ -54,62 +54,62 @@ function create_automaton_G(m::ContinuousTimeModel, x1::Float64, x2::Float64, t1
         # l0 loc
         # l0 => l1
         @everywhere $(func_name(:cc, :l0, :l1, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = true
-        @everywhere $(func_name(:us, :l0, :l1, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l1"); 
-         setindex!(S_values, 0, $(idx_var_d));
+        @everywhere $(func_name(:us, :l0, :l1, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, 0, $(idx_var_d));
          setindex!(S_values, x[$(idx_obs_var)], $(idx_var_n));
          setindex!(S_values, true, $(idx_var_in));
-         setindex!(S_values, getfield(Main, $(Meta.quot(sym_isabs_func)))(p, x), $(idx_var_isabs)))
+         setindex!(S_values, getfield(Main, $(Meta.quot(sym_isabs_func)))(p, x), $(idx_var_isabs));
+		:l1)
 
         # l1 => l3
         @everywhere $(func_name(:cc, :l1, :l3, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         S_time <= $t1 && 
         S_values[$(idx_var_n)] < $x1 || S_values[$(idx_var_n)] > $x2
-        @everywhere $(func_name(:us, :l1, :l3, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l3"); 
-         setindex!(S_values, min(abs($x1 - S_values[$(idx_var_n)]), abs($x2 - S_values[$(idx_var_n)])), $(idx_var_d));
-         setindex!(S_values, false, $(idx_var_in)))
+        @everywhere $(func_name(:us, :l1, :l3, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, min(abs($x1 - S_values[$(idx_var_n)]), abs($x2 - S_values[$(idx_var_n)])), $(idx_var_d));
+         setindex!(S_values, false, $(idx_var_in));
+		:l3)
 
         @everywhere $(func_name(:cc, :l1, :l3, 2))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         (S_time <= $t1) && 
         ($x1 <= S_values[$(idx_var_n)] <= $x2)
-        @everywhere $(func_name(:us, :l1, :l3, 2))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l3"); 
-         setindex!(S_values, 0, $(idx_var_d));
-         setindex!(S_values, false, $(idx_var_in)))
+        @everywhere $(func_name(:us, :l1, :l3, 2))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, 0, $(idx_var_d));
+         setindex!(S_values, false, $(idx_var_in));
+		:l3)
 
         @everywhere $(func_name(:cc, :l1, :l3, 3))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         !istrue(S_values[$(idx_var_in)]) && 
         ($t1 <= S_time <= $t2) && 
         ($x1 <= S_values[$(idx_var_n)] <= $x2)
-        @everywhere $(func_name(:us, :l1, :l3, 3))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l3"); 
-         setindex!(S_values, S_values[$(idx_var_d)] * (S_time - $t1), $(idx_var_d));
-         setindex!(S_values, 0.0, $(idx_var_tprime)))
+        @everywhere $(func_name(:us, :l1, :l3, 3))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, S_values[$(idx_var_d)] * (S_time - $t1), $(idx_var_d));
+         setindex!(S_values, 0.0, $(idx_var_tprime));
+		:l3)
 
         @everywhere $(func_name(:cc, :l1, :l3, 4))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         istrue(S_values[$(idx_var_in)]) && 
         ($t1 <= S_time <= $t2) && 
         ($x1 <= S_values[$(idx_var_n)] <= $x2)
-        @everywhere $(func_name(:us, :l1, :l3, 4))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l3"); 
-         setindex!(S_values, 0.0, $(idx_var_tprime)))
+        @everywhere $(func_name(:us, :l1, :l3, 4))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, 0.0, $(idx_var_tprime));
+		:l3)
 
         # l1 => l4
         @everywhere $(func_name(:cc, :l1, :l4, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         !istrue(S_values[$(idx_var_in)]) && 
         ($t1 <= S_time <= $t2) && 
         (S_values[$(idx_var_n)] < $x1 || S_values[$(idx_var_n)] > $x2)
-        @everywhere $(func_name(:us, :l1, :l4, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l4"); 
-         setindex!(S_values, S_values[$(idx_var_d)] + S_values[$(idx_var_d)] * (S_time - $t1), $(idx_var_d)))
+        @everywhere $(func_name(:us, :l1, :l4, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, S_values[$(idx_var_d)] + S_values[$(idx_var_d)] * (S_time - $t1), $(idx_var_d));
+		:l4)
 
         @everywhere $(func_name(:cc, :l1, :l4, 2))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         istrue(S_values[$(idx_var_in)]) && 
         ($t1 <= S_time <= $t2) && 
         (S_values[$(idx_var_n)] < $x1 || S_values[$(idx_var_n)] > $x2)
-        @everywhere $(func_name(:us, :l1, :l4, 2))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l4"))
+        @everywhere $(func_name(:us, :l1, :l4, 2))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (:l4)
 
 
         # l1 => l2
@@ -117,76 +117,76 @@ function create_automaton_G(m::ContinuousTimeModel, x1::Float64, x2::Float64, t1
         @everywhere $(func_name(:cc, :l1, :l2, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         istrue(S_values[$(idx_var_in)]) && 
         S_time >= $t2
-        @everywhere $(func_name(:us, :l1, :l2, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l2"))
+        @everywhere $(func_name(:us, :l1, :l2, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (:l2)
 
         @everywhere $(func_name(:cc, :l1, :l2, 2))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         !istrue(S_values[$(idx_var_in)]) && 
         S_time >= $t2
-        @everywhere $(func_name(:us, :l1, :l2, 2))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l2"); 
-         setindex!(S_values, S_values[$(idx_var_d)] * ($t2 - $t1), $(idx_var_d)))
+        @everywhere $(func_name(:us, :l1, :l2, 2))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, S_values[$(idx_var_d)] * ($t2 - $t1), $(idx_var_d));
+		:l2)
 
         @everywhere $(func_name(:cc, :l1, :l2, 3))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         istrue(S_values[$(idx_var_isabs)]) && 
         S_time <= $t1
-        @everywhere $(func_name(:us, :l1, :l2, 3))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l2"); 
-         setindex!(S_values, ($t2 - $t1) * min(abs($x1 - S_values[$(idx_var_n)]), abs($x2 - S_values[$(idx_var_n)])), $(idx_var_d)))
+        @everywhere $(func_name(:us, :l1, :l2, 3))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, ($t2 - $t1) * min(abs($x1 - S_values[$(idx_var_n)]), abs($x2 - S_values[$(idx_var_n)])), $(idx_var_d));
+		:l2)
 
         @everywhere $(func_name(:cc, :l1, :l2, 4))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         istrue(S_values[$(idx_var_isabs)]) && 
         ($t1 <= S_time <= $t2)
-        @everywhere $(func_name(:us, :l1, :l2, 4))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l2"); 
-         setindex!(S_values, S_values[$(idx_var_d)] + ($t2 - S_time) * min(abs($x1 - S_values[$(idx_var_n)]), abs($x2 - S_values[$(idx_var_n)])), $(idx_var_d)))
+        @everywhere $(func_name(:us, :l1, :l2, 4))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, S_values[$(idx_var_d)] + ($t2 - S_time) * min(abs($x1 - S_values[$(idx_var_n)]), abs($x2 - S_values[$(idx_var_n)])), $(idx_var_d));
+		:l2)
         =#
 
         # l3 => l1
         @everywhere $(func_name(:cc, :l3, :l1, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = true
-        @everywhere $(func_name(:us, :l3, :l1, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l1"); 
-         setindex!(S_values, x[$(idx_obs_var)], $(idx_var_n));
-         setindex!(S_values, getfield(Main, $(Meta.quot(sym_isabs_func)))(p, x), $(idx_var_isabs)))
+        @everywhere $(func_name(:us, :l3, :l1, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, x[$(idx_obs_var)], $(idx_var_n));
+         setindex!(S_values, getfield(Main, $(Meta.quot(sym_isabs_func)))(p, x), $(idx_var_isabs));
+		:l1)
 
         # l4 => l1
         @everywhere $(func_name(:cc, :l4, :l1, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = true
-        @everywhere $(func_name(:us, :l4, :l1, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l1"); 
-         setindex!(S_values, S_values[$(idx_var_d)] + S_values[$(idx_var_tprime)] * min(abs($x1 - S_values[$(idx_var_n)]), abs($x2 - S_values[$(idx_var_n)])), $(idx_var_d));
+        @everywhere $(func_name(:us, :l4, :l1, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, S_values[$(idx_var_d)] + S_values[$(idx_var_tprime)] * min(abs($x1 - S_values[$(idx_var_n)]), abs($x2 - S_values[$(idx_var_n)])), $(idx_var_d));
          setindex!(S_values, 0.0, $(idx_var_tprime));
          setindex!(S_values, x[$(idx_obs_var)], $(idx_var_n));
          setindex!(S_values, true, $(idx_var_in));
-         setindex!(S_values, getfield(Main, $(Meta.quot(sym_isabs_func)))(p, x), $(idx_var_isabs)))
+         setindex!(S_values, getfield(Main, $(Meta.quot(sym_isabs_func)))(p, x), $(idx_var_isabs));
+		:l1)
 
         # l3 => l2
         @everywhere $(func_name(:cc, :l3, :l2, 2))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         istrue(S_values[$(idx_var_in)]) && 
         (S_time >= $t2 || istrue(S_values[$(idx_var_isabs)]))
-        @everywhere $(func_name(:us, :l3, :l2, 2))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l2");
-         setindex!(S_values, S_values[$(idx_var_d)] * ($t2 - $t1), $(idx_var_d)))
+        @everywhere $(func_name(:us, :l3, :l2, 2))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, S_values[$(idx_var_d)] * ($t2 - $t1), $(idx_var_d));
+		:l2)
 
         @everywhere $(func_name(:cc, :l3, :l2, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         !istrue(S_values[$(idx_var_in)]) && 
         (S_time >= $t2 || istrue(S_values[$(idx_var_isabs)]))
-        @everywhere $(func_name(:us, :l3, :l2, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l2"))
+        @everywhere $(func_name(:us, :l3, :l2, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (:l2)
 
         # l4 => l2
         @everywhere $(func_name(:cc, :l4, :l2, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         (istrue(S_values[$(idx_var_isabs)]))
-        @everywhere $(func_name(:us, :l4, :l2, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l2"); 
-         setindex!(S_values, S_values[$(idx_var_d)] + ($t2 - S_time) * min(abs($x1 - S_values[$(idx_var_n)]), abs($x2 - S_values[$(idx_var_n)])), $(idx_var_d));
-         setindex!(S_values, 0.0, $(idx_var_tprime)))
+        @everywhere $(func_name(:us, :l4, :l2, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, S_values[$(idx_var_d)] + ($t2 - S_time) * min(abs($x1 - S_values[$(idx_var_n)]), abs($x2 - S_values[$(idx_var_n)])), $(idx_var_d));
+         setindex!(S_values, 0.0, $(idx_var_tprime));
+		:l2)
 
         @everywhere $(func_name(:cc, :l4, :l2, 2))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         (S_time >= $t2)
-        @everywhere $(func_name(:us, :l4, :l2, 2))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l2"); 
-         setindex!(S_values, S_values[$(idx_var_d)] + S_values[$(idx_var_tprime)] * min(abs($x1 - S_values[$(idx_var_n)]), abs($x2 - S_values[$(idx_var_n)])), $(idx_var_d));
-         setindex!(S_values, 0.0, $(idx_var_tprime)))
+        @everywhere $(func_name(:us, :l4, :l2, 2))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, S_values[$(idx_var_d)] + S_values[$(idx_var_tprime)] * min(abs($x1 - S_values[$(idx_var_n)]), abs($x2 - S_values[$(idx_var_n)])), $(idx_var_d));
+         setindex!(S_values, 0.0, $(idx_var_tprime));
+		:l2)
  
     end
     eval(meta_elementary_functions)
diff --git a/automata/automaton_G_and_F.jl b/automata/automaton_G_and_F.jl
index f445f297a22e89987e330f7b423f5f292a7fcb6c..6a54d052c922c7ac51b6d21a4604dda6c49c29ca 100644
--- a/automata/automaton_G_and_F.jl
+++ b/automata/automaton_G_and_F.jl
@@ -54,7 +54,7 @@ function create_automaton_G_and_F(m::ContinuousTimeModel, x1::Float64, x2::Float
     idx_var_isabs = map_var_automaton_idx[:isabs] 
     idx_var_in = map_var_automaton_idx[:in] 
     idx_var_tprime = map_var_automaton_idx[:tprime]
-    
+
     nbr_rand = rand(1:1000)
     basename_func = "$(replace(m.name, ' '=>'_'))_$(nbr_rand)"
     basename_func = replace(basename_func, '-'=>'_')
@@ -68,215 +68,215 @@ function create_automaton_G_and_F(m::ContinuousTimeModel, x1::Float64, x2::Float
         # l0G loc
         # l0G => l1G
         @everywhere $(func_name(:cc, :l0G, :l1G, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = true
-        @everywhere $(func_name(:us, :l0G, :l1G, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l1G"); 
-         setindex!(S_values, 0, $(idx_var_d));
-         setindex!(S_values, x[$(idx_obs_var_G)], $(idx_var_n)); 
+        @everywhere $(func_name(:us, :l0G, :l1G, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, 0, $(idx_var_d));
+         setindex!(S_values, x[$(idx_obs_var_G)], $(idx_var_n));
          setindex!(S_values, true, $(idx_var_in));
-         setindex!(S_values, getfield(Main, $(Meta.quot(sym_isabs_func)))(p, x), $(idx_var_isabs)))
+         setindex!(S_values, getfield(Main, $(Meta.quot(sym_isabs_func)))(p, x), $(idx_var_isabs));
+         :l1G)
 
         # l1G loc
         # l1G => l3G
         @everywhere $(func_name(:cc, :l1G, :l3G, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         S_time <= $t1 && 
         S_values[$(idx_var_n)] < $x1 || S_values[$(idx_var_n)] > $x2
-        @everywhere $(func_name(:us, :l1G, :l3G, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l3G"); 
-         setindex!(S_values, min(abs($x1 - S_values[$(idx_var_n)]), abs($x2 - S_values[$(idx_var_n)])), $(idx_var_d)); 
-         setindex!(S_values, false, $(idx_var_in)))
+        @everywhere $(func_name(:us, :l1G, :l3G, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, min(abs($x1 - S_values[$(idx_var_n)]), abs($x2 - S_values[$(idx_var_n)])), $(idx_var_d));
+         setindex!(S_values, false, $(idx_var_in));
+         :l3G)
 
         @everywhere $(func_name(:cc, :l1G, :l3G, 2))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         (S_time <= $t1) && 
         ($x1 <= S_values[$(idx_var_n)] <= $x2)
-        @everywhere $(func_name(:us, :l1G, :l3G, 2))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l3G"); 
-         setindex!(S_values, 0, $(idx_var_d));
-         setindex!(S_values, false, $(idx_var_in)))
+        @everywhere $(func_name(:us, :l1G, :l3G, 2))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, 0, $(idx_var_d));
+         setindex!(S_values, false, $(idx_var_in));
+         :l3G)
 
         @everywhere $(func_name(:cc, :l1G, :l3G, 3))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         !istrue(S_values[$(idx_var_in)]) && 
         ($t1 <= S_time <= $t2) && 
         ($x1 <= S_values[$(idx_var_n)] <= $x2)
-        @everywhere $(func_name(:us, :l1G, :l3G, 3))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l3G"); 
-         setindex!(S_values, S_values[$(idx_var_d)] * (S_time - $t1), $(idx_var_d)); 
-         setindex!(S_values, 0.0, $(idx_var_tprime)))
+        @everywhere $(func_name(:us, :l1G, :l3G, 3))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, S_values[$(idx_var_d)] * (S_time - $t1), $(idx_var_d));
+         setindex!(S_values, 0.0, $(idx_var_tprime));
+         :l3G)
 
         @everywhere $(func_name(:cc, :l1G, :l3G, 4))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         istrue(S_values[$(idx_var_in)]) && 
         ($t1 <= S_time <= $t2) && 
         ($x1 <= S_values[$(idx_var_n)] <= $x2)
-        @everywhere $(func_name(:us, :l1G, :l3G, 4))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l3G"); 
-         setindex!(S_values, 0.0, $(idx_var_tprime)))
+        @everywhere $(func_name(:us, :l1G, :l3G, 4))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, 0.0, $(idx_var_tprime));
+         :l3G)
 
         # l1G => l4G
         @everywhere $(func_name(:cc, :l1G, :l4G, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         !istrue(S_values[$(idx_var_in)]) && 
         ($t1 <= S_time <= $t2) && 
         (S_values[$(idx_var_n)] < $x1 || S_values[$(idx_var_n)] > $x2)
-        @everywhere $(func_name(:us, :l1G, :l4G, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l4G"); 
-         setindex!(S_values, S_values[$(idx_var_d)] + S_values[$(idx_var_d)] * (S_time - $t1), $(idx_var_d)))
+        @everywhere $(func_name(:us, :l1G, :l4G, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, S_values[$(idx_var_d)] + S_values[$(idx_var_d)] * (S_time - $t1), $(idx_var_d));
+         :l4G)
 
         @everywhere $(func_name(:cc, :l1G, :l4G, 2))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         istrue(S_values[$(idx_var_in)]) && 
         ($t1 <= S_time <= $t2) && 
         (S_values[$(idx_var_n)] < $x1 || S_values[$(idx_var_n)] > $x2)
-        @everywhere $(func_name(:us, :l1G, :l4G, 2))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l4G"))
+        @everywhere $(func_name(:us, :l1G, :l4G, 2))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (:l4G)
 
         # l1G => l2G
         #=
         @everywhere $(func_name(:cc, :l1G, :l2G, 3))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         istrue(S_values[$(idx_var_isabs)]) && 
         S_time <= $t1
-        @everywhere $(func_name(:us, :l1G, :l2G, 3))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l2G"); 
-         setindex!(S_values, ($t2 - $t1) * min(abs($x1 - S_values[$(idx_var_n)]), abs($x2 - S_values[$(idx_var_n)])), $(idx_var_d)))
-        
-         @everywhere $(func_name(:cc, :l1G, :l2G, 4))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        @everywhere $(func_name(:us, :l1G, :l2G, 3))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, ($t2 - $t1) * min(abs($x1 - S_values[$(idx_var_n)]), abs($x2 - S_values[$(idx_var_n)])), $(idx_var_d));
+        :l2G)
+
+        @everywhere $(func_name(:cc, :l1G, :l2G, 4))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         istrue(S_values[$(idx_var_isabs)]) && 
         ($t1 <= S_time <= $t2)
-        @everywhere $(func_name(:us, :l1G, :l2G, 4))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l2G"); 
-         setindex!(S_values, S_values[$(idx_var_d)] + ($t2 - S_time) * min(abs($x1 - S_values[$(idx_var_n)]), abs($x2 - S_values[$(idx_var_n)])), $(idx_var_d)))
+        @everywhere $(func_name(:us, :l1G, :l2G, 4))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, S_values[$(idx_var_d)] + ($t2 - S_time) * min(abs($x1 - S_values[$(idx_var_n)]), abs($x2 - S_values[$(idx_var_n)])), $(idx_var_d));
+        :l2G)
 
         @everywhere $(func_name(:cc, :l1G, :l2G, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         istrue(S_values[$(idx_var_in)]) && 
         S_time >= $t2
-        @everywhere $(func_name(:us, :l1G, :l2G, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l2G"))
+        @everywhere $(func_name(:us, :l1G, :l2G, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (:l2G)
 
         @everywhere $(func_name(:cc, :l1G, :l2G, 2))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         !istrue(S_values[$(idx_var_in)]) && 
         S_time >= $t2
-        @everywhere $(func_name(:us, :l1G, :l2G, 2))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l2G"); 
-         setindex!(S_values, S_values[$(idx_var_d)] * ($t2 - $t1), $(idx_var_d)))
+        @everywhere $(func_name(:us, :l1G, :l2G, 2))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, S_values[$(idx_var_d)] * ($t2 - $t1), $(idx_var_d));
+        :l2G)
         =#
 
         # l3G loc
         # l3G => l1G
         @everywhere $(func_name(:cc, :l3G, :l1G, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = true
-        @everywhere $(func_name(:us, :l3G, :l1G, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l1G"); 
-         setindex!(S_values, x[$(idx_obs_var_G)], $(idx_var_n)); 
-         setindex!(S_values, getfield(Main, $(Meta.quot(sym_isabs_func)))(p, x), $(idx_var_isabs)))
+        @everywhere $(func_name(:us, :l3G, :l1G, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, x[$(idx_obs_var_G)], $(idx_var_n));
+         setindex!(S_values, getfield(Main, $(Meta.quot(sym_isabs_func)))(p, x), $(idx_var_isabs));
+         :l1G)
 
         # l3G => l2G
         @everywhere $(func_name(:cc, :l3G, :l2G, 2))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         istrue(S_values[$(idx_var_in)]) && 
         (S_time >= $t2 || istrue(S_values[$(idx_var_isabs)]))
-        @everywhere $(func_name(:us, :l3G, :l2G, 2))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l2G");
-         setindex!(S_values, S_values[$(idx_var_d)] * ($t2 - $t1), $(idx_var_d)))
+        @everywhere $(func_name(:us, :l3G, :l2G, 2))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, S_values[$(idx_var_d)] * ($t2 - $t1), $(idx_var_d));
+         :l2G)
 
         @everywhere $(func_name(:cc, :l3G, :l2G, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         !istrue(S_values[$(idx_var_in)]) && 
         (S_time >= $t2 || istrue(S_values[$(idx_var_isabs)]))
-        @everywhere $(func_name(:us, :l3G, :l2G, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l2G"))
+        @everywhere $(func_name(:us, :l3G, :l2G, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (:l2G)
 
         # l4G loc
         # l4G => l1G
         @everywhere $(func_name(:cc, :l4G, :l1G, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = true
-        @everywhere $(func_name(:us, :l4G, :l1G, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l1G"); 
-         setindex!(S_values, S_values[$(idx_var_d)] + S_values[$(idx_var_tprime)] * min(abs($x1 - S_values[$(idx_var_n)]), abs($x2 - S_values[$(idx_var_n)])), $(idx_var_d)); 
+        @everywhere $(func_name(:us, :l4G, :l1G, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, S_values[$(idx_var_d)] + S_values[$(idx_var_tprime)] * min(abs($x1 - S_values[$(idx_var_n)]), abs($x2 - S_values[$(idx_var_n)])), $(idx_var_d));
          setindex!(S_values, 0.0, $(idx_var_tprime));
-         setindex!(S_values, x[$(idx_obs_var_G)], $(idx_var_n)); 
+         setindex!(S_values, x[$(idx_obs_var_G)], $(idx_var_n));
          setindex!(S_values, true, $(idx_var_in));
-         setindex!(S_values, getfield(Main, $(Meta.quot(sym_isabs_func)))(p, x), $(idx_var_isabs)))
+         setindex!(S_values, getfield(Main, $(Meta.quot(sym_isabs_func)))(p, x), $(idx_var_isabs));
+         :l1G)
 
         # l4G => l2G
         @everywhere $(func_name(:cc, :l4G, :l2G, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         (istrue(S_values[$(idx_var_isabs)]))
-        @everywhere $(func_name(:us, :l4G, :l2G, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l2G"); 
-         setindex!(S_values, S_values[$(idx_var_d)] +  ($t2 - S_time) * min(abs($x1 - S_values[$(idx_var_n)]), abs($x2 - S_values[$(idx_var_n)])), $(idx_var_d));)
-        
+        @everywhere $(func_name(:us, :l4G, :l2G, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, S_values[$(idx_var_d)] +  ($t2 - S_time) * min(abs($x1 - S_values[$(idx_var_n)]), abs($x2 - S_values[$(idx_var_n)])), $(idx_var_d));
+         :l2G)
+
         @everywhere $(func_name(:cc, :l4G, :l2G, 2))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         (S_time >= $t2)
-        @everywhere $(func_name(:us, :l4G, :l2G, 2))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l2G"); 
-         setindex!(S_values, S_values[$(idx_var_d)] +  S_values[$(idx_var_tprime)] * min(abs($x1 - S_values[$(idx_var_n)]), abs($x2 - S_values[$(idx_var_n)])), $(idx_var_d));)
+        @everywhere $(func_name(:us, :l4G, :l2G, 2))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, S_values[$(idx_var_d)] +  S_values[$(idx_var_tprime)] * min(abs($x1 - S_values[$(idx_var_n)]), abs($x2 - S_values[$(idx_var_n)])), $(idx_var_d));
+         :l2G)
 
 
         # Connection between the two automata: l2G => l1F
         @everywhere $(func_name(:cc, :l2G, :l1F, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = true
-        @everywhere $(func_name(:us, :l2G, :l1F, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l1F"); 
-         setindex!(S_values, x[$(idx_obs_var_F)], $(idx_var_n));
+        @everywhere $(func_name(:us, :l2G, :l1F, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, x[$(idx_obs_var_F)], $(idx_var_n));
          setindex!(S_values, Inf, $(idx_var_dprime));
-         setindex!(S_values, getfield(Main, $(Meta.quot(sym_isabs_func)))(p, x), $(idx_var_isabs)))
+         setindex!(S_values, getfield(Main, $(Meta.quot(sym_isabs_func)))(p, x), $(idx_var_isabs));
+         :l1F)
 
         # l1F loc : we construct  the edges of the form l1F => (..)
         # l1F => l2F
         @everywhere $(func_name(:cc, :l1F, :l2F, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         S_time >= $t3 &&
         S_values[$(idx_var_dprime)] == 0 
-        @everywhere $(func_name(:us, :l1F, :l2F, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l2F"));
-         #setindex!(S_values, 0, $(idx_var_dprime)))
+        @everywhere $(func_name(:us, :l1F, :l2F, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (#setindex!(S_values, 0, $(idx_var_dprime));
+         :l2F)
 
         @everywhere $(func_name(:cc, :l1F, :l2F, 2))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         (S_time >= $t4) && 
         (S_values[$(idx_var_n)] < $x3 || S_values[$(idx_var_n)] > $x4)
-        @everywhere $(func_name(:us, :l1F, :l2F, 2))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l2F");
-         #setindex!(S_values, min(abs(S_values[$(idx_var_n)] - $x3), abs(S_values[$(idx_var_n)] - $x4)), $(idx_var_dprime));
-         setindex!(S_values, S_values[$(idx_var_d)] + S_values[$(idx_var_dprime)], $(idx_var_d)))
+        @everywhere $(func_name(:us, :l1F, :l2F, 2))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (#setindex!(S_values, min(abs(S_values[$(idx_var_n)] - $x3), abs(S_values[$(idx_var_n)] - $x4)), $(idx_var_dprime));
+         setindex!(S_values, S_values[$(idx_var_d)] + S_values[$(idx_var_dprime)], $(idx_var_d));
+         :l2F)
         #=
         @everywhere $(func_name(:cc, :l1F, :l2F, 3))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         istrue(S_values[$(idx_var_isabs)]) && S_time <= $t4
-        @everywhere $(func_name(:us, :l1F, :l2F, 3))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l2F");
-         setindex!(S_values, S_values[$(idx_var_d)] + S_values[$(idx_var_dprime)], $(idx_var_d)))
+        @everywhere $(func_name(:us, :l1F, :l2F, 3))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, S_values[$(idx_var_d)] + S_values[$(idx_var_dprime)], $(idx_var_d));
+        :l2F)
 
         @everywhere $(func_name(:cc, :l1F, :l2F, 4))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         S_time >= $t3 &&
         S_values[$(idx_var_dprime)] == 0 
-        @everywhere $(func_name(:us, :l1F, :l2F, 4))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l2F"))
+        @everywhere $(func_name(:us, :l1F, :l2F, 4))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (:l2F)
         =#
 
         # l1F => l3F
         @everywhere $(func_name(:cc, :l1F, :l3F, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         (S_time <= $t3) &&
         (S_values[$(idx_var_n)] < $x3 || S_values[$(idx_var_n)] > $x4)
-        @everywhere $(func_name(:us, :l1F, :l3F, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l3F");
-         setindex!(S_values, min(sqrt((S_time - $t3)^2 + (S_values[$(idx_var_n)] - $x4)^2), 
-                                             sqrt((S_time - $t3)^2 + (S_values[$(idx_var_n)] - $x3)^2)), $(idx_var_dprime)))
+        @everywhere $(func_name(:us, :l1F, :l3F, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, min(sqrt((S_time - $t3)^2 + (S_values[$(idx_var_n)] - $x4)^2), 
+                                 sqrt((S_time - $t3)^2 + (S_values[$(idx_var_n)] - $x3)^2)), $(idx_var_dprime));
+        :l3F)
 
         @everywhere $(func_name(:cc, :l1F, :l3F, 2))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         ($x3 <= S_values[$(idx_var_n)] <= $x4)
-        @everywhere $(func_name(:us, :l1F, :l3F, 2))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l3F");
-         setindex!(S_values, 0, $(idx_var_dprime));)
+        @everywhere $(func_name(:us, :l1F, :l3F, 2))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, 0, $(idx_var_dprime));
+         :l3F)
 
         @everywhere $(func_name(:cc, :l1F, :l3F, 3))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         (S_time >= $t3) &&
         (S_values[$(idx_var_n)] < $x3 || S_values[$(idx_var_n)] > $x4)
-        @everywhere $(func_name(:us, :l1F, :l3F, 3))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l3F");
-         setindex!(S_values, min(S_values[$(idx_var_dprime)], min(abs(S_values[$(idx_var_n)] - $x3), abs(S_values[$(idx_var_n)] - $x4))), $(idx_var_dprime)))
+        @everywhere $(func_name(:us, :l1F, :l3F, 3))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, min(S_values[$(idx_var_dprime)], min(abs(S_values[$(idx_var_n)] - $x3), abs(S_values[$(idx_var_n)] - $x4))), $(idx_var_dprime));
+         :l3F)
 
         # l3F loc
         # l3F => l1F
         @everywhere $(func_name(:cc, :l3F, :l1F, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = true
-        @everywhere $(func_name(:us, :l3F, :l1F, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l1F");
-         setindex!(S_values, x[$(idx_obs_var_F)], $(idx_var_n));
-         setindex!(S_values, getfield(Main, $(Meta.quot(sym_isabs_func)))(p, x), $(idx_var_isabs)))
+        @everywhere $(func_name(:us, :l3F, :l1F, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, x[$(idx_obs_var_F)], $(idx_var_n));
+         setindex!(S_values, getfield(Main, $(Meta.quot(sym_isabs_func)))(p, x), $(idx_var_isabs));
+         :l1F)
 
         # l3F => l2F
         @everywhere $(func_name(:cc, :l3F, :l2F, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         (S_time >= $t4 || istrue(S_values[$(idx_var_isabs)]))
-        @everywhere $(func_name(:us, :l3F, :l2F, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l2F");
-         setindex!(S_values, S_values[$(idx_var_d)] + S_values[$(idx_var_dprime)], $(idx_var_d)))
+        @everywhere $(func_name(:us, :l3F, :l2F, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, S_values[$(idx_var_d)] + S_values[$(idx_var_dprime)], $(idx_var_d));
+         :l2F)
     end
     eval(meta_elementary_functions)
 
diff --git a/automata/euclidean_distance_automaton.jl b/automata/euclidean_distance_automaton.jl
index e50b6e6d84da9f892e28dbb95ce7402fd7bfa412..22d633a427c5feca938599e4708b657ae151b30d 100644
--- a/automata/euclidean_distance_automaton.jl
+++ b/automata/euclidean_distance_automaton.jl
@@ -35,7 +35,7 @@ function create_euclidean_distance_automaton(m::ContinuousTimeModel, timeline::A
     idx_var_n = map_var_automaton_idx[:n] 
     idx_var_d = map_var_automaton_idx[:d] 
     idx_var_idx = map_var_automaton_idx[:idx] 
-    
+
     nbr_rand = rand(1:1000)
     basename_func = "$(replace(m.name, ' '=>'_'))_$(nbr_rand)"
     basename_func = replace(basename_func, '-'=>'_')
@@ -45,11 +45,11 @@ function create_euclidean_distance_automaton(m::ContinuousTimeModel, timeline::A
         # l0 loc
         # l0 => l1
         @everywhere $(func_name(:cc, :l0, :l1, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = true
-        @everywhere $(func_name(:us, :l0, :l1, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l1"); 
-         setindex!(S_values, x[$(idx_obs_var)], $(idx_var_n));
+        @everywhere $(func_name(:us, :l0, :l1, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, x[$(idx_obs_var)], $(idx_var_n));
          setindex!(S_values, 0.0, $(idx_var_d));
-         setindex!(S_values, 1.0, $(idx_var_idx)))
+         setindex!(S_values, 1.0, $(idx_var_idx));
+         :l1)
 
         # l1 loc
         # l1 => l1
@@ -58,23 +58,25 @@ function create_euclidean_distance_automaton(m::ContinuousTimeModel, timeline::A
         (tml = $(Tuple(timeline));
          tml_idx = tml[convert(Int, S_values[$(idx_var_idx)])];
          S_values[$(idx_var_t)] >= tml_idx)
-        @everywhere $(func_name(:us, :l1, :l1, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
+        @everywhere $(func_name(:us, :l1, :l1, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
         (y_obs = $(Tuple(observations));
          y_obs_idx = y_obs[convert(Int, S_values[$(idx_var_idx)])];
          setindex!(S_values, S_values[$(idx_var_d)] + (S_values[$(idx_var_n)]  - y_obs_idx)^2, 
-                                         $(idx_var_d));
-         setindex!(S_values, S_values[$(idx_var_idx)] + 1.0, $(idx_var_idx)))
-        
+                   $(idx_var_d));
+         setindex!(S_values, S_values[$(idx_var_idx)] + 1.0, $(idx_var_idx));
+         :l1)
+
         @everywhere $(func_name(:cc, :l1, :l1, 2))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = true 
-        @everywhere $(func_name(:us, :l1, :l1, 2))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (setindex!(S_values, x[$(idx_obs_var)], $(idx_var_n)))
-        
+        @everywhere $(func_name(:us, :l1, :l1, 2))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, x[$(idx_obs_var)], $(idx_var_n));
+         :l1)
+
         # l1 => l2
         @everywhere $(func_name(:cc, :l1, :l2, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         S_values[$(idx_var_idx)] >= ($nbr_observations + 1)
-        @everywhere $(func_name(:us, :l1, :l2, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l2"); 
-         setindex!(S_values, sqrt(S_values[$(idx_var_d)]), $(idx_var_d)))
+        @everywhere $(func_name(:us, :l1, :l2, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, sqrt(S_values[$(idx_var_d)]), $(idx_var_d));
+         :l2)
     end
     eval(meta_elementary_functions)
 
@@ -89,15 +91,15 @@ function create_euclidean_distance_automaton(m::ContinuousTimeModel, timeline::A
     edge1 = Edge([:ALL], getfield(Main, func_name(:cc, :l1, :l1, 1)), getfield(Main, func_name(:us, :l1, :l2, 1)))
     map_edges[:l1][:l1] = [edge1]
     for i = 1:nbr_observations
-        meta_edge_i = quote
-            @everywhere $(func_name(:cc, :l1, :l1, 1+i))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
-            S[:t] >= $(timeline[i])
-            @everywhere $(func_name(:us, :l1, :l1, 1+i))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
-            (setindex!(S_values, S[:d] + (S[:n]  - $(observations[i]))^2, $(idx_var_d));
-             setindex!(S_values, S[:idx] + 1.0, $(idx_var_idx)))
-        end
-        eval(meta_edge_i)
-        push!(map_edges[:l1][:l1], Edge(nothing, getfield(Main, func_name(:cc, :l1, :l1, 1+i)), getfield(Main, func_name(:us, :l1, :l1, 1+i))))
+    meta_edge_i = quote
+    @everywhere $(func_name(:cc, :l1, :l1, 1+i))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
+    S[:t] >= $(timeline[i])
+    @everywhere $(func_name(:us, :l1, :l1, 1+i))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
+    (setindex!(S_values, S[:d] + (S[:n]  - $(observations[i]))^2, $(idx_var_d));
+    setindex!(S_values, S[:idx] + 1.0, $(idx_var_idx)))
+    end
+    eval(meta_edge_i)
+    push!(map_edges[:l1][:l1], Edge(nothing, getfield(Main, func_name(:cc, :l1, :l1, 1+i)), getfield(Main, func_name(:us, :l1, :l1, 1+i))))
     end
     =#
     edge1 = Edge(nothing, getfield(Main, func_name(:cc, :l1, :l1, 1)), getfield(Main, func_name(:us, :l1, :l1, 1)))
diff --git a/automata/euclidean_distance_automaton_2.jl b/automata/euclidean_distance_automaton_2.jl
index 95cb14d8e4fb781583a7cf13acc1bb096a2c112b..c9da64cfe0c0ac71812c59fc1be5aa2ef06f3668 100644
--- a/automata/euclidean_distance_automaton_2.jl
+++ b/automata/euclidean_distance_automaton_2.jl
@@ -28,13 +28,13 @@ function create_euclidean_distance_automaton_2(m::ContinuousTimeModel, timeline:
     for loc in locations
         flow[loc] = vector_flow
     end
-    
+
     ## Edges
     map_edges = Dict{Location, Dict{Location, Vector{Edge}}}()
     for loc in locations 
         map_edges[loc] = Dict{Location, Vector{Edge}}()
     end
-   
+
     idx_obs_var = getfield(m, :map_var_idx)[sym_obs]
     to_idx(var::Symbol) = map_var_automaton_idx[var] 
     nbr_rand = rand(1:1000)
@@ -47,24 +47,25 @@ function create_euclidean_distance_automaton_2(m::ContinuousTimeModel, timeline:
         # l0 loc
         # l0 => l1
         @everywhere $(func_name(:cc, :l0, :l1, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = true
-        @everywhere $(func_name(:us, :l0, :l1, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("l1"); 
-         setindex!(S_values, x[$(idx_obs_var)], $(to_idx(:n)));
-         setindex!(S_values, 0.0, $(to_idx(:d))))
-       
+        @everywhere $(func_name(:us, :l0, :l1, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, x[$(idx_obs_var)], $(to_idx(:n)));
+         setindex!(S_values, 0.0, $(to_idx(:d)));
+         :l1)
+
         # lnbr_obs => lfinal
         @everywhere $(func_name(:cc, loc_nbr_obs, :lfinal, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         S_values[$(to_idx(:t))] >= $(timeline[nbr_observations])
-        @everywhere $(func_name(:us, loc_nbr_obs, :lfinal, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (ptr_loc[1] = Symbol("lfinal"); 
-         setindex!(S_values, S_values[$(to_idx(:d))] + (S_values[$(to_idx(:n))]-$(observations[nbr_observations]))^2, 
-                                         $(to_idx(:d)));
-         setindex!(S_values, sqrt(S_values[$(to_idx(:d))]), $(to_idx(:d))))
+        @everywhere $(func_name(:us, loc_nbr_obs, :lfinal, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, S_values[$(to_idx(:d))] + (S_values[$(to_idx(:n))]-$(observations[nbr_observations]))^2, 
+                   $(to_idx(:d)));
+         setindex!(S_values, sqrt(S_values[$(to_idx(:d))]), $(to_idx(:d)));
+         :lfinal)
 
         # lnbr_obs => lnbr_obs
         @everywhere $(func_name(:cc, loc_nbr_obs, loc_nbr_obs, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = true 
-        @everywhere $(func_name(:us, loc_nbr_obs, loc_nbr_obs, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-        (setindex!(S_values, x[$(idx_obs_var)], $(to_idx(:n))))
+        @everywhere $(func_name(:us, loc_nbr_obs, loc_nbr_obs, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+        (setindex!(S_values, x[$(idx_obs_var)], $(to_idx(:n)));
+         $(Meta.quot(loc_nbr_obs)))
     end
     eval(meta_elementary_functions)
     # l0 loc
@@ -88,14 +89,15 @@ function create_euclidean_distance_automaton_2(m::ContinuousTimeModel, timeline:
             # Defined below 
             @everywhere $(func_name(:cc, loci, locip1, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
             S_values[$(to_idx(:t))] >= $(timeline[i])
-            @everywhere $(func_name(:us, loci, locip1, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
-            (ptr_loc[1] = $(Meta.quot(locip1)); 
-             setindex!(S_values, S_values[$(to_idx(:d))] + (S_values[$(to_idx(:n))]-$(observations[i]))^2, 
-                                             $(to_idx(:d))))
+            @everywhere $(func_name(:us, loci, locip1, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
+            (setindex!(S_values, S_values[$(to_idx(:d))] + (S_values[$(to_idx(:n))]-$(observations[i]))^2, 
+                       $(to_idx(:d)));
+             $(Meta.quot(locip1)))
 
             @everywhere $(func_name(:cc, loci, loci, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = true 
-            @everywhere $(func_name(:us, loci, loci, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
-            (setindex!(S_values, x[$(idx_obs_var)], $(to_idx(:n))))
+            @everywhere $(func_name(:us, loci, loci, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
+            (setindex!(S_values, x[$(idx_obs_var)], $(to_idx(:n)));
+             $(Meta.quot(loci)))
         end
         eval(meta_elementary_functions_loci)
 
@@ -106,7 +108,7 @@ function create_euclidean_distance_automaton_2(m::ContinuousTimeModel, timeline:
         edge1 = Edge([:ALL], getfield(Main, func_name(:cc, loci, loci, 1)), getfield(Main, func_name(:us, loci, loci, 1)))
         map_edges[loci][loci] = [edge1]
     end
-    
+
     ## Constants
     constants = Dict{Symbol,Float64}(:nbr_obs => nbr_observations)
 
diff --git a/automata/period_automaton.jl b/automata/period_automaton.jl
index 01d2e145c4a8f1f1db3d1392c4ecc36873f8dc7a..0e02e93071cb28b3f331f7893d09cb09eccedfcb 100644
--- a/automata/period_automaton.jl
+++ b/automata/period_automaton.jl
@@ -73,108 +73,107 @@ function create_period_automaton(m::ContinuousTimeModel, L::Float64, H::Float64,
         # * l0 => l0
         @everywhere $(func_name(:cc, :l0, :l0, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         true
-        @everywhere $(func_name(:us, :l0, :l0, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
-        (nothing)
+        @everywhere $(func_name(:us, :l0, :l0, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
+        (:l0)
 
         # * l0 => l0prime
         @everywhere $(func_name(:cc, :l0, :l0prime, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         S_values[$(to_idx(:t))] >= $initT
-        @everywhere $(func_name(:us, :l0, :l0prime, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
-        (ptr_loc[1] = Symbol("l0prime");
-         setindex!(S_values, Inf, $(to_idx(:d))))
+        @everywhere $(func_name(:us, :l0, :l0prime, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
+        (setindex!(S_values, Inf, $(to_idx(:d)));
+		:l0prime)
 
         # * l0 => low
         @everywhere $(func_name(:cc, :l0, :low, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         S_values[$(to_idx(:t))] >= $initT
-        @everywhere $(func_name(:us, :l0, :low, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
-        (ptr_loc[1] = Symbol("low");
-         setindex!(S_values, 0.0, $(to_idx(:t)));
+        @everywhere $(func_name(:us, :l0, :low, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
+        (setindex!(S_values, 0.0, $(to_idx(:t)));
          setindex!(S_values, 0.0, $(to_idx(:top)));
          setindex!(S_values, -1, $(to_idx(:n)));
          setindex!(S_values, 0.0, $(to_idx(:tp)));
-         setindex!(S_values, Inf, $(to_idx(:d))))
+         setindex!(S_values, Inf, $(to_idx(:d)));
+		:low)
 
         # l0prime
         # * l0prime => l0prime
         @everywhere $(func_name(:cc, :l0prime, :l0prime, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         true
-        @everywhere $(func_name(:us, :l0prime, :l0prime, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
-        (nothing)
+        @everywhere $(func_name(:us, :l0prime, :l0prime, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
+        (:l0prime)
 
         # * l0prime => low
         @everywhere $(func_name(:cc, :l0prime, :low, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         true
-        @everywhere $(func_name(:us, :l0prime, :low, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
-        (ptr_loc[1] = Symbol("low");
-         setindex!(S_values, 0.0, $(to_idx(:t)));
+        @everywhere $(func_name(:us, :l0prime, :low, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
+        (setindex!(S_values, 0.0, $(to_idx(:t)));
          setindex!(S_values, 0.0, $(to_idx(:top)));
          setindex!(S_values, -1, $(to_idx(:n)));
-         setindex!(S_values, 0.0, $(to_idx(:tp))))
+         setindex!(S_values, 0.0, $(to_idx(:tp)));
+		:low)
 
         # low 
         # * low => low
         @everywhere $(func_name(:cc, :low, :low, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         S_values[$(to_idx(:n))] < $N
-        @everywhere $(func_name(:us, :low, :low, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
-        (nothing)
+        @everywhere $(func_name(:us, :low, :low, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
+        (:low)
 
         # * low => mid 
         @everywhere $(func_name(:cc, :low, :mid, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         S_values[$(to_idx(:n))] < $N
-        @everywhere $(func_name(:us, :low, :mid, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
-        (ptr_loc[1] = Symbol("mid"))
+        @everywhere $(func_name(:us, :low, :mid, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
+        (:mid)
 
         # * low => final
         @everywhere $(func_name(:cc, :low, :final, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         S_values[$(to_idx(:n))] == $N
-        @everywhere $(func_name(:us, :low, :final, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
-        (ptr_loc[1] = Symbol("final");
-         val_d = getfield(Main, $(Meta.quot(error_func)))(S_values[$(to_idx(:mean_tp))], 
+        @everywhere $(func_name(:us, :low, :final, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
+        (val_d = getfield(Main, $(Meta.quot(error_func)))(S_values[$(to_idx(:mean_tp))], 
                                                           S_values[$(to_idx(:var_tp))], 
                                                           $(ref_mean_tp), $(ref_var_tp));
-         setindex!(S_values, val_d, $(to_idx(:d))))
+         setindex!(S_values, val_d, $(to_idx(:d)));
+		:final)
 
         # mid
         # * mid => mid
         @everywhere $(func_name(:cc, :mid, :mid, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         S_values[$(to_idx(:n))] < $N
-        @everywhere $(func_name(:us, :mid, :mid, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
-        (nothing)
+        @everywhere $(func_name(:us, :mid, :mid, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
+        (:mid)
 
         # * mid => low 
         @everywhere $(func_name(:cc, :mid, :low, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         S_values[$(to_idx(:n))] < $N &&
         S_values[$(to_idx(:top))] == 0.0
-        @everywhere $(func_name(:us, :mid, :low, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
-        (ptr_loc[1] = Symbol("low"))
+        @everywhere $(func_name(:us, :mid, :low, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
+        (:low)
 
         @everywhere $(func_name(:cc, :mid, :low, 2))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         S_values[$(to_idx(:n))] == -1.0 &&
         S_values[$(to_idx(:top))] == 1.0
-        @everywhere $(func_name(:us, :mid, :low, 2))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
-        (ptr_loc[1] = Symbol("low");
-         setindex!(S_values, S_values[$(to_idx(:n))] + 1, $(to_idx(:n)));
+        @everywhere $(func_name(:us, :mid, :low, 2))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
+        (setindex!(S_values, S_values[$(to_idx(:n))] + 1, $(to_idx(:n)));
          setindex!(S_values, 0.0, $(to_idx(:top)));
-         setindex!(S_values, 0.0, $(to_idx(:tp))))
+         setindex!(S_values, 0.0, $(to_idx(:tp)));
+		:low)
 
         @everywhere $(func_name(:cc, :mid, :low, 3))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         (S_values[$(to_idx(:n))] == 0.0) &&
         S_values[$(to_idx(:top))] == 1.0
-        @everywhere $(func_name(:us, :mid, :low, 3))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
-        (ptr_loc[1] = Symbol("low");
-         setindex!(S_values, S_values[$(to_idx(:n))] + 1, $(to_idx(:n)));
+        @everywhere $(func_name(:us, :mid, :low, 3))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
+        (setindex!(S_values, S_values[$(to_idx(:n))] + 1, $(to_idx(:n)));
          setindex!(S_values, 0.0, $(to_idx(:top)));
          setindex!(S_values, f_mean_tp(S_values[$(to_idx(:mean_tp))], 
                                                    S_values[$(to_idx(:tp))],
                                                    S_values[$(to_idx(:n))]), $(to_idx(:mean_tp)));
-         setindex!(S_values, 0.0, $(to_idx(:tp))))
+         setindex!(S_values, 0.0, $(to_idx(:tp)));
+        :low)
 
         @everywhere $(func_name(:cc, :mid, :low, 4))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         (1 <= S_values[$(to_idx(:n))] < $N) &&
         S_values[$(to_idx(:top))] == 1.0
-        @everywhere $(func_name(:us, :mid, :low, 4))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
-        (ptr_loc[1] = Symbol("low");
-         setindex!(S_values, S_values[$(to_idx(:n))] + 1, $(to_idx(:n)));
+        @everywhere $(func_name(:us, :mid, :low, 4))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
+        (setindex!(S_values, S_values[$(to_idx(:n))] + 1, $(to_idx(:n)));
          setindex!(S_values, 0.0, $(to_idx(:top)));
          setindex!(S_values, g_var_tp(S_values[$(to_idx(:var_tp))], 
                                                    S_values[$(to_idx(:mean_tp))],
@@ -183,47 +182,48 @@ function create_period_automaton(m::ContinuousTimeModel, L::Float64, H::Float64,
          setindex!(S_values, f_mean_tp(S_values[$(to_idx(:mean_tp))], 
                                                    S_values[$(to_idx(:tp))],
                                                    S_values[$(to_idx(:n))]), $(to_idx(:mean_tp)));
-         setindex!(S_values, 0.0, $(to_idx(:tp))))
+         setindex!(S_values, 0.0, $(to_idx(:tp)));
+        :low)
 
         # * mid => high
         @everywhere $(func_name(:cc, :mid, :high, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         S_values[$(to_idx(:n))] < $N
-        @everywhere $(func_name(:us, :mid, :high, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
-        (ptr_loc[1] = Symbol("high");
-         setindex!(S_values, 1.0, $(to_idx(:top))))
+        @everywhere $(func_name(:us, :mid, :high, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
+        (setindex!(S_values, 1.0, $(to_idx(:top)));
+		:high)
 
         # * mid => final
         @everywhere $(func_name(:cc, :mid, :final, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         S_values[$(to_idx(:n))] == $N
-        @everywhere $(func_name(:us, :mid, :final, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
-        (ptr_loc[1] = Symbol("final");
-         val_d = getfield(Main, Meta.quot($error_func))(S_values[$(to_idx(:mean_tp))],
+        @everywhere $(func_name(:us, :mid, :final, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
+        (val_d = getfield(Main, Meta.quot($error_func))(S_values[$(to_idx(:mean_tp))],
                                                         S_values[$(to_idx(:var_tp))],
                                                         $(ref_mean_tp), $(ref_var_tp));
-         setindex!(S_values, val_d, $(to_idx(:d))))
+         setindex!(S_values, val_d, $(to_idx(:d)));
+		:final)
 
         # high 
         # * high => high
         @everywhere $(func_name(:cc, :high, :high, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         S_values[$(to_idx(:n))] < $N
-        @everywhere $(func_name(:us, :high, :high, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
-        (nothing)
+        @everywhere $(func_name(:us, :high, :high, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
+        (:high)
 
         # * high => mid
         @everywhere $(func_name(:cc, :high, :mid, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         S_values[$(to_idx(:n))] < $N
-        @everywhere $(func_name(:us, :high, :mid, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
-        (ptr_loc[1] = Symbol("mid"))
+        @everywhere $(func_name(:us, :high, :mid, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
+        (:mid)
 
         # * high => final
         @everywhere $(func_name(:cc, :high, :final, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) = 
         S_values[$(to_idx(:n))] == $N
-        @everywhere $(func_name(:us, :high, :final, 1))(ptr_loc::Vector{Symbol}, S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
-        (ptr_loc[1] = Symbol("final");
-         val_d = getfield(Main, Meta.quot($error_func))(S_values[$(to_idx(:mean_tp))],
+        @everywhere $(func_name(:us, :high, :final, 1))(S_time::Float64, S_values::Vector{Float64}, x::Vector{Int}, p::Vector{Float64}) =
+        (val_d = getfield(Main, Meta.quot($error_func))(S_values[$(to_idx(:mean_tp))],
                                                         S_values[$(to_idx(:var_tp))],
                                                         $(ref_mean_tp), $(ref_var_tp));
-         setindex!(S_values, val_d, $(to_idx(:d))))
+         setindex!(S_values, val_d, $(to_idx(:d)));
+		:final)
     end
     eval(meta_elementary_functions)
 
diff --git a/core/lha.jl b/core/lha.jl
index eb3ecc6ecea5e8981177d11337a02e364ee43732..2843d3f9732955f8a91c6ff7050ee4060647934e 100644
--- a/core/lha.jl
+++ b/core/lha.jl
@@ -70,7 +70,7 @@ function Base.copyto!(Sdest::StateLHA, Ssrc::StateLHA)
     Sdest.A = Ssrc.A
     Sdest.loc = Ssrc.loc
     for i = eachindex(Sdest.values)
-        Sdest.values[i] = Ssrc.values[i]
+        @inbounds Sdest.values[i] = Ssrc.values[i]
     end
     Sdest.time = Ssrc.time
 end
@@ -96,7 +96,7 @@ end
 # are not greater than 2
 function _push_edge!(edge_candidates::Vector{Edge}, edge::Edge, nbr_candidates::Int)
     if nbr_candidates < 2
-        edge_candidates[nbr_candidates+1] = edge
+        @inbounds edge_candidates[nbr_candidates+1] = edge
     else
         push!(edge_candidates, edge)
     end
@@ -110,8 +110,9 @@ function _find_edge_candidates!(edge_candidates::Vector{Edge},
                                 only_asynchronous::Bool)
     nbr_candidates = 0
     for target_loc in keys(edges_from_current_loc)
+        if !Λ[target_loc](x) continue end
         for edge in edges_from_current_loc[target_loc]
-            if Λ[target_loc](x) && getfield(edge, :check_constraints)(S_time, S_values, x, p)
+            if getfield(edge, :check_constraints)(S_time, S_values, x, p)
                 if getfield(edge, :transitions) == nothing
                     _push_edge!(edge_candidates, edge, nbr_candidates)
                     nbr_candidates += 1
@@ -159,8 +160,11 @@ function next_state!(Snplus1::StateLHA, A::LHA,
     turns = 0
     current_values = getfield(Snplus1, :values)
     current_time = getfield(Snplus1, :time)
-    ptr_current_loc = [getfield(Snplus1, :loc)]
-    
+    current_loc = getfield(Snplus1, :loc)
+    Λ = getfield(A, :Λ)
+    flow = getfield(A, :flow)
+    map_edges = getfield(A, :map_edges)
+
     if verbose 
         println("##### Begin next_state!")
         @show xnplus1, tnplus1, tr_nplus1
@@ -171,9 +175,9 @@ function next_state!(Snplus1::StateLHA, A::LHA,
     while true
         turns += 1
         #edge_candidates = empty!(edge_candidates) 
-        edges_from_current_loc = getfield(A, :map_edges)[ptr_current_loc[1]]
+        edges_from_current_loc = map_edges[current_loc]
         # Save all edges that satisfies transition predicate (asynchronous ones)
-        nbr_candidates = _find_edge_candidates!(edge_candidates, edges_from_current_loc, getfield(A, :Λ), 
+        nbr_candidates = _find_edge_candidates!(edge_candidates, edges_from_current_loc, Λ, 
                                                 current_time, current_values, xn, p, true)
         # Search the one we must chose, here the event is nothing because 
         # we're not processing yet the next event
@@ -182,7 +186,7 @@ function next_state!(Snplus1::StateLHA, A::LHA,
         # Should be xn here
         #first_round = false
         if ind_edge > 0
-            getfield(edge_candidates[ind_edge], :update_state!)(ptr_current_loc, current_time, current_values, xn, p)
+            current_loc = getfield(edge_candidates[ind_edge], :update_state!)(current_time, current_values, xn, p)
         else
             if verbose println("No edge fired") end
             break 
@@ -191,7 +195,7 @@ function next_state!(Snplus1::StateLHA, A::LHA,
             @show turns
             @show edge_candidates
             @show ind_edge, detected_event, nbr_candidates
-            @show ptr_current_loc[1]
+            @show current_loc
             @show current_time
             @show current_values
             if turns == 500
@@ -218,29 +222,29 @@ function next_state!(Snplus1::StateLHA, A::LHA,
     end
     # Now time flies according to the flow
     for i in eachindex(current_values)
-        @inbounds coeff_deriv = (getfield(A, :flow)[ptr_current_loc[1]])[i]
+        @inbounds coeff_deriv = flow[current_loc][i]
         if coeff_deriv > 0
             @inbounds current_values[i] += coeff_deriv*(tnplus1 - current_time)
         end
     end
     current_time = tnplus1
     if verbose 
-        @show ptr_current_loc[1]
+        @show current_loc
         @show current_time
         @show current_values
     end
     # Now firing an edge according to the event 
     while true
         turns += 1
-        edges_from_current_loc = getfield(A, :map_edges)[ptr_current_loc[1]]
+        edges_from_current_loc = map_edges[current_loc]
         # Save all edges that satisfies transition predicate (synchronous ones)
-        nbr_candidates = _find_edge_candidates!(edge_candidates, edges_from_current_loc, getfield(A, :Λ), 
+        nbr_candidates = _find_edge_candidates!(edge_candidates, edges_from_current_loc, Λ, 
                                                 current_time, current_values, xnplus1, p, false)
         # Search the one we must chose
         ind_edge, detected_event = _get_edge_index(edge_candidates, nbr_candidates, detected_event, tr_nplus1)
         # Update the state with the chosen one (if it exists)
         if ind_edge > 0
-            getfield(edge_candidates[ind_edge], :update_state!)(ptr_current_loc, current_time, current_values, xnplus1, p)
+            current_loc = getfield(edge_candidates[ind_edge], :update_state!)(current_time, current_values, xnplus1, p)
         end
         if ind_edge == 0 || detected_event
             if verbose 
@@ -250,7 +254,7 @@ function next_state!(Snplus1::StateLHA, A::LHA,
                     @show edge_candidates
                     @show ind_edge, detected_event, nbr_candidates
                     @show detected_event
-                    @show ptr_current_loc[1]
+                    @show current_loc
                     @show current_time
                     @show current_values
                 else
@@ -264,7 +268,7 @@ function next_state!(Snplus1::StateLHA, A::LHA,
             @show edge_candidates
             @show ind_edge, detected_event, nbr_candidates
             @show detected_event
-            @show ptr_current_loc[1]
+            @show current_loc
             @show current_time
             @show current_values
             if turns == 500
@@ -286,7 +290,7 @@ function next_state!(Snplus1::StateLHA, A::LHA,
         end
         =#
     end
-    setfield!(Snplus1, :loc, ptr_current_loc[1])
+    setfield!(Snplus1, :loc, current_loc)
     setfield!(Snplus1, :time, current_time)
     if verbose 
         @show Snplus1