Applied CS patch from fabbot