Protect against null pointer exceptions