Merge pull request #5 from evmarkov/master

Improved error handling