Investigations, refactoring and minor fixes
Fix popup not closing by upgrading query forms