Fix Valgrind errors

Signed-off-by: Michael Steinert <mike.steinert@gmail.com>