code cleanup and logging
added thread naming and made thread a daemon