finalized record writing api, issue #6