Made print and resize handlers switch to main thread