Patch based on this patch with small changes for trunk...