Fix the threading issues on Pi.