Fix memory leaks for 64 bit