fix some memory alloc