Some changes in file saving logic