query scripts and small other changes