Fixing the error handling as suggested in #45.
I did not change it in all the places, and I won't do it now