Minor query and schema fixes