Manty fixes. Mostly binlog for messages
Merge github.com:vysheng/tg
fixed binlog problems. Set lock on binlog