Do not compare an array against NULL.
Fix possible NULL pointer dereferences.
Remove dead code.