Fix error messages and add comments.