Fix problem with unsaved queries