Patches from Gerd v. Egidy (slightly reworked)