Fixed pre-mature deletion of files