Fix potentially bad query values