dedup improvements, and a bugfix