Lots of NPE fixes.