Added some code for memory management in decompression