Re-applied fix for bug#9501