fixes for stat queries