str.c: improved error handling and comments.