fix 2 (possible) memory leaks

nit: also set it to zero after deletion