Cleanup error handling

Close #2