Fix for Issue #12

- fixed errors reported by valgrind
Merge remote-tracking branch 'upstream/master'