Fix possible race condition in handling of known items