Multiple improvments to checking validity.