Fix possible NPE's