Various updates to the validation code

Please revise and comment.