Fix some NPE check