wipe memory leak and fix compress logic bug