Added missing components in query building (limit, offset, distinct)