some thread safety adjustments