Fixed a bug in renaming functions. Was not checking properly if file already exists before overwriting