Fix some memory leak, at least pass valgrind for now