Some NPE fixes