Pluged more memory leaks.
We don't need to check for NULL before calling free.