minimal query cleanup