RID query fixes