Add null pointer checks to cope with initialisation errors

NPE can occur on startup depending on the order files are read.