Memory leaks and compiler warnings

Plugged memory leaks. Real and imaginary