Improve error handling
Fix braces, add extra code
.
Merge pull request #291 from ArchZombie/master

Improving error handling.