Rework message passing between threads. Version 0.9.6