Fix random NPE crashes