Fixes for loading legacy queries