Merge pull request #194 from apaiva/npe_fix

NPE fix
NPE fix
Merge branch 'master' into npe_fix