fix minor memory leaks