Applying Scott's fix for #1198.