let get_value env = function
        | GlobalVar(uid, ind) -> let (_, value) = env.heap.(ind) in value
        | LocalVar(uid, depth, ind) ->
                        match env.closure_vars with
                        | None -> env.stackframes.(depth).(ind)
                        | Some h ->
                                        try match Hashtbl.find h (depth, ind) with
                                                | RUndefined -> env.stackframes.(depth).(ind) (* needed for recursive function defs *)
                                                | value -> value
                                        with Not_found -> env.stackframes.(depth).(ind)