Added active flag and sort order in Query objects