buffer.c: improved error handling and comments.
compat.c: improved error handling and comments.