more query cleanup