fixed a typo in error message
updated comments for some functions