fixed some null pointer exceptions
Merge pull request #8 from SantiagoTorres/npe_fixes

fixed some null pointer exceptions