Fix possible mem-leaks