More efficient checking of file validity.