This code (safeRename) was taken from WTP. I never investigated their assumptions, but I also didn't want to change their code if I didn't understand their assumptions.