Fix bug when cleaning up livedb documents