Added a mutex for the message queue.
Resolved some compile-time errors when built with release options.
Merge remote-tracking branch 'origin/master'