Fix probable null pointer exceptions.