Added a workaround for race conditions with files.