fixes for slow query