Uninitialized memory and leaks that valgrind was complaining about
Merge pull request #482 from wivlaro/valgrind-fix

Uninitialized memory and leaks that valgrind was complaining about