Replace weak IORef with weak TVar, so we can get rid of unsafeIOToSTM