Fixing race condition/locking/some weird issue in a multi-threaded envir...

...onment.  Not sure why this is happening.