fixed up the integrity queries