adding graulund's commit #194a4964c1 and re-adding my customizations