Fix bugs in rename file and do some refactoring.
Edit the README after changes to rename file.