Fixes some bugs with empty error messages.
Fixes #305.