Fix errors pointed out by Tony
Merge pull request #9 from jni/seg-fix

Fix errors pointed out by Tony