Backport instance harvesting fix from master

I messed up the backport last time.