Use a buffer to speed up inserts.