updated query builder to support sub where classes, updated related classes