Completed .query, fixed other minor issues