Improve error message and doc strings.