Improve method signature of duplication function.
Make dump() method better testable.