Fixed some memory leaking.