Fix bugs in message dispatching
Fix logging format