Update native code to avoid segfault