Finished rename code.
Added comments. Some code cleanup.