Some fixes to overall stability in multi threaded environment.

Signed-off-by: Daniel (dmilith) Dettlaff <dmilith@verknowsys.com>