Fixed upsert bug #8