Refactors document insertion so that it vacuums up new docs.