Change cleanup to a validate function and add comment.