Refactor code

Use code review tool like SonarLint to analyze code.

Remove unused imports and variables and methods. Don't use variable injection - use constructor instead. Etc.