Fix nif to avoid segfault on upgrade
Merge pull request #10 from AntonSizov/master

Fix nif to avoid segfault on upgrade