better and more consistent error handling (#45)