Fix possible NPEs.