Make file loading more robust