Cleaning (aka refactor) code is necessary, not to change what it does but how it works.

Baselines are useful as a backup.

This seemed like a useful screenshot to make to remember the order of steps in order to refactor.

Automating testing is very useful for bigger programs. For visual things you might need to find a bit of a work around when automating, like by taking screenshots.

Try to also recreate the steps manually later in the same way you did it automatically.

This screenshot also seemed useful, its the cycle of coding in one image.

Refactoring allows you to be a bit sloppier in the beginning so you can fix it later, or even just remove the old code. Again, do not forget about the cycle, to test and create new baselines.

Don't refactor too early or when unnecessary.

Keep performance in mind.

This little feature built into c# allows you to see how long a piece of code takes to execute.

Example:

Stringbuilders help when making a longer string.

Again, another Example: