More robust file management