Update native code to avoid segfault
Merge pull request #7 from tryba/fix-segfault

Update native code to avoid segfault