Improved handling of loading invalid files