Code cleanup with valgrind / scan-build