Fix NPE and config