Fix possible NPEs