It may be good to have unit test cases

Study the code layout.

Create base classes, Interfaces etc

Create your own library

Make Copy of Class files before modifying.

Refactoring is easier with Injectables. Just create a new class.

Commit in small increments.

Continuously Integrate your code

Refactor one functionality at a time instead of everything at once.