fixed handle leak
fixed alloc mismatch