Fixed bug where the to avoid application crash on orientation change
Improved file checking