Fix 3-bites fault and memoty leak