Updated to make windows manage their own threads correctly.