         raise ElixirScript.CompileError,
           message: "An error occurred while compiling #{inspect(module)}: #{error}",
           severity: :error
+    end
+  end
+
+  defp do_execute(module, pid) do
+    result = get_debug_info(module, pid)
+    do_execute(module, result, pid)
+  end
+
+  defp get_debug_info(module, pid) do
+    case ModuleState.get_in_memory_module(pid, module) do
+      nil ->
+        ElixirScript.Beam.debug_info(module)
+
+      beam ->
+        ElixirScript.Beam.debug_info(beam)
     end
   end
 


  defp walk({:., _, [module, function]}, state) do
    if ElixirScript.Translate.Module.is_elixir_module(module) do
      ModuleState.put_used_module(state.pid, state.module, module)

      if ModuleState.get_module(state.pid, module) == nil do
        do_execute(module, state.pid)
      end
    else
      walk(module, state)

       when is_atom(form) and form not in [BitString, Function, PID, Port, Reference, Any, Elixir] do
    if ElixirScript.Translate.Module.is_elixir_module(form) and
         !ElixirScript.Translate.Module.is_js_module(form, state) do
      if ModuleState.get_module(state.pid, form) == nil do
        case get_debug_info(form, state.pid) do
          {:ok, _} = result ->
            ModuleState.put_used_module(state.pid, state.module, form)
            do_execute(form, result, state.pid)

          result ->
            do_execute(form, result, state.pid)
        end
      else
        ModuleState.put_used_module(state.pid, state.module, form)
      end
    end
  end
