Minor fix and NPE fix.