Remove duplicate code.
Merge pull request #1045 from tweise/hds

Remove duplicate code.