[[ Valgrind ]] Fix various memory errors.