Better error handling
Closes #6