I've removed the "render" flag to prevent the double rendering of metadata (also see FS#1706
The code doesn't work as you describe above. addLogEntry uses the old metadata to determine if it needs to create keys for some items. Those keys that it does create are passed to p_set_metadata(). p_set_metadata() merges the keys with the existing metadata. Nothing should be dropped.
Was there a particular problem you came across?