Fix minor compaction algorithm bug

Thanks to @dlongley for spotting it

This addresses #253.