Some preliminary query stuff.