Added NPE check in spellchecking