Two minor code cleanups and one NULL deref on error fix.