Starting cleaning the messy code before refactoring