Fixes for multi-threaded builds