Fixed some queries broken by security patch