Initial implementation of Ian McHugh's CPD code.