Fixed some query stuff