Fixed some socket/thread issues.
Merge remote-tracking branch 'upstream/develop' into mungo