Some fixes after running with valgrind
Merge pull request #310 from khogenso/devel

Some fixes after running with valgrind