Added lock for printing results from all threads.
Merge branch 'fix-console-printing' into develop
Fixed problems with reductions (tuple element expressions not extracted).
Merge branch 'fix-reductions' into develop