Start thread when the window will have been created. Fix logic error.