fix fatal memory leaks