fixing usage of TMVar.