Fix error handling. This creates a backwards incompatibility, as noted in README.