Make better log rendering and Code refactoring