fix potential leaks found by analyzer