meamory leakege fix, intellegent unpack algorithm