Fix exponentially growing database when using in-place-imports on a regular base #1676