Fix some "dereference after null check" issues
Coverity CID 1034372, CID 1034374, CID 1034375, CID 1034377, CID 1034378
Fix some "dereference before null check" issues
Coverity CID 1034503 to CID 1034508