Code refactor and formatting.