Handle some null pointer exceptions