Fix up error handling
Merge pull request #8 from sarina/master

Fix up error handling