Merged patch from ed