Fixed monkey patch of mangleQuery.