Fix possible mem leaks