tidy up error messages; fix a docstring