Correct memory leaks and some FFT code