Simplify query class hierarchy