Early return to avoid crashing.
More early returning on error.
Merge pull request #344 from mozilla/fix-crash

Fix crashes