Imported from https://github.com/PhilippBach/hdm