fixed insertion into primary index when there were deleted documents
cppcheck fixes