fix some (possible) memory leaks