Merge problems fixed, also added the renaming and handle the case where the file might exist