Fix bugs related to order_by statements