error handling fixes

fixes #135