memleak and segfault fixed
Merge pull request #5 from zanella/master

memleak and segfault fixed