How to refactor code?

How to start code refactoring? How to do it correctly and is it worth doing code analysis before refactoring?

Very much so. This will give you a better overall picture in determining what to refactor and simplify. That last word is the important one, here. Simplified code is easier to read and to analyze. On the whole, refactoring is not all that important, especially if the code works as expected, all possible edge cases are mitigated, and the code is readable.