Fix for bug#9418. (improved)