Maybe fixed a bug caused potentially memory leak.