Fix errors in validation code