Improved error handling.
Merge pull request #5 from hugoatease/master

Improved error handling.