fixed tcp publish, and all of the synchronization issues in logging thread! (with semaphores)