Fixed bugs in validation.