Few trace prints. Fixing bad lexical cast. Fixing few possible deadlocks.