Clean up of file checking logic