Code refactor and cleaning.