added restore_file option
added debugging