fix some memory bug.