Cppcheck possible null pointer dereferences

A few changes to pointer dereferences, some of them are actual possible null pointer derefences, others are just to silence cppcheck.