Tidy up error handling
Merge pull request #21 from alexweissman/master

Tidy up error handling