Complete reworking of validation logic.