Fix potential leaks