Add threads and refactor logger with ThreadLogger