Replace IORef with TVar