Fix some leak problem. Still can't handle rehash no matter how, keeping working on it.