Ensure output buffer is flushed.
Factor out key-value pair structure.
Add logging output for error conditions.
Update reference manual.