Added checks for validity of binary files.