Some useful error handling
Fixes #4