Fix null pointer crash