Threading bugs

These were found running with QT_FATAL_WARNINGS environment set. Just making a test run through Team City at this point. If that works, I'll clean up the commits with better explanations for the individual changes.

This should hopefully fix the Windows build to bring it up above the basket case level.