Catch exceptions when reading from files. Determine the device size correctly.