Refactor common code to support DES segment too.