Added thread locking for sorting queue's
Merge remote-tracking branch 'upstream/dev' into dev