compression and cleanup