Don't double check for NULLs and don't initialize if not necessary. No functional changes.
simplifies a lot of error handling code, and fixes many memory leaks.